From 19c0a7a39a01b3803a391b46cdf64548eae6b8ca Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 13 Sep 2022 18:34:49 +0200 Subject: Don't release hex control immediately after forced march regroups. --- rules.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/rules.js b/rules.js index 29444d2..b5aa38e 100644 --- a/rules.js +++ b/rules.js @@ -739,6 +739,7 @@ function release_hex_control(a) { set_delete(game.allied_sides, side) } }) + hide_units_in_hex(a) } function claim_hex_control_for_defender(a) { @@ -4221,10 +4222,14 @@ states.retreat_move = { } function end_retreat() { - if (!is_battle_hex(game.retreat)) { - release_hex_control(game.retreat) - hide_units_in_hex(game.retreat) + if ((game.to1 || game.to2) && game.forced.length > 0) { + // Don't release in case a forced march regroup teleports units back into battle. + // Wait until goto_combat_phase to release these hexes. + } else { + if (!is_battle_hex(game.retreat)) + release_hex_control(game.retreat) } + game.retreat_units = null // mark shielding units as moved @@ -4489,7 +4494,6 @@ function end_rout() { log_br() game.state = game.rout.state release_hex_control(game.rout.from) - hide_units_in_hex(game.rout.from) set_delete(game.new_battles, game.rout.from) @@ -4513,9 +4517,19 @@ function is_mandatory_combat(fortress) { return false } +function release_retreat_hex_control() { + for (let x of all_hexes) + if (!is_battle_hex(x)) + if (set_has(game.axis_hexes, x) || set_has(game.allied_hexes, x)) + release_hex_control(x) +} + function goto_combat_phase() { set_active_player() + // Release hexes that were retreated from here + release_retreat_hex_control() + reveal_visited_minefields() if (game.turn_option === 'pass') { @@ -4764,10 +4778,8 @@ function goto_battle(x) { } function end_battle() { - if (!is_battle_hex(game.battle)) { + if (!is_battle_hex(game.battle)) release_hex_control(game.battle) - hide_units_in_hex(game.battle) - } set_delete(game.new_battles, game.battle) set_delete(game.active_battles, game.battle) -- cgit v1.2.3