From 2ffcab7b644e3c874f7c01f2f1d765c222db9a58 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 25 Jan 2023 18:52:46 +0100 Subject: Fix discard of capability when multiple lords have the same. --- rules.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'rules.js') 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) } -- cgit v1.2.3