remove separate trait

This commit is contained in:
2026-07-08 09:34:49 -07:00
parent 1245ba1947
commit eac07676dd
2 changed files with 16 additions and 33 deletions
+11 -13
View File
@@ -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")]