allow king to move to empty tableau

This commit is contained in:
2026-05-15 11:03:57 -07:00
parent dd557d2fcf
commit a1572a3971
+9 -5
View File
@@ -125,14 +125,18 @@ impl KlondikeState {
// other = move to tableau
KlondikeInstruction { src, dst } => {
// get the top cards
if let Some(src_card) = self.pile(src).face_up().last()
&& let Some(dst_card) = self.pile(dst).face_up().last()
if let Some(src_card) = self.pile(src).face_up().last() {
match self.pile(dst).face_up().last() {
// destination card exists
Some(dst_card) => {
// red-ness is opposite?
&& src_card.is_red() != dst_card.is_red()
src_card.is_red() != dst_card.is_red()
// value is -1?
&& dst_card.value().checked_sub(1) == Some(src_card.value())
{
true
}
// only king is allowed to go onto empty tableau
None => src_card.value() == CardValue::KING,
}
} else {
false
}