diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-09-24 23:49:16 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-01 16:11:22 +0200 |
commit | 8df1c18e7594de3fede403361b83cfc0437f366c (patch) | |
tree | c49d496e93f4812bc6c9123e7dd7c407d8dc57f8 /rules.js | |
parent | 0db892146a5f1899e0091409818f9f80b769ee78 (diff) | |
download | waterloo-campaign-1815-8df1c18e7594de3fede403361b83cfc0437f366c.tar.gz |
Disallow passing if reinforcements can still enter.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -1215,6 +1215,8 @@ function end_movement() { states.movement = { prompt() { + let may_pass = 1 + prompt("Movement.") update_zoc() @@ -1263,8 +1265,12 @@ states.movement = { for (let p of info.list) { if (piece_hex(p) === REINFORCEMENTS) { has_reinf = true - gen_action_piece(p) - break + if (can_piece_enter(p)) { + if (game.remain > 0) + may_pass = 0 + gen_action_piece(p) + break + } } } } @@ -1279,7 +1285,7 @@ states.movement = { gen_action_piece(p) } - view.actions.pass = 1 + view.actions.pass = may_pass }, piece(p) { push_undo() @@ -1521,6 +1527,19 @@ function search_detachment_road_segment(queue, here, road, cur, dir) { queue.push(here) } +function can_piece_enter(p) { + let xs = find_reinforcement_hex(p) + if (typeof xs === "number") { + if (!hex_has_any_piece(xs, all_corps)) + return true + } else { + for (let x of xs) + if (!hex_has_any_piece(x, all_corps)) + return true + } + return false +} + function search_move(p) { move_seen.fill(0) move_flip.fill(1) |