diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-01-26 17:53:20 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 13:02:39 +0100 |
commit | 4f50d6a4f53d69b627948815b6f042e409f689e7 (patch) | |
tree | 3b1c9af312635f7216361f76d223152732ee29f7 | |
parent | 870052c751ea5c84231eafb8d4a374fb5142ee52 (diff) | |
download | nevsky-4f50d6a4f53d69b627948815b6f042e409f689e7.tar.gz |
Skip Avoid Battle if impossible.
-rw-r--r-- | rules.js | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -1,6 +1,5 @@ "use strict" - // FIXME: lift_sieges / besieged needs checking! (automatic after disband_lord, manual after move/sail, extra careful manual after battle) // FIXME: remove_legate_if_endangered needs checking! (automatic after disband_lord, manual after move/sail, manual after battle) @@ -4862,6 +4861,14 @@ function spoil_loot(lord) { add_spoils(LOOT, 1) } +function can_any_avoid_battle() { + let here = game.march.to + for (let [to, way] of data.locales[here].ways) + if (can_avoid_battle(to, way)) + return true + return false +} + function can_avoid_battle(to, way) { if (way === game.march.approach) return false @@ -4875,10 +4882,15 @@ function can_avoid_battle(to, way) { function goto_avoid_battle() { clear_undo() set_active_enemy() - game.march.group = game.group // save group - game.state = "avoid_battle" - game.spoils = 0 - resume_avoid_battle() + if (can_any_avoid_battle()) { + // TODO: pre-select lone lord? + game.march.group = game.group // save group + game.state = "avoid_battle" + game.spoils = 0 + resume_avoid_battle() + } else { + goto_march_withdraw() + } } function resume_avoid_battle() { |