allow king to move to empty tableau
This commit is contained in:
+12
-8
@@ -125,14 +125,18 @@ impl KlondikeState {
|
|||||||
// other = move to tableau
|
// other = move to tableau
|
||||||
KlondikeInstruction { src, dst } => {
|
KlondikeInstruction { src, dst } => {
|
||||||
// get the top cards
|
// get the top cards
|
||||||
if let Some(src_card) = self.pile(src).face_up().last()
|
if let Some(src_card) = self.pile(src).face_up().last() {
|
||||||
&& let Some(dst_card) = self.pile(dst).face_up().last()
|
match self.pile(dst).face_up().last() {
|
||||||
// red-ness is opposite?
|
// destination card exists
|
||||||
&& src_card.is_red() != dst_card.is_red()
|
Some(dst_card) => {
|
||||||
// value is -1?
|
// red-ness is opposite?
|
||||||
&& dst_card.value().checked_sub(1) == Some(src_card.value())
|
src_card.is_red() != dst_card.is_red()
|
||||||
{
|
// value is -1?
|
||||||
true
|
&& dst_card.value().checked_sub(1) == Some(src_card.value())
|
||||||
|
}
|
||||||
|
// only king is allowed to go onto empty tableau
|
||||||
|
None => src_card.value() == CardValue::KING,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user