Added Parallel Jim Deck Importer support

This commit is contained in:
Entrox-Licher 2023-10-13 22:30:32 -04:00
parent 28cbcb7dbf
commit 1629f790b3

View File

@ -88,6 +88,7 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
handleAncestralKnowledge(cardsToSpawn) handleAncestralKnowledge(cardsToSpawn)
handleUnderworldMarket(cardsToSpawn, playerColor) handleUnderworldMarket(cardsToSpawn, playerColor)
handleHunchDeck(investigatorId, cardsToSpawn, playerColor) handleHunchDeck(investigatorId, cardsToSpawn, playerColor)
handleSpiritDeck(investigatorId, cardsToSpawn, playerColor)
handleCustomizableUpgrades(cardsToSpawn, customizations) handleCustomizableUpgrades(cardsToSpawn, customizations)
handlePeteSignatureAssets(investigatorId, cardsToSpawn) handlePeteSignatureAssets(investigatorId, cardsToSpawn)
@ -322,6 +323,46 @@ function handleHunchDeck(investigatorId, cardList, playerColor)
end end
end end
-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit
-- Deck.
---@param investigatorId String ID for the deck's investigator card. Passed separately because the
--- investigator may not be included in the cardList
---@param cardList Table Deck list being created
---@param playerColor String Color this deck is being loaded for
function handleSpiritDeck(investigatorId, cardList, playerColor)
if investigatorId == "02004-p" or investigatorId == "02004-pb" then -- Parallel Jim Culver
local spritList = {}
for i, card in ipairs(cardList) do
if card.metadata.id == "90053" or (card.metadata.type == "Asset"
and card.metadata.traits ~= nil
and string.match(card.metadata.traits, "Ally")
and card.metadata.bonded_to == nil) then
table.insert(spritList, i)
end
end
-- Process allies to move them to the spirit deck. This is done in reverse
-- order because the sorting needs to be reversed (deck sorts for face down)
-- Performance here may be an issue, as table.remove() is an O(n) operation
-- which makes the full shift O(n^2). But keep it simple unless it becomes
-- a problem
for i = #spritList, 1, -1 do
local moving = cardList[spritList[i]]
moving.zone = "SetAside5"
table.remove(cardList, spritList[i])
table.insert(cardList, moving)
end
if #spritList < 10 then
printToAll("Jim's spirit deck must have 10 cards but the deck only has " .. #spritList ..
" Ally assets.", playerColor)
elseif #spritList > 11 then
printToAll("Moved all " .. #spritList ..
" Ally assets to the spirit deck, reduce it to 11.", playerColor)
else
printToAll("Built Jim's spirit deck", playerColor)
end
end
end
-- For any customization upgrade cards in the card list, process the metadata from the deck to -- For any customization upgrade cards in the card list, process the metadata from the deck to
-- set the save state to show the correct checkboxes/text field values -- set the save state to show the correct checkboxes/text field values
---@param cardList Table Deck list being created ---@param cardList Table Deck list being created