add hint
This commit is contained in:
@@ -120,6 +120,7 @@ impl core::str::FromStr for Parsed<KlondikePileId> {
|
|||||||
|
|
||||||
enum SessionInstruction {
|
enum SessionInstruction {
|
||||||
Undo,
|
Undo,
|
||||||
|
Hint,
|
||||||
Klondike(KlondikeInstruction),
|
Klondike(KlondikeInstruction),
|
||||||
}
|
}
|
||||||
impl core::str::FromStr for SessionInstruction {
|
impl core::str::FromStr for SessionInstruction {
|
||||||
@@ -127,6 +128,7 @@ impl core::str::FromStr for SessionInstruction {
|
|||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
Ok(match s {
|
Ok(match s {
|
||||||
"UNDO" | "undo" => Self::Undo,
|
"UNDO" | "undo" => Self::Undo,
|
||||||
|
"HINT" | "hint" => Self::Hint,
|
||||||
other => {
|
other => {
|
||||||
let Parsed(ki) = other.parse()?;
|
let Parsed(ki) = other.parse()?;
|
||||||
Self::Klondike(ki)
|
Self::Klondike(ki)
|
||||||
@@ -152,6 +154,11 @@ fn main() -> Result<(), std::io::Error> {
|
|||||||
// run game
|
// run game
|
||||||
match instruction {
|
match instruction {
|
||||||
SessionInstruction::Undo => session.undo(),
|
SessionInstruction::Undo => session.undo(),
|
||||||
|
SessionInstruction::Hint => {
|
||||||
|
for instruction in session.possible_instructions() {
|
||||||
|
println!("{instruction:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
SessionInstruction::Klondike(instruction) => {
|
SessionInstruction::Klondike(instruction) => {
|
||||||
if session.is_instruction_valid(instruction) {
|
if session.is_instruction_valid(instruction) {
|
||||||
session.process_instruction(instruction);
|
session.process_instruction(instruction);
|
||||||
|
|||||||
Reference in New Issue
Block a user