summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
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) {