implement staging api

This commit is contained in:
2026-07-07 18:44:50 -07:00
parent a511679a47
commit 8c64583c00
5 changed files with 65 additions and 56 deletions
+8 -5
View File
@@ -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!");
}