Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
189da6f408 | ||
|
|
0cbcd1c8d1 |
No files matched your search
+1
-1
@@ -1410,7 +1410,7 @@ async fn main() {
|
||||
if !inp.rdrag && !over_ui && app.game.state == 0 {
|
||||
if inp.ldown.is_some() {
|
||||
inp.ldown = None;
|
||||
} else if app.game.hand.is_empty() && matches!(ui.tool, Tool::Order(_)) {
|
||||
} else if app.game.hand.is_empty() && matches!(ui.tool, Tool::Order(_) | Tool::Flag) {
|
||||
app.game.queue(Act::Unmark { x: wx, y: wy });
|
||||
} else {
|
||||
app.game.queue(Act::Drop { x: wx, y: wy });
|
||||
|
||||
+33
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user