summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-06 15:25:58 +0200
committerTor Andersson <tor@ccxvii.net>2023-12-10 18:16:55 +0100
commit885a161740b483bad04abd98d380c05d253d96d6 (patch)
tree7535560b022c331a46d3ef78d493df126ddd3ca4 /rules.js
parentade99ca6bb86bd1494f1de1f6b5813aa5080a935 (diff)
downloadplantagenet-885a161740b483bad04abd98d380c05d253d96d6.tar.gz
game.battle.routed_vassals is a always set
No need to check if it is 0.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js12
1 files changed, 4 insertions, 8 deletions
diff --git a/rules.js b/rules.js
index 335a740..b6ed8ac 100644
--- a/rules.js
+++ b/rules.js
@@ -756,7 +756,7 @@ function lord_has_unrouted_units(lord) {
return true
let result = false
for_each_vassal_with_lord(lord, v => {
- if (game.battle.routed_vassals[lord] === 0 || !game.battle.routed_vassals[lord].includes(v))
+ if (!set_has(game.battle.routed_vassals[lord], v))
result = true
})
return result
@@ -764,15 +764,11 @@ function lord_has_unrouted_units(lord) {
function lord_has_routed_units(lord) {
return (
- game.pieces.routed[lord] !== 0 ||
- (game.battle.routed_vassals[lord] !== 0 && game.battle.routed_vassals[lord].length > 0)
+ game.pieces.routed[lord] !== 0 || game.battle.routed_vassals[lord].length > 0
)
}
function rout_vassal(lord, vassal) {
- if (game.battle.routed_vassals[lord] === 0)
- game.battle.routed_vassals[lord] = []
-
set_add(game.battle.routed_vassals[lord], vassal)
}
@@ -5564,7 +5560,7 @@ function prompt_hit_forces() {
gen_action_militia(lord)
for_each_vassal_with_lord(lord, v => {
- if (!game.battle.routed_vassals[lord].includes(v))
+ if (!set_has(game.battle.routed_vassals[lord], v))
gen_action_vassal(v)
})
})
@@ -6099,7 +6095,7 @@ function goto_battle_aftermath() {
// Routed Vassals get disbanded
for (let lord = first_lord; lord <= last_lord; lord++) {
- if (is_lord_on_map(lord) && game.battle.routed_vassals[lord] !== 0) {
+ if (is_lord_on_map(lord)) {
for (let vassal of game.battle.routed_vassals[lord]) {
disband_vassal(vassal)
}