Compare commits
3 Commits
2510ba3eb6
...
17988b97f7
Author | SHA1 | Date |
---|---|---|
LeRoyce Pearson | 17988b97f7 | |
LeRoyce Pearson | 1189682bfa | |
LeRoyce Pearson | 42c18ebdfc |
|
@ -1,2 +1,2 @@
|
||||||
zig-out/
|
zig-out/
|
||||||
zig-cache/
|
.zig-cache/
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub fn addSeizerSolitaireExe(b: *std.Build, install_step: *std.Build.Step, optio
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "seizer-solitaire",
|
.name = "seizer-solitaire",
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = options.target,
|
.target = options.target,
|
||||||
.optimize = options.optimize,
|
.optimize = options.optimize,
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
// internet connectivity.
|
// internet connectivity.
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.seizer = .{
|
.seizer = .{
|
||||||
.url = "https://github.com/leroycep/seizer/archive/54a39bf2c2f867a2caa69c4a63fa4732ebc7ac71.tar.gz",
|
.url = "https://github.com/leroycep/seizer/archive/e065ae24f5ae4be546c6f1eb170677b0ac835452.tar.gz",
|
||||||
.hash = "12208d8ee636719b6b4fbb75014cfaa9aa0d9557d2ca4e160ad245825eaa20849b48",
|
.hash = "12200e611cb9ea7aa15b43cc52a6ff31aa8dbcf33a360c858ea237a6df102ee8da6d",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
|
19
src/main.zig
19
src/main.zig
|
@ -582,6 +582,8 @@ pub fn doSelectOrPlace(pressed: bool) !void {
|
||||||
new_snapshot.selected_card = null;
|
new_snapshot.selected_card = null;
|
||||||
try history.append(seizer.platform.allocator(), new_snapshot);
|
try history.append(seizer.platform.allocator(), new_snapshot);
|
||||||
hovered_card = @intCast(indexOfTopOfStack(new_snapshot.getDeck(hovered_deck.?)));
|
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);
|
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;
|
||||||
|
@ -682,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;
|
||||||
|
|
Loading…
Reference in New Issue