summaryrefslogtreecommitdiff
path: root/rules.ts
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-04-20 20:37:29 +0200
committerTor Andersson <tor@ccxvii.net>2024-04-20 20:37:29 +0200
commit8f76d3bfd33494b2e378c994fbbc7e67a86c1761 (patch)
tree4b4d25124fe33c44cf9ff3604bad7cdb6282d3bc /rules.ts
parentddea0d426029c95616730763159b79f9fdd39702 (diff)
downloadplantagenet-8f76d3bfd33494b2e378c994fbbc7e67a86c1761.tar.gz
Optimize and fix Chamberlains and Quartermasters.
Diffstat (limited to 'rules.ts')
-rw-r--r--rules.ts43
1 files changed, 18 insertions, 25 deletions
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)
}