added error printing for removing cards

This commit is contained in:
Chr1Z93 2024-01-28 12:15:10 +01:00
parent 3026a60d4f
commit 9ea4a930e9

View File

@ -102,9 +102,9 @@ do
if (adbCardInfo.xp ~= nil and adbCardInfo.xp > 0) then if (adbCardInfo.xp ~= nil and adbCardInfo.xp > 0) then
cardName = cardName .. " (" .. adbCardInfo.xp .. ")" cardName = cardName .. " (" .. adbCardInfo.xp .. ")"
end end
internal.maybePrint("Card not found: " .. cardName .. ", ArkhamDB ID " .. cardId, playerColor) internal.maybePrint("Card not found: " .. cardName .. ", card ID " .. cardId, playerColor)
else else
internal.maybePrint("Card not found in ArkhamDB, ID " .. cardId, playerColor) internal.maybePrint("Card not found in ArkhamDB/Index, ID " .. cardId, playerColor)
end end
end) end)
end end
@ -147,7 +147,7 @@ do
loadAltInvestigator = internal.addInvestigatorCards(deck, slots) loadAltInvestigator = internal.addInvestigatorCards(deck, slots)
end end
internal.maybeModifyDeckFromDescription(slots, deck.description_md) internal.maybeModifyDeckFromDescription(slots, deck.description_md, playerColor)
internal.maybeAddSummonedServitor(slots) internal.maybeAddSummonedServitor(slots)
internal.maybeAddOnTheMend(slots, playerColor) internal.maybeAddOnTheMend(slots, playerColor)
internal.maybeAddRealityAcidReference(slots) internal.maybeAddRealityAcidReference(slots)
@ -292,7 +292,7 @@ do
-- Processes the deck description from ArkhamDB and modifies the slot list accordingly -- Processes the deck description from ArkhamDB and modifies the slot list accordingly
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number ---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
---@param description String The deck desription from ArkhamDB ---@param description String The deck desription from ArkhamDB
internal.maybeModifyDeckFromDescription = function(slots, description) internal.maybeModifyDeckFromDescription = function(slots, description, playerColor)
-- check for import instructions -- check for import instructions
local pos = string.find(description, "++SCED import instructions++") local pos = string.find(description, "++SCED import instructions++")
if not pos then return end if not pos then return end
@ -326,7 +326,10 @@ do
if instructor == "add:" then if instructor == "add:" then
slots[str] = (slots[str] or 0) + 1 slots[str] = (slots[str] or 0) + 1
elseif instructor == "remove:" then elseif instructor == "remove:" then
if slots[str] == nil then break end if slots[str] == nil then
internal.maybePrint("Tried to remove " .. str .. ", but didn't find card in deck.", playerColor)
break
end
slots[str] = math.max(slots[str] - 1, 0) slots[str] = math.max(slots[str] - 1, 0)
-- also remove related minicard -- also remove related minicard