diff options
-rw-r--r-- | rules.js | 24 |
1 files changed, 4 insertions, 20 deletions
@@ -708,17 +708,11 @@ function for_each_undisrupted_and_unmoved_friendly_unit_in_hex(x, fn) { fn(u) } -function has_undisrupted_and_moved_friendly_unit_in_hex(x) { +function hex_or_adjacent_has_undisrupted_and_unmoved_friendly_unit(here) { for (let u = first_friendly_unit; u <= last_friendly_unit; ++u) - if (!is_unit_disrupted(u) && unit_hex(u) === x && is_unit_moved(u)) + if (!is_unit_disrupted(u) && !is_unit_moved(u) && is_hex_or_adjacent_to(unit_hex(u), here)) return true -} - - -function for_each_undisrupted_friendly_unit_in_hex_or_adjacent(x, fn) { - for (let u = first_friendly_unit; u <= last_friendly_unit; ++u) - if (!is_unit_disrupted(u) && is_hex_or_adjacent_to(unit_hex(u), x)) - fn(u) + return false } function for_each_enemy_unit_in_hex(x, fn) { @@ -1335,16 +1329,6 @@ function pick_path(to, speed) { return next_road } -function adjacent_hex_has_undisrupted_friendly_unit(here) { - for (let s = 0; s < 6; ++s) { - let next = here + hexnext[s] - if (is_map_hex(next)) - if (has_undisrupted_friendly_unit(next)) - return true - } - return false -} - function max_speed_of_undisrupted_and_unmoved_friendly_unit_in_hex(from) { let max_speed = 0 for_each_undisrupted_and_unmoved_friendly_unit_in_hex(from, u => { @@ -1683,7 +1667,7 @@ states.regroup_move_command_point = { gen_rommel_move() for (let x = first_hex; x <= last_hex; ++x) { if (!is_enemy_hex(x)) { - if (has_undisrupted_friendly_unit(x) || adjacent_hex_has_undisrupted_friendly_unit(x)) + if (hex_or_adjacent_has_undisrupted_and_unmoved_friendly_unit(x)) gen_action_hex(x) } } |