summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-01-21 19:04:04 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:39 +0100
commit10505553517ee6742014124e79b47b9a552abade (patch)
treefe9b80a0dd9b64e9308d3a748f6696eae132b630 /rules.js
parent0f1429defc3e5ee4b9dd726f17115a1133872752 (diff)
downloadnevsky-10505553517ee6742014124e79b47b9a552abade.tar.gz
Array 3 or fewer attacking lords automatically.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/rules.js b/rules.js
index 85496a0..01bd29e 100644
--- a/rules.js
+++ b/rules.js
@@ -6696,11 +6696,10 @@ function start_battle() {
log_h2(`Battle at %${here}`)
- // TODO: array <= 3 attacking lords automatically
-
init_battle(here, 0, 0)
- for (let lord = first_lord; lord <= last_lord; ++lord) {
+ // All attacking lords to reserve
+ for (let lord = first_friendly_lord; lord <= last_friendly_lord; ++lord) {
if (get_lord_locale(lord) === here && !is_lord_besieged(lord)) {
set_lord_moved(lord, 1)
if (lord !== game.command)
@@ -6708,6 +6707,20 @@ function start_battle() {
}
}
+ // Array attacking lords if fewer than 3.
+ if (game.battle.reserves.length === 2)
+ game.battle.array[A3] = game.battle.reserves.pop()
+ if (game.battle.reserves.length === 1)
+ game.battle.array[A1] = game.battle.reserves.pop()
+
+ // All defending lords to reserve
+ for (let lord = first_enemy_lord; lord <= last_enemy_lord; ++lord) {
+ if (get_lord_locale(lord) === here && !is_lord_besieged(lord)) {
+ set_lord_moved(lord, 1)
+ set_add(game.battle.reserves, lord)
+ }
+ }
+
goto_relief_sally()
}