From 885a161740b483bad04abd98d380c05d253d96d6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 6 Oct 2023 15:25:58 +0200 Subject: game.battle.routed_vassals is a always set No need to check if it is 0. --- rules.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'rules.js') 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) } -- cgit v1.2.3