summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-09-18 11:29:34 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:27 +0100
commitb8d1038fa3b37b481f5b63bd24bdda2d45cb78b7 (patch)
tree1b236dce9642b847deb272be7f3c483ac7d901f0 /rules.js
parent7c10b2e9dd5d3af198635bb5cbd3f119a1730486 (diff)
downloadrommel-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.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index f0717fb..3a9dcb9 100644
--- a/rules.js
+++ b/rules.js
@@ -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) {