summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-06 20:03:11 +0200
committerTor Andersson <tor@ccxvii.net>2023-12-10 18:16:55 +0100
commit6e212cb25c5674df070481d06087f727fcf7a4ca (patch)
tree5ed80df4181282c0e46f43643fd2a25e4e6d751f /rules.js
parent289e9eb5cc729bb8a9f17799de5d95b7d01e82f3 (diff)
downloadplantagenet-6e212cb25c5674df070481d06087f727fcf7a4ca.tar.gz
for_each_ready_vassal
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js24
1 files changed, 8 insertions, 16 deletions
diff --git a/rules.js b/rules.js
index 5d9db10..3e59ec4 100644
--- a/rules.js
+++ b/rules.js
@@ -105,7 +105,7 @@ const D3 = 5
function find_card(name) {
let ix = data.cards.findIndex(x => x.name === name)
if (ix < 0)
- throw "CANNOT FIND LORD: " + name
+ throw "CANNOT FIND CARD: " + name
return ix
}
@@ -119,7 +119,7 @@ function find_lord(name) {
function find_locale(name) {
let ix = data.locales.findIndex(x => x.name === name)
if (ix < 0)
- throw "CANNOT FIND LORD: " + name
+ throw "CANNOT FIND LOCALE: " + name
return ix
}
@@ -229,8 +229,6 @@ const L35 = find_card("L35")
const L36 = find_card("L36")
const L37 = find_card("L37")
-//const GARRISON = 100
-
const LORD_YORK = find_lord("York")
const LORD_MARCH = find_lord("March")
const LORD_EDWARD_IV = find_lord("Edward IV")
@@ -1324,17 +1322,11 @@ function pay_vassal(vassal) {
set_vassal_on_calendar(vassal, current_turn() + 1)
}
-function get_ready_vassals() {
+function for_each_ready_vassal(f) {
let favor = game.active === YORK ? game.pieces.favoury : game.pieces.favourl
- let results = []
-
- for (let x = first_vassal; x < last_vassal; x++) {
- if (is_vassal_ready(x) && favor.includes(data.vassals[x].seat[0])) {
- results.push(x)
- }
- }
-
- return results
+ for (let x = first_vassal; x < last_vassal; x++)
+ if (is_vassal_ready(x) && set_has(favor, data.vassals[x].seat))
+ f(x)
}
function is_vassal_unavailable(vassal) {
@@ -2758,9 +2750,9 @@ states.levy_muster_lord = {
// Muster Ready Vassal Forces
if (is_friendly_locale(get_lord_locale(game.who))) {
- for (let vassal of get_ready_vassals()) {
+ for_each_ready_vassal(vasal => {
gen_action_vassal(vassal)
- }
+ })
}
// Add Transport