From d93ae767fd030a6e2f90adab2ff5c3b183782cd6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 3 Sep 2022 17:35:28 +0200 Subject: Don't highlight pass turn group non-retreat moves with disrupted units. --- rules.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/rules.js b/rules.js index bbcd15b..943ae98 100644 --- a/rules.js +++ b/rules.js @@ -680,6 +680,12 @@ function has_undisrupted_friendly_unit(x) { return has_undisrupted_allied_unit(x) } +function has_disrupted_friendly_unit(x) { + if (game.active === AXIS) + return has_disrupted_axis_unit(x) + return has_disrupted_allied_unit(x) +} + function has_enemy_unit(x) { if (game.active === ALLIED) return has_axis_unit(x) @@ -2045,7 +2051,7 @@ function is_valid_withdrawal_group_move_from(x) { return can_all_undisrupted_units_disengage_and_withdraw(x) } else { // non-retreat withdrawal, check if network is reduced after we leave this hex - if (can_all_undisrupted_units_withdraw(x)) { + if (!has_disrupted_friendly_unit(x) && can_all_undisrupted_units_withdraw(x)) { // All units in hex have the same supply source let src = hex_supply_source(x) let net = hex_supply_network(x) @@ -3051,9 +3057,12 @@ states.group_move_from = { mandatory = true } if (!mandatory) { - for (let x of all_hexes) - if (has_undisrupted_friendly_unit(x) && is_valid_withdrawal_group_move_from(x)) - gen_action_hex(x) + for (let x of all_hexes) { + if (has_undisrupted_friendly_unit(x)) { + if (is_valid_withdrawal_group_move_from(x)) + gen_action_hex(x) + } + } } } }, @@ -5208,13 +5217,13 @@ function roll_pursuit_fire_imp(who, n, hp) { } if (n === 1) { let a = roll_die() - game.flash = `${speed_name_cap[speed]} fired ${a}.` if (a >= 4) { game.hits++ a = die_face_hit[a] } else { a = die_face_miss[a] } + game.flash = `${speed_name_cap[speed]} fired ${a}.` } log(game.flash) if (game.hits > hp) @@ -5440,12 +5449,15 @@ function end_buildup_supply_check() { } function goto_buildup_supply_check_recover() { + let summary = [] for_each_friendly_unit_on_map(u => { if (is_unit_supplied(u) && is_unit_disrupted(u) && !is_battle_hex(unit_hex(u))) { - log(`Recovered at #${unit_hex(u)}.`) + set_add(summary, unit_hex(u)) clear_unit_disrupted(u) } }) + for (let x of summary) + log(`Recovered at #${x}.`) resume_buildup_eliminate_unsupplied() } -- cgit v1.2.3