diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-09-29 22:44:08 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-01 16:11:22 +0200 |
commit | cbb859a1593d565543f2d4a0203cb223e1e29656 (patch) | |
tree | c1893a1b94330b410ad7ecc3af07996e1e1c0fae | |
parent | 0da3cc2279295813214950eed623fd188db9067f (diff) | |
download | waterloo-campaign-1815-cbb859a1593d565543f2d4a0203cb223e1e29656.tar.gz |
Show supporting units.
-rw-r--r-- | play.js | 9 | ||||
-rw-r--r-- | rules.js | 2 |
2 files changed, 10 insertions, 1 deletions
@@ -263,6 +263,12 @@ function is_action(action, arg) { return !!(view.actions && view.actions[action] && set_has(view.actions[action], arg)) } +function is_piece_support(id) { + if (view.support) + return view.support & (1 << id) + return false +} + function find_hex_side(a, b) { if (a > b) return find_hex_side(b, a) @@ -392,6 +398,7 @@ function on_update() { ui.pieces[id].classList.toggle("action", is_action("piece", id)) ui.pieces[id].classList.toggle("selected", view.who === id) ui.pieces[id].classList.toggle("target", view.target === id) + ui.pieces[id].classList.toggle("support", is_piece_support(id)) } if (view.roads) { @@ -500,7 +507,7 @@ function sub_hex(match, p1) { let x = p1 | 0 let n = data.map.names[x] if (n) - n = x + " (" + n + ")" + n = x + " " + n else n = x return `<span class="tip" onmouseenter="on_focus_hex_tip(${x})" onmouseleave="on_blur_hex_tip(${x})" onclick="on_click_hex_tip(${x})">${n}</span>` @@ -1941,6 +1941,7 @@ function goto_defend_support() { states.attack_support = { inactive: "attack", prompt() { + view.support = game.count if (data.map.names[game.attack]) prompt("Attack " + piece_name(game.target) + " at " + data.map.names[game.attack] + @@ -1983,6 +1984,7 @@ states.attack_support = { states.defend_support = { inactive: "commit cavalry", prompt() { + view.support = game.count if (data.map.names[game.attack]) prompt(piece_name(game.who) + " attacks " + piece_name(game.target) + |