From 8f76d3bfd33494b2e378c994fbbc7e67a86c1761 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 20 Apr 2024 20:37:29 +0200 Subject: Optimize and fix Chamberlains and Quartermasters. --- rules.ts | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'rules.ts') diff --git a/rules.ts b/rules.ts index e2b3af4..3445c99 100644 --- a/rules.ts +++ b/rules.ts @@ -3049,13 +3049,12 @@ function do_levy_ship() { goto_the_kings_name("Levy Ship") } -// Check if the levy troops is at vassal seat function chamberlains_eligible_levy(loc: Locale) { - for (let vassal of all_vassals) - if (is_vassal_mustered_with(vassal, game.command) && lord_has_capability(game.command, AOW_LANCASTER_CHAMBERLAINS)) { - if (loc === data.vassals[vassal].seat) + if (lord_has_capability(game.command, AOW_LANCASTER_CHAMBERLAINS)) { + for (let vassal of all_vassals) + if (is_vassal_mustered_with(vassal, game.command) && loc === data.vassals[vassal].seat) return true - } + } return false } @@ -3731,14 +3730,20 @@ function command_has_harbingers() { } function chamberlains_eligible_supply(source: Locale) { - for (let vassal of all_vassals) - if ( - is_vassal_mustered_with(vassal, game.command) && - lord_has_capability(game.command, AOW_LANCASTER_CHAMBERLAINS) - ) { - if (source === data.vassals[vassal].seat) + if (lord_has_capability(game.command, AOW_LANCASTER_CHAMBERLAINS)) { + for (let vassal of all_vassals) + if (is_vassal_mustered_with(vassal, game.command) && source === data.vassals[vassal].seat) return true - } + } + return false +} + +function quartermasters_eligible_supply(source: Locale) { + if (lord_has_capability(game.command, AOW_LANCASTER_QUARTERMASTERS)) { + for (let vassal of all_vassals) + if (is_vassal_mustered_with(vassal, game.command) && source === data.vassals[vassal].seat) + return true + } return false } @@ -3861,22 +3866,10 @@ states.supply_source = { }, } -function quartermasters_eligible_supply(source: Locale) { - for (let vassal of all_vassals) - if ( - is_vassal_mustered_with(vassal, game.command) && - lord_has_capability(game.command, AOW_LANCASTER_CHAMBERLAINS) - ) { - if (source === data.vassals[vassal].seat) - return true - } - return false -} - function use_stronghold_supply(source: Locale, amount: number) { logi(`${amount} from Stronghold at %${source}`) add_lord_assets(game.command, PROV, amount) - if (!chamberlains_eligible_supply(source)) + if (!chamberlains_eligible_supply(source) && !quartermasters_eligible_supply(source)) deplete_locale(source) } -- cgit v1.2.3