diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-07-27 19:12:49 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:26 +0100 |
commit | 736097bab6ce3d9b59f791b8dad0d7cd98c9d584 (patch) | |
tree | 21726d000750bd818b80ddbf4b385fa9ba2418ac /play.js | |
parent | 330d6dfb5382f4b3b338d88b8a08d4f776f5ee36 (diff) | |
download | rommel-in-the-desert-736097bab6ce3d9b59f791b8dad0d7cd98c9d584.tar.gz |
Forced march.
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -173,6 +173,10 @@ function is_hex_action(hex) { return !!(view.actions && view.actions.hex && view.actions.hex.includes(hex)) } +function is_hex_forced_march_action(hex) { + return !!(view.actions && view.actions.forced_march && view.actions.forced_march.includes(hex)) +} + function is_hex_axis_supply(hex) { return view.axis_supply[hex] > 0 } @@ -232,6 +236,8 @@ function on_click_hex(evt) { hide_supply() if (send_action('hex', evt.target.hex)) evt.stopPropagation() + if (send_action('forced_march', evt.target.hex)) + evt.stopPropagation() } } @@ -373,13 +379,18 @@ function build_hexes() { } function add_hex(x, y) { + let sm_hex_w = hex_w - 8 + let sm_hex_h = sm_hex_w / sqrt(3) * 2 + let ww = sm_hex_w / 2 + let aa = sm_hex_h / 2 + let bb = sm_hex_h / 4 return [ - [ round(x), round(y-a) ], - [ round(x+w), round(y-b) ], - [ round(x+w), round(y+b) ], - [ round(x), round(y+a) ], - [ round(x-w), round(y+b) ], - [ round(x-w), round(y-b) ] + [ round(x), round(y-aa) ], + [ round(x+ww), round(y-bb) ], + [ round(x+ww), round(y+bb) ], + [ round(x), round(y+aa) ], + [ round(x-ww), round(y+bb) ], + [ round(x-ww), round(y-bb) ] ].join(" ") } @@ -519,7 +530,8 @@ function update_map() { } if (ui.hexes[hex]) { - ui.hexes[hex].classList.toggle("action", is_hex_action(hex)) + ui.hexes[hex].classList.toggle("action", is_hex_action(hex) || is_hex_forced_march_action(hex)) + ui.hexes[hex].classList.toggle("forced_march", is_hex_forced_march_action(hex)) ui.hexes[hex].classList.toggle("from", hex === view.from1 || hex === view.from2) ui.hexes[hex].classList.toggle("to", hex === view.to1 || hex === view.to2) ui.hexes[hex].classList.toggle("axis_control", is_hex_axis_controlled(hex)) |