Compare commits

..

3 Commits

Author SHA1 Message Date
LeRoyce Pearson 17988b97f7 fix: re-implement selecting specific cards from stacks
/ build-dist (push) Failing after 33s Details
2024-07-25 23:11:24 -06:00
LeRoyce Pearson 1189682bfa deselect cards when placing cards fails 2024-07-25 22:52:53 -06:00
LeRoyce Pearson 42c18ebdfc update to zig 0.13.0 2024-07-25 22:44:21 -06:00
4 changed files with 21 additions and 6 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
zig-out/
zig-cache/
.zig-cache/

View File

@ -44,7 +44,7 @@ pub fn addSeizerSolitaireExe(b: *std.Build, install_step: *std.Build.Step, optio
const exe = b.addExecutable(.{
.name = "seizer-solitaire",
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = options.target,
.optimize = options.optimize,
});

View File

@ -16,8 +16,8 @@
// internet connectivity.
.dependencies = .{
.seizer = .{
.url = "https://github.com/leroycep/seizer/archive/54a39bf2c2f867a2caa69c4a63fa4732ebc7ac71.tar.gz",
.hash = "12208d8ee636719b6b4fbb75014cfaa9aa0d9557d2ca4e160ad245825eaa20849b48",
.url = "https://github.com/leroycep/seizer/archive/e065ae24f5ae4be546c6f1eb170677b0ac835452.tar.gz",
.hash = "12200e611cb9ea7aa15b43cc52a6ff31aa8dbcf33a360c858ea237a6df102ee8da6d",
},
},
.paths = .{

View File

@ -582,6 +582,8 @@ pub fn doSelectOrPlace(pressed: bool) !void {
new_snapshot.selected_card = null;
try history.append(seizer.platform.allocator(), new_snapshot);
hovered_card = @intCast(indexOfTopOfStack(new_snapshot.getDeck(hovered_deck.?)));
} else {
snapshot.selected_card = null;
}
}
}
@ -653,9 +655,16 @@ pub fn moveUp(pressed: bool) !void {
return try menu_fn(.up);
}
// move which pile is hovered
// move which card/pile is hovered
const snapshot = &history.items[history.items.len - 1];
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);
} else {
hovered_deck = .draw_pile;
@ -682,9 +691,15 @@ pub fn moveDown(pressed: bool) !void {
return try menu_fn(.down);
}
// move which pile is hovered
// move which card/pile is hovered
const snapshot = &history.items[history.items.len - 1];
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);
} else {
hovered_deck = .draw_pile;