From a33910dcb88d42a35967c90f236febcf35cbe440 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 25 Aug 2023 17:27:48 +0200 Subject: [PATCH] allow getting the same RBW multiple times --- src/arkhamdb/ArkhamDb.ttslua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/arkhamdb/ArkhamDb.ttslua b/src/arkhamdb/ArkhamDb.ttslua index 7b8e266e..92ed195e 100644 --- a/src/arkhamdb/ArkhamDb.ttslua +++ b/src/arkhamdb/ArkhamDb.ttslua @@ -167,18 +167,13 @@ do --- if a weakness is added. internal.maybeDrawRandomWeakness = function(slots, playerColor) local allCardsBag = getObjectFromGUID(configuration.card_bag_guid) - local randomWeaknessAmount = 0 - for cardId, cardCount in pairs(slots) do - if cardId == RANDOM_WEAKNESS_ID then - randomWeaknessAmount = cardCount - break - end - end + local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0 + slots[RANDOM_WEAKNESS_ID] = nil + if randomWeaknessAmount ~= 0 then for i=1, randomWeaknessAmount do local weaknessId = allCardsBag.call("getRandomWeaknessId") - slots[weaknessId] = 1 - slots[RANDOM_WEAKNESS_ID] = nil + slots[weaknessId] = (slots[weaknessId] or 0) + 1 end internal.maybePrint("Added " .. randomWeaknessAmount .. " random basic weakness(es) to deck", playerColor) end