summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-01-25 18:52:46 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:39 +0100
commit2ffcab7b644e3c874f7c01f2f1d765c222db9a58 (patch)
tree5ff649e6bc708b70ecbccf6989acd30cd475d89e /rules.js
parent1726bed0e8dc2e7f3a2947645c66872322cb5316 (diff)
downloadnevsky-2ffcab7b644e3c874f7c01f2f1d765c222db9a58.tar.gz
Fix discard of capability when multiple lords have the same.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/rules.js b/rules.js
index 96394d7..3d6c735 100644
--- a/rules.js
+++ b/rules.js
@@ -3563,12 +3563,9 @@ states.muster_lord_transport = {
}
function lord_has_capability_card(lord, c) {
- let name = data.cards[c].capability
- let c1 = get_lord_capability(lord, 0)
- if (c1 >= 0 && data.cards[c1].capability === name)
+ if (get_lord_capability(lord, 0) === c)
return true
- let c2 = get_lord_capability(lord, 1)
- if (c2 >= 0 && data.cards[c2].capability === name)
+ if (get_lord_capability(lord, 1) === c)
return true
return false
}
@@ -10528,9 +10525,9 @@ function action_wastage(lord, type) {
add_lord_assets(lord, type, -1)
}
-function find_lord_capability(c) {
+function find_lord_with_capability_card(c) {
for (let lord = first_friendly_lord; lord <= last_friendly_lord; ++lord)
- if (lord_has_capability(lord, c))
+ if (lord_has_capability_card(lord, c))
return lord
return NOBODY
}
@@ -10554,7 +10551,7 @@ states.wastage = {
},
card(c) {
push_undo()
- let lord = find_lord_capability(c)
+ let lord = find_lord_with_capability_card(c)
set_lord_moved(lord, 0)
discard_lord_capability(lord, c)
},
@@ -10626,7 +10623,7 @@ states.reset = {
log("Discarded Held card.")
set_delete(game.hand2, c)
} else {
- let lord = find_lord_capability(c)
+ let lord = find_lord_with_capability_card(c)
if (lord !== NOBODY) {
discard_lord_capability(lord, c)
}