Markers: a second click or tap removes them; right click with the flag tool takes the flag

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-06 12:19:37 +01:00
1 parent c3f7939627
commit 0cbcd1c8d1
2 files changed
+34 -2

No files matched your search

+33 -1
View File
@@ -86,7 +86,9 @@ impl Game {
let (mx, my) = xy(m);
(mx - x).abs() <= 1 && (my - y).abs() <= 1
}) {
return; // there is one already
// a second click (tap) on a marker takes it away again
self.unmark(x as f32 + 0.5, y as f32 + 0.5);
return;
}
if marks.len() >= MAX_MARKS {
self.hint(31, "hint.marks_full");
@@ -128,6 +130,11 @@ impl Game {
}
}
}
} else if let Some(f) = self.flag.filter(|f| near(f)) {
// the rally flag goes the same way
let (fx, fy) = xy(f);
self.set_flag(fx, fy);
return;
} else {
self.cancel_orders();
return;
@@ -329,6 +336,31 @@ mod tests {
assert_eq!(g.ents.iter().filter(|e| matches!(e.job, Job::Guard(_))).count(), 0);
}
#[test]
fn a_second_tap_removes_a_marker_and_right_click_takes_the_flag() {
let mut g = Game::new(14, 64, 64);
let (cx, cy) = g.map.core;
for y in cy - 6..=cy + 8 {
for x in cx - 6..=cx + 10 {
let t = &mut g.map.t[idx(x, y)];
if t.kind != Kind::Core {
t.kind = Kind::Floor;
t.owner = Owner::Player;
}
}
}
g.place_mark(cx + 5, cy + 5, false);
g.place_mark(cx + 7, cy + 2, true);
assert_eq!((g.guard_marks.len(), g.attack_marks.len()), (1, 1));
g.place_mark(cx + 5, cy + 5, false);
g.place_mark(cx + 7, cy + 2, true);
assert_eq!((g.guard_marks.len(), g.attack_marks.len()), (0, 0), "tapped again: gone");
g.set_flag(cx + 4, cy - 3);
assert!(g.flag.is_some());
g.unmark(cx as f32 + 4.5, cy as f32 - 2.5);
assert!(g.flag.is_none(), "the flag goes too");
}
#[test]
fn shields_are_held_and_swords_share_the_creatures() {
let mut g = Game::new(14, 64, 64);