diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-04-20 20:37:29 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-04-20 20:37:29 +0200 |
commit | 8f76d3bfd33494b2e378c994fbbc7e67a86c1761 (patch) | |
tree | 4b4d25124fe33c44cf9ff3604bad7cdb6282d3bc /rules.ts | |
parent | ddea0d426029c95616730763159b79f9fdd39702 (diff) | |
download | plantagenet-8f76d3bfd33494b2e378c994fbbc7e67a86c1761.tar.gz |
Optimize and fix Chamberlains and Quartermasters.
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 43 |
1 files changed, 18 insertions, 25 deletions
@@ -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) } |