add new game command
This commit is contained in:
@@ -119,6 +119,7 @@ impl core::str::FromStr for Parsed<KlondikePileId> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum SessionInstruction {
|
enum SessionInstruction {
|
||||||
|
New,
|
||||||
Undo,
|
Undo,
|
||||||
Hint,
|
Hint,
|
||||||
Klondike(KlondikeInstruction),
|
Klondike(KlondikeInstruction),
|
||||||
@@ -127,6 +128,7 @@ impl core::str::FromStr for SessionInstruction {
|
|||||||
type Err = Invalid;
|
type Err = Invalid;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
Ok(match s {
|
Ok(match s {
|
||||||
|
"NEW" | "new" => Self::New,
|
||||||
"UNDO" | "undo" => Self::Undo,
|
"UNDO" | "undo" => Self::Undo,
|
||||||
"HINT" | "hint" => Self::Hint,
|
"HINT" | "hint" => Self::Hint,
|
||||||
other => {
|
other => {
|
||||||
@@ -153,6 +155,7 @@ fn main() -> Result<(), std::io::Error> {
|
|||||||
|
|
||||||
// run game
|
// run game
|
||||||
match instruction {
|
match instruction {
|
||||||
|
SessionInstruction::New => session = Session::new(Klondike::new_random_default()),
|
||||||
SessionInstruction::Undo => session.undo(),
|
SessionInstruction::Undo => session.undo(),
|
||||||
SessionInstruction::Hint => {
|
SessionInstruction::Hint => {
|
||||||
for instruction in session.possible_instructions() {
|
for instruction in session.possible_instructions() {
|
||||||
|
|||||||
Reference in New Issue
Block a user