summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-07-02 14:20:36 +0200
committerTor Andersson <tor@ccxvii.net>2024-07-02 14:20:36 +0200
commit50113262dec35af2f6228cce8d6e83e66c64b7b1 (patch)
treeb6c725699784405b504a138c6aa36d7191798ad3
parent26dc8db58f46add3ba35544b1021214bbac75b61 (diff)
downloadplantagenet-50113262dec35af2f6228cce8d6e83e66c64b7b1.tar.gz
Separate count_lord_all_forces and count_lord_all_troops.
-rw-r--r--rules.js13
-rw-r--r--rules.ts14
2 files changed, 17 insertions, 10 deletions
diff --git a/rules.js b/rules.js
index e3c6d49..26530c2 100644
--- a/rules.js
+++ b/rules.js
@@ -989,13 +989,16 @@ function is_enemy_lord(lord) {
return is_lancaster_lord(lord);
return is_york_lord(lord);
}
-function count_lord_all_forces(lord) {
+function count_lord_all_troops(lord) {
return (get_lord_forces(lord, BURGUNDIANS) +
get_lord_forces(lord, MERCENARIES) +
get_lord_forces(lord, MEN_AT_ARMS) +
get_lord_forces(lord, MILITIA) +
get_lord_forces(lord, LONGBOWMEN));
}
+function count_lord_all_forces(lord) {
+ return 1 + count_vassals_with_lord(lord) + count_lord_all_troops(lord);
+}
function count_group_all_forces(list) {
let n = 0;
for (let lord of list)
@@ -1916,7 +1919,7 @@ function reset_unpaid_lords(here) {
for (let lord of all_friendly_lords()) {
if (is_lord_unfed(lord) && get_lord_locale(lord) === here) {
// Note: Percy's Power only affects Pay -- so will never end up here
- set_lord_unfed(lord, Math.ceil(count_lord_all_forces(lord) / 6));
+ set_lord_unfed(lord, Math.ceil(count_lord_all_troops(lord) / 6));
}
}
}
@@ -1925,7 +1928,7 @@ function goto_pay_troops() {
logcap(AOW_LANCASTER_PERCYS_POWER);
for (let lord of all_friendly_lords()) {
let here = get_lord_locale(lord);
- let n = Math.ceil(count_lord_all_forces(lord) / 6);
+ let n = Math.ceil(count_lord_all_troops(lord) / 6);
if (lord_has_capability(lord, AOW_LANCASTER_MADAME_LA_GRANDE) && is_at_or_adjacent_to_lancastrian_english_channel_port(here)) {
logcap(AOW_LANCASTER_MADAME_LA_GRANDE);
add_lord_assets(lord, COIN, 1);
@@ -7626,7 +7629,7 @@ function has_friendly_lord_who_must_feed() {
function set_lord_feed_requirements(lord) {
// Count how much food each lord needs
if (get_lord_moved(lord))
- set_lord_unfed(lord, Math.ceil(count_lord_all_forces(lord) / 6));
+ set_lord_unfed(lord, Math.ceil(count_lord_all_troops(lord) / 6));
else
set_lord_unfed(lord, 0);
}
@@ -11786,7 +11789,7 @@ function assert_mutually_exclusive_lords() {
}
function assert_all_lords_have_troops_or_retinue() {
for (let lord of all_lords) {
- if (is_lord_on_map(lord) && !count_lord_all_forces(lord) && !get_lord_forces(lord, RETINUE))
+ if (is_lord_on_map(lord) && !count_lord_all_troops(lord) && !get_lord_forces(lord, RETINUE))
throw Error(`ASSERT: Lord "${lord_name[lord]}" without troops or retinue.`);
}
}
diff --git a/rules.ts b/rules.ts
index b0369c8..db155d1 100644
--- a/rules.ts
+++ b/rules.ts
@@ -1374,7 +1374,7 @@ function is_enemy_lord(lord: Lord) {
return is_york_lord(lord)
}
-function count_lord_all_forces(lord: Lord) {
+function count_lord_all_troops(lord: Lord) {
return (
get_lord_forces(lord, BURGUNDIANS) +
get_lord_forces(lord, MERCENARIES) +
@@ -1384,6 +1384,10 @@ function count_lord_all_forces(lord: Lord) {
)
}
+function count_lord_all_forces(lord: Lord) {
+ return 1 + count_vassals_with_lord(lord) + count_lord_all_troops(lord)
+}
+
function count_group_all_forces(list: Lord[]) {
let n = 0
for (let lord of list)
@@ -2433,7 +2437,7 @@ function reset_unpaid_lords(here: Locale) {
for (let lord of all_friendly_lords()) {
if (is_lord_unfed(lord) && get_lord_locale(lord) === here) {
// Note: Percy's Power only affects Pay -- so will never end up here
- set_lord_unfed(lord, Math.ceil(count_lord_all_forces(lord) / 6))
+ set_lord_unfed(lord, Math.ceil(count_lord_all_troops(lord) / 6))
}
}
}
@@ -2444,7 +2448,7 @@ function goto_pay_troops() {
for (let lord of all_friendly_lords()) {
let here = get_lord_locale(lord)
- let n = Math.ceil(count_lord_all_forces(lord) / 6)
+ let n = Math.ceil(count_lord_all_troops(lord) / 6)
if (lord_has_capability(lord, AOW_LANCASTER_MADAME_LA_GRANDE) && is_at_or_adjacent_to_lancastrian_english_channel_port(here)) {
logcap(AOW_LANCASTER_MADAME_LA_GRANDE)
add_lord_assets(lord, COIN, 1)
@@ -8938,7 +8942,7 @@ function has_friendly_lord_who_must_feed() {
function set_lord_feed_requirements(lord: Lord) {
// Count how much food each lord needs
if (get_lord_moved(lord))
- set_lord_unfed(lord, Math.ceil(count_lord_all_forces(lord) / 6))
+ set_lord_unfed(lord, Math.ceil(count_lord_all_troops(lord) / 6))
else
set_lord_unfed(lord, 0)
}
@@ -13575,7 +13579,7 @@ function assert_mutually_exclusive_lords() {
function assert_all_lords_have_troops_or_retinue() {
for (let lord of all_lords) {
- if (is_lord_on_map(lord) && !count_lord_all_forces(lord) && !get_lord_forces(lord, RETINUE))
+ if (is_lord_on_map(lord) && !count_lord_all_troops(lord) && !get_lord_forces(lord, RETINUE))
throw Error(`ASSERT: Lord "${lord_name[lord]}" without troops or retinue.`)
}
}