fix: re-implement selecting specific cards from stacks
/ build-dist (push) Failing after 33s Details

dev
LeRoyce Pearson 2024-07-25 23:11:24 -06:00
parent 1189682bfa
commit 17988b97f7
1 changed files with 15 additions and 2 deletions

View File

@ -655,9 +655,16 @@ pub fn moveUp(pressed: bool) !void {
return try menu_fn(.up); return try menu_fn(.up);
} }
// move which pile is hovered // move which card/pile is hovered
const snapshot = &history.items[history.items.len - 1]; const snapshot = &history.items[history.items.len - 1];
if (hovered_deck) |hovered| { if (hovered_deck) |hovered| {
if (hovered_card != null and hovered.getDeckKind() == .stack) {
const top_of_movable_stack = indexOfTopOfStack(snapshot.getDeck(hovered));
if (hovered_card.? > top_of_movable_stack) {
hovered_card = hovered_card.? - 1;
return;
}
}
hovered_deck = hovered.getDeckUpwards(last_hovered_stack); hovered_deck = hovered.getDeckUpwards(last_hovered_stack);
} else { } else {
hovered_deck = .draw_pile; hovered_deck = .draw_pile;
@ -684,9 +691,15 @@ pub fn moveDown(pressed: bool) !void {
return try menu_fn(.down); return try menu_fn(.down);
} }
// move which pile is hovered // move which card/pile is hovered
const snapshot = &history.items[history.items.len - 1]; const snapshot = &history.items[history.items.len - 1];
if (hovered_deck) |hovered| { if (hovered_deck) |hovered| {
if (hovered_card != null and hovered.getDeckKind() == .stack) {
if (hovered_card.? + 1 < snapshot.deck_card_count[@intFromEnum(hovered)]) {
hovered_card = hovered_card.? + 1;
return;
}
}
hovered_deck = hovered.getDeckDownwards(last_hovered_stack); hovered_deck = hovered.getDeckDownwards(last_hovered_stack);
} else { } else {
hovered_deck = .draw_pile; hovered_deck = .draw_pile;