summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-09-27 18:47:45 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:27 +0100
commit8f432713888b89e8c37a635a312fc97e29268637 (patch)
treec0c9016ba87644fdec680a47501f25bafa6a46d8
parentce8910eee718fbba261ba142e45b325db3411283 (diff)
downloadrommel-in-the-desert-8f432713888b89e8c37a635a312fc97e29268637.tar.gz
Skip pursuit fire during rout if possible.
-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)