diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-07-27 16:42:56 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:26 +0100 |
commit | 803a82364b56a60b3e8cd2cb5f84eb27eb290255 (patch) | |
tree | 9ab98f4e46622ca60414e20fdcdd9defc3135fc5 | |
parent | b4d3f46b6e0497af9836dfd00a0918bc0f95a5db (diff) | |
download | rommel-in-the-desert-803a82364b56a60b3e8cd2cb5f84eb27eb290255.tar.gz |
Cleans.
-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) } } |