rename
This commit is contained in:
+3
-3
@@ -4,7 +4,7 @@ use crate::Rng;
|
|||||||
pub trait Game {
|
pub trait Game {
|
||||||
type Instruction;
|
type Instruction;
|
||||||
fn possible_instructions(&self) -> impl Iterator<Item = Self::Instruction> + use<Self>;
|
fn possible_instructions(&self) -> impl Iterator<Item = Self::Instruction> + use<Self>;
|
||||||
fn validate_instruction(&self, instruction: Self::Instruction) -> bool;
|
fn is_instruction_valid(&self, instruction: Self::Instruction) -> bool;
|
||||||
fn process_instruction(&mut self, instruction: Self::Instruction);
|
fn process_instruction(&mut self, instruction: Self::Instruction);
|
||||||
fn is_win(&self) -> bool;
|
fn is_win(&self) -> bool;
|
||||||
}
|
}
|
||||||
@@ -192,8 +192,8 @@ where
|
|||||||
fn possible_instructions(&self) -> impl Iterator<Item = Self::Instruction> + use<G> {
|
fn possible_instructions(&self) -> impl Iterator<Item = Self::Instruction> + use<G> {
|
||||||
self.state.possible_instructions()
|
self.state.possible_instructions()
|
||||||
}
|
}
|
||||||
fn validate_instruction(&self, instruction: Self::Instruction) -> bool {
|
fn is_instruction_valid(&self, instruction: Self::Instruction) -> bool {
|
||||||
self.state.validate_instruction(instruction)
|
self.state.is_instruction_valid(instruction)
|
||||||
}
|
}
|
||||||
fn process_instruction(&mut self, instruction: Self::Instruction) {
|
fn process_instruction(&mut self, instruction: Self::Instruction) {
|
||||||
self.history.push(instruction.clone());
|
self.history.push(instruction.clone());
|
||||||
|
|||||||
+4
-4
@@ -75,7 +75,7 @@ impl KlondikeState {
|
|||||||
fn pile_mut(&mut self, index: KlondikePileId) -> &mut Pile {
|
fn pile_mut(&mut self, index: KlondikePileId) -> &mut Pile {
|
||||||
&mut self.piles[index as usize]
|
&mut self.piles[index as usize]
|
||||||
}
|
}
|
||||||
fn validate_instruction(&self, instruction: KlondikeInstruction) -> bool {
|
fn is_instruction_valid(&self, instruction: KlondikeInstruction) -> bool {
|
||||||
match instruction {
|
match instruction {
|
||||||
// Stock -> Stock draws a card or resets the stock
|
// Stock -> Stock draws a card or resets the stock
|
||||||
KlondikeInstruction {
|
KlondikeInstruction {
|
||||||
@@ -208,10 +208,10 @@ impl Game for Klondike {
|
|||||||
type Instruction = KlondikeInstruction;
|
type Instruction = KlondikeInstruction;
|
||||||
fn possible_instructions(&self) -> impl Iterator<Item = Self::Instruction> + use<> {
|
fn possible_instructions(&self) -> impl Iterator<Item = Self::Instruction> + use<> {
|
||||||
let state = self.state.clone();
|
let state = self.state.clone();
|
||||||
KlondikeIter::new().filter(move |&instruction| state.validate_instruction(instruction))
|
KlondikeIter::new().filter(move |&instruction| state.is_instruction_valid(instruction))
|
||||||
}
|
}
|
||||||
fn validate_instruction(&self, instruction: Self::Instruction) -> bool {
|
fn is_instruction_valid(&self, instruction: Self::Instruction) -> bool {
|
||||||
self.state.validate_instruction(instruction)
|
self.state.is_instruction_valid(instruction)
|
||||||
}
|
}
|
||||||
fn process_instruction(&mut self, instruction: Self::Instruction) {
|
fn process_instruction(&mut self, instruction: Self::Instruction) {
|
||||||
let card = self.pile_mut(instruction.src).pop().unwrap();
|
let card = self.pile_mut(instruction.src).pop().unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user