Added Foundation to Pile movement
And made it make a bit more sense wrt Pile to Foundation
This commit is contained in:
@@ -269,7 +269,10 @@ fn handle_move_highlighted(current_position: &CardPosition, direction: Direction
|
|||||||
match direction {
|
match direction {
|
||||||
Direction::Up | Direction::Left => { CardPosition::TopWaste },
|
Direction::Up | Direction::Left => { CardPosition::TopWaste },
|
||||||
Direction::Right => { CardPosition::Foundation(0) }
|
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) => {
|
CardPosition::Pile(p, i) => {
|
||||||
@@ -284,7 +287,14 @@ fn handle_move_highlighted(current_position: &CardPosition, direction: Direction
|
|||||||
Direction::Up => {
|
Direction::Up => {
|
||||||
let lowest_shown_card = cards.clone().lowest_visible_card_in_pile_from_index(*p, 0);
|
let lowest_shown_card = cards.clone().lowest_visible_card_in_pile_from_index(*p, 0);
|
||||||
if *i == lowest_shown_card {
|
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 {
|
} else {
|
||||||
CardPosition::Pile(*p, *i - 1)
|
CardPosition::Pile(*p, *i - 1)
|
||||||
}
|
}
|
||||||
@@ -329,21 +339,21 @@ fn handle_move_highlighted(current_position: &CardPosition, direction: Direction
|
|||||||
Direction::Down => {
|
Direction::Down => {
|
||||||
match f {
|
match f {
|
||||||
0 => {
|
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);
|
let i = cards.clone().lowest_visible_card_in_pile_from_index(3, 0);
|
||||||
CardPosition::Pile(3, i)
|
CardPosition::Pile(3, i)
|
||||||
},
|
},
|
||||||
2 => {
|
1 => {
|
||||||
let i = cards.clone().lowest_visible_card_in_pile_from_index(4, 0);
|
let i = cards.clone().lowest_visible_card_in_pile_from_index(4, 0);
|
||||||
CardPosition::Pile(4, i)
|
CardPosition::Pile(4, i)
|
||||||
},
|
},
|
||||||
3 => {
|
2 => {
|
||||||
let i = cards.clone().lowest_visible_card_in_pile_from_index(5, 0);
|
let i = cards.clone().lowest_visible_card_in_pile_from_index(5, 0);
|
||||||
CardPosition::Pile(5, i)
|
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")
|
_ => panic!("Can't be on a foundation this high")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user