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 6d53263..a712237 100644
--- a/rules.js
+++ b/rules.js
@@ -5252,19 +5252,37 @@ function fastest_undisrupted_friendly_unit_speed(where) {
return r
}
+function has_hidden_friendly_unit(x) {
+ for (let u = first_friendly_unit; u <= last_friendly_unit; ++u)
+ if (unit_hex(u) === x && !set_has(game.revealed, u))
+ return true
+ return false
+}
+
function goto_rout_fire(where) {
set_enemy_player()
game.hits = 0
game.pursuit = where
+ game.flash = ""
+
let slowest = slowest_enemy_unit_speed(game.pursuit)
+ let fastest = fastest_undisrupted_friendly_unit_speed(game.pursuit)
+
log(`Slowest was ${speed_name[slowest]} unit.`)
- game.state = 'rout_fire'
+ if (slowest <= fastest || has_hidden_friendly_unit(game.pursuit)) {
+ game.state = 'rout_fire'
+ } else {
+ // too fast for pursuit fire, and we already know all the units involved
+ set_enemy_player()
+ end_rout_fire()
+ }
}
function goto_pursuit_fire_during_retreat(where) {
set_passive_player()
game.hits = 0
game.pursuit = where
+ game.flash = ""
let slowest = slowest_undisrupted_enemy_unit_speed(game.pursuit)
let fastest = fastest_undisrupted_friendly_unit_speed(game.pursuit)