diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-09-18 11:29:34 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:27 +0100 |
commit | b8d1038fa3b37b481f5b63bd24bdda2d45cb78b7 (patch) | |
tree | 1b236dce9642b847deb272be7f3c483ac7d901f0 /rules.js | |
parent | 7c10b2e9dd5d3af198635bb5cbd3f119a1730486 (diff) | |
download | rommel-in-the-desert-b8d1038fa3b37b481f5b63bd24bdda2d45cb78b7.tar.gz |
Don't pursuit fire from retreat if all are slower.
During retreats from battle hexes, enemy units are all revealed.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -5250,6 +5250,16 @@ function fastest_undisrupted_friendly_unit(where) { return who } +function fastest_undisrupted_friendly_unit_speed(where) { + let r = 0 + for_each_undisrupted_friendly_unit_in_hex(where, u => { + let s = unit_speed[u] + if (s > r) + r = s + }) + return r +} + function goto_rout_fire(where) { set_enemy_player() game.hits = 0 @@ -5263,9 +5273,17 @@ function goto_pursuit_fire_during_retreat(where) { set_passive_player() game.hits = 0 game.pursuit = where + let slowest = slowest_undisrupted_enemy_unit_speed(game.pursuit) + let fastest = fastest_undisrupted_friendly_unit_speed(game.pursuit) + log(`Slowest was ${speed_name[slowest]} unit.`) - game.state = 'pursuit_fire' + if (slowest <= fastest) { + game.state = 'pursuit_fire' + } else { + // too fast for pursuit fire, and we already know all the units involved + end_pursuit_fire() + } } function goto_pursuit_fire_during_refuse_battle(where) { |