summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js5
-rw-r--r--rules.ts14
2 files changed, 12 insertions, 7 deletions
diff --git a/play.js b/play.js
index 777641d..2186790 100644
--- a/play.js
+++ b/play.js
@@ -962,10 +962,9 @@ function add_valour(parent, lord) {
function update_valour(lord, parent, battle) {
parent.replaceChildren()
if (!battle) return
- for (let i = 0; i < battle.valour[lord]; i++) {
+ let n = map_get(battle.valour, lord, 0)
+ for (let i = 0; i < n; i++)
add_valour(parent, lord)
- }
-
}
function update_lord_mat(ix) {
diff --git a/rules.ts b/rules.ts
index f017378..d30fbb9 100644
--- a/rules.ts
+++ b/rules.ts
@@ -5873,7 +5873,7 @@ function goto_battle() {
NOBODY, NOBODY, NOBODY,
NOBODY, NOBODY, NOBODY
],
- valour: Array(lord_count).fill(0),
+ valour: [],
routed_vassals: [],
engagements: [],
reserves: [],
@@ -5900,7 +5900,9 @@ function goto_battle() {
if (get_lord_locale(lord) === here) {
set_lord_fought(lord)
set_add(game.battle.reserves, lord)
- game.battle.valour[lord] = get_modified_valour(lord)
+ let n = get_modified_valour(lord)
+ if (n > 0)
+ map_set(game.battle.valour, lord, n)
}
}
@@ -7473,11 +7475,15 @@ function assign_hit_roll(what, prot, extra) {
}
function get_lord_remaining_valour(lord: Lord): number {
- return game.battle.valour[lord]
+ return map_get(game.battle.valour, lord, 0)
}
function spend_valour(lord: Lord) {
- game.battle.valour[lord] --
+ let n = map_get(game.battle.valour, lord, 0) - 1
+ if (n > 0)
+ map_set(game.battle.valour, lord, n)
+ else
+ map_delete(game.battle.valour, lord)
}
function get_inherent_protection(force: Force) {