add new game command

This commit is contained in:
2026-05-15 12:38:40 -07:00
parent a5ca7ff25d
commit 792c9acba3
+3
View File
@@ -119,6 +119,7 @@ impl core::str::FromStr for Parsed<KlondikePileId> {
}
enum SessionInstruction {
New,
Undo,
Hint,
Klondike(KlondikeInstruction),
@@ -127,6 +128,7 @@ impl core::str::FromStr for SessionInstruction {
type Err = Invalid;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"NEW" | "new" => Self::New,
"UNDO" | "undo" => Self::Undo,
"HINT" | "hint" => Self::Hint,
other => {
@@ -153,6 +155,7 @@ fn main() -> Result<(), std::io::Error> {
// run game
match instruction {
SessionInstruction::New => session = Session::new(Klondike::new_random_default()),
SessionInstruction::Undo => session.undo(),
SessionInstruction::Hint => {
for instruction in session.possible_instructions() {