remove separate trait
This commit is contained in:
+11
-13
@@ -1,6 +1,6 @@
|
||||
pub type Rng = rand::rngs::StdRng;
|
||||
|
||||
use card_game::{Card, Game, InstructionConsumer, Pile, Rank, Stack, StagedInstruction};
|
||||
use card_game::{Card, Game, Pile, Rank, Stack, StagedInstruction};
|
||||
|
||||
#[cfg(test)]
|
||||
mod test;
|
||||
@@ -835,18 +835,6 @@ impl Game for Klondike {
|
||||
fn is_instruction_valid(&self, config: &Self::Config, instruction: &Self::Instruction) -> bool {
|
||||
self.state.is_instruction_valid(config, instruction)
|
||||
}
|
||||
fn is_win(&self) -> bool {
|
||||
// all foundations contain all ranks
|
||||
self.state.foundations.iter().all(|foundation| {
|
||||
foundation.len() == Rank::RANKS.len()
|
||||
&& foundation
|
||||
.iter()
|
||||
.zip(Rank::RANKS)
|
||||
.all(|(card, rank)| card.rank() == rank)
|
||||
})
|
||||
}
|
||||
}
|
||||
impl InstructionConsumer for Klondike {
|
||||
fn process_instruction(valid_instruction: StagedInstruction<'_, Self>) {
|
||||
let (game, stats, config, instruction) = valid_instruction.consume();
|
||||
stats.increment_moves();
|
||||
@@ -886,6 +874,16 @@ impl InstructionConsumer for Klondike {
|
||||
}
|
||||
}
|
||||
}
|
||||
fn is_win(&self) -> bool {
|
||||
// all foundations contain all ranks
|
||||
self.state.foundations.iter().all(|foundation| {
|
||||
foundation.len() == Rank::RANKS.len()
|
||||
&& foundation
|
||||
.iter()
|
||||
.zip(Rank::RANKS)
|
||||
.all(|(card, rank)| card.rank() == rank)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
|
||||
Reference in New Issue
Block a user