implement staging api
This commit is contained in:
@@ -210,7 +210,7 @@ fn find_valid_instruction(
|
||||
});
|
||||
let instruction =
|
||||
KlondikeInstruction::DstTableau(DstTableau { tableau, src });
|
||||
if state.is_instruction_valid(config, instruction) {
|
||||
if state.is_instruction_valid(config, &instruction) {
|
||||
return Some(instruction);
|
||||
}
|
||||
}
|
||||
@@ -228,7 +228,7 @@ fn find_valid_instruction(
|
||||
_ => return None,
|
||||
};
|
||||
state
|
||||
.is_instruction_valid(config, instruction)
|
||||
.is_instruction_valid(config, &instruction)
|
||||
.then_some(instruction)
|
||||
}
|
||||
|
||||
@@ -277,13 +277,16 @@ fn main() -> Result<(), std::io::Error> {
|
||||
.state()
|
||||
.get_auto_move(&session.config().inner)
|
||||
{
|
||||
session.process_instruction(instruction);
|
||||
session.stage_instruction(instruction).unwrap().commit();
|
||||
} else {
|
||||
println!("No valid moves!");
|
||||
}
|
||||
}
|
||||
SessionInstruction::Stock => {
|
||||
session.process_instruction(KlondikeInstruction::RotateStock)
|
||||
session
|
||||
.stage_instruction(KlondikeInstruction::RotateStock)
|
||||
.unwrap()
|
||||
.commit();
|
||||
}
|
||||
SessionInstruction::Klondike(naive_instruction) => {
|
||||
if let Some(instruction) = find_valid_instruction(
|
||||
@@ -291,7 +294,7 @@ fn main() -> Result<(), std::io::Error> {
|
||||
session.state().state(),
|
||||
naive_instruction,
|
||||
) {
|
||||
session.process_instruction(instruction);
|
||||
session.stage_instruction(instruction).unwrap().commit();
|
||||
} else {
|
||||
println!("Invalid move!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user