Added Foundation to Pile movement

And made it make a bit more sense wrt Pile to Foundation
This commit is contained in:
2025-06-28 00:30:35 +01:00
parent 16be88c703
commit 9f1eac75a0

View File

@@ -269,7 +269,10 @@ fn handle_move_highlighted(current_position: &CardPosition, direction: Direction
match direction {
Direction::Up | Direction::Left => { CardPosition::TopWaste },
Direction::Right => { CardPosition::Foundation(0) }
Direction::Down => { CardPosition:: Pile(0, 0) }
Direction::Down => {
let lowest_shown_card = cards.clone().lowest_visible_card_in_pile_from_index(1, 0);
CardPosition:: Pile(1, lowest_shown_card)
}
}
},
CardPosition::Pile(p, i) => {
@@ -284,7 +287,14 @@ fn handle_move_highlighted(current_position: &CardPosition, direction: Direction
Direction::Up => {
let lowest_shown_card = cards.clone().lowest_visible_card_in_pile_from_index(*p, 0);
if *i == lowest_shown_card {
CardPosition::TopWaste // FIXME - should move to the appropriate Waste or Foundation
match *p {
0 | 1 => CardPosition::TopWaste,
2 | 3 => CardPosition::Foundation(0),
4 => CardPosition::Foundation(1),
5 => CardPosition::Foundation(2),
6 => CardPosition::Foundation(3),
_ => panic!("Should be on Pile over 6")
}
} else {
CardPosition::Pile(*p, *i - 1)
}
@@ -329,21 +339,21 @@ fn handle_move_highlighted(current_position: &CardPosition, direction: Direction
Direction::Down => {
match f {
0 => {
let i = cards.clone().lowest_visible_card_in_pile_from_index(2, 0);
CardPosition::Pile(2, i)
},
1 => {
let i = cards.clone().lowest_visible_card_in_pile_from_index(3, 0);
CardPosition::Pile(3, i)
},
2 => {
1 => {
let i = cards.clone().lowest_visible_card_in_pile_from_index(4, 0);
CardPosition::Pile(4, i)
},
3 => {
2 => {
let i = cards.clone().lowest_visible_card_in_pile_from_index(5, 0);
CardPosition::Pile(5, i)
},
3 => {
let i = cards.clone().lowest_visible_card_in_pile_from_index(6, 0);
CardPosition::Pile(6, i)
},
_ => panic!("Can't be on a foundation this high")
}
}