rename PileIds to use human numbers
This commit is contained in:
+10
-10
@@ -11,7 +11,6 @@ impl Default for KlondikeConfig {
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||||
pub enum KlondikePileId {
|
pub enum KlondikePileId {
|
||||||
Tableau0,
|
|
||||||
Tableau1,
|
Tableau1,
|
||||||
Tableau2,
|
Tableau2,
|
||||||
Tableau3,
|
Tableau3,
|
||||||
@@ -19,28 +18,29 @@ pub enum KlondikePileId {
|
|||||||
Tableau5,
|
Tableau5,
|
||||||
Tableau6,
|
Tableau6,
|
||||||
Tableau7,
|
Tableau7,
|
||||||
Foundation0,
|
Tableau8,
|
||||||
Foundation1,
|
Foundation1,
|
||||||
Foundation2,
|
Foundation2,
|
||||||
Foundation3,
|
Foundation3,
|
||||||
|
Foundation4,
|
||||||
Stock,
|
Stock,
|
||||||
}
|
}
|
||||||
impl KlondikePileId {
|
impl KlondikePileId {
|
||||||
fn next(self) -> Option<Self> {
|
fn next(self) -> Option<Self> {
|
||||||
use KlondikePileId::*;
|
use KlondikePileId::*;
|
||||||
Some(match self {
|
Some(match self {
|
||||||
Tableau0 => Tableau1,
|
|
||||||
Tableau1 => Tableau2,
|
Tableau1 => Tableau2,
|
||||||
Tableau2 => Tableau3,
|
Tableau2 => Tableau3,
|
||||||
Tableau3 => Tableau4,
|
Tableau3 => Tableau4,
|
||||||
Tableau4 => Tableau5,
|
Tableau4 => Tableau5,
|
||||||
Tableau5 => Tableau6,
|
Tableau5 => Tableau6,
|
||||||
Tableau6 => Tableau7,
|
Tableau6 => Tableau7,
|
||||||
Tableau7 => Foundation0,
|
Tableau7 => Tableau8,
|
||||||
Foundation0 => Foundation1,
|
Tableau8 => Foundation1,
|
||||||
Foundation1 => Foundation2,
|
Foundation1 => Foundation2,
|
||||||
Foundation2 => Foundation3,
|
Foundation2 => Foundation3,
|
||||||
Foundation3 => Stock,
|
Foundation3 => Foundation4,
|
||||||
|
Foundation4 => Stock,
|
||||||
Stock => return None,
|
Stock => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -99,10 +99,10 @@ impl KlondikeState {
|
|||||||
KlondikeInstruction { src, dst }
|
KlondikeInstruction { src, dst }
|
||||||
if matches!(
|
if matches!(
|
||||||
dst,
|
dst,
|
||||||
KlondikePileId::Foundation0
|
KlondikePileId::Foundation1
|
||||||
| KlondikePileId::Foundation1
|
|
||||||
| KlondikePileId::Foundation2
|
| KlondikePileId::Foundation2
|
||||||
| KlondikePileId::Foundation3
|
| KlondikePileId::Foundation3
|
||||||
|
| KlondikePileId::Foundation4
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
// get the top cards
|
// get the top cards
|
||||||
@@ -152,8 +152,8 @@ impl KlondikeIter {
|
|||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
instruction: Some(KlondikeInstruction {
|
instruction: Some(KlondikeInstruction {
|
||||||
src: KlondikePileId::Tableau0,
|
src: KlondikePileId::Tableau1,
|
||||||
dst: KlondikePileId::Tableau1,
|
dst: KlondikePileId::Tableau2,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -50,15 +50,14 @@ impl Display for Klondike {
|
|||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"Foundations: {} {} {} {}",
|
"Foundations: {} {} {} {}",
|
||||||
OptionalCard(self.pile(KlondikePileId::Foundation0).face_up().last()),
|
|
||||||
OptionalCard(self.pile(KlondikePileId::Foundation1).face_up().last()),
|
OptionalCard(self.pile(KlondikePileId::Foundation1).face_up().last()),
|
||||||
OptionalCard(self.pile(KlondikePileId::Foundation2).face_up().last()),
|
OptionalCard(self.pile(KlondikePileId::Foundation2).face_up().last()),
|
||||||
OptionalCard(self.pile(KlondikePileId::Foundation3).face_up().last())
|
OptionalCard(self.pile(KlondikePileId::Foundation3).face_up().last()),
|
||||||
|
OptionalCard(self.pile(KlondikePileId::Foundation4).face_up().last()),
|
||||||
)?;
|
)?;
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
|
|
||||||
for (i, tableau) in [
|
for (i, tableau) in [
|
||||||
KlondikePileId::Tableau0,
|
|
||||||
KlondikePileId::Tableau1,
|
KlondikePileId::Tableau1,
|
||||||
KlondikePileId::Tableau2,
|
KlondikePileId::Tableau2,
|
||||||
KlondikePileId::Tableau3,
|
KlondikePileId::Tableau3,
|
||||||
@@ -66,6 +65,7 @@ impl Display for Klondike {
|
|||||||
KlondikePileId::Tableau5,
|
KlondikePileId::Tableau5,
|
||||||
KlondikePileId::Tableau6,
|
KlondikePileId::Tableau6,
|
||||||
KlondikePileId::Tableau7,
|
KlondikePileId::Tableau7,
|
||||||
|
KlondikePileId::Tableau8,
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
@@ -101,7 +101,6 @@ impl core::str::FromStr for Parsed<KlondikePileId> {
|
|||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
Ok(Parsed(match s {
|
Ok(Parsed(match s {
|
||||||
"ST" | "st" => KlondikePileId::Stock,
|
"ST" | "st" => KlondikePileId::Stock,
|
||||||
"T0" | "t0" => KlondikePileId::Tableau0,
|
|
||||||
"T1" | "t1" => KlondikePileId::Tableau1,
|
"T1" | "t1" => KlondikePileId::Tableau1,
|
||||||
"T2" | "t2" => KlondikePileId::Tableau2,
|
"T2" | "t2" => KlondikePileId::Tableau2,
|
||||||
"T3" | "t3" => KlondikePileId::Tableau3,
|
"T3" | "t3" => KlondikePileId::Tableau3,
|
||||||
@@ -109,10 +108,11 @@ impl core::str::FromStr for Parsed<KlondikePileId> {
|
|||||||
"T5" | "t5" => KlondikePileId::Tableau5,
|
"T5" | "t5" => KlondikePileId::Tableau5,
|
||||||
"T6" | "t6" => KlondikePileId::Tableau6,
|
"T6" | "t6" => KlondikePileId::Tableau6,
|
||||||
"T7" | "t7" => KlondikePileId::Tableau7,
|
"T7" | "t7" => KlondikePileId::Tableau7,
|
||||||
"F0" | "f0" => KlondikePileId::Foundation0,
|
"T8" | "t8" => KlondikePileId::Tableau8,
|
||||||
"F1" | "f1" => KlondikePileId::Foundation1,
|
"F1" | "f1" => KlondikePileId::Foundation1,
|
||||||
"F2" | "f2" => KlondikePileId::Foundation2,
|
"F2" | "f2" => KlondikePileId::Foundation2,
|
||||||
"F3" | "f3" => KlondikePileId::Foundation3,
|
"F3" | "f3" => KlondikePileId::Foundation3,
|
||||||
|
"F4" | "f4" => KlondikePileId::Foundation4,
|
||||||
_ => return Err(Invalid),
|
_ => return Err(Invalid),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user