updated code
This commit is contained in:
parent
27643967eb
commit
5ddce52890
@ -291,18 +291,20 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
|
|||||||
local resourceModifier = 0
|
local resourceModifier = 0
|
||||||
local zoneWithAttachments = {}
|
local zoneWithAttachments = {}
|
||||||
cardsWithAttachments = {
|
cardsWithAttachments = {
|
||||||
["03264"] = true,
|
["03264"] = "reserve", -- Stick to the Plan
|
||||||
["07303"] = true,
|
["05002"] = true, -- Joe Diamond
|
||||||
["09077"] = true,
|
["07303"] = "reserve", -- Ancestral Knowledge
|
||||||
["10079"] = true
|
["09077"] = true, -- Underworld Market
|
||||||
|
["10079"] = "reserve" -- Bewitching
|
||||||
}
|
}
|
||||||
|
|
||||||
-- reset the startsInPlayCount
|
-- reset the startsInPlayCount
|
||||||
startsInPlayCount = 0
|
startsInPlayCount = 0
|
||||||
|
|
||||||
-- reserve slots for cards with attachments (not for Underworld Market)
|
-- reserve slots for certain cards with attachments
|
||||||
for cardId, _ in pairs(cardsWithAttachments) do
|
for cardId, state in pairs(cardsWithAttachments) do
|
||||||
if cardId ~= "09077" and slotsCopy[cardId] and slotsCopy[cardId] > 0 then
|
if state == "reserve" then
|
||||||
|
if slotsCopy[cardId] and slotsCopy[cardId] > 0 then
|
||||||
-- increase startsInPlayCount by 1 and reserve slot for this card
|
-- increase startsInPlayCount by 1 and reserve slot for this card
|
||||||
startsInPlayCount = startsInPlayCount + 1
|
startsInPlayCount = startsInPlayCount + 1
|
||||||
cardsWithAttachments[cardId] = startsInPlayCount
|
cardsWithAttachments[cardId] = startsInPlayCount
|
||||||
@ -312,6 +314,7 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
|
|||||||
zoneWithAttachments["Blank" .. startsInPlayCount] = true
|
zoneWithAttachments["Blank" .. startsInPlayCount] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for cardId, cardCount in pairs(slots) do
|
for cardId, cardCount in pairs(slots) do
|
||||||
local card = allCardsBagApi.getCardById(cardId)
|
local card = allCardsBagApi.getCardById(cardId)
|
||||||
@ -548,23 +551,6 @@ function removeBusyZones(playerColor, zoneDecks)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function handleAncestralKnowledge(cardsToSpawn)
|
|
||||||
local skillList = {}
|
|
||||||
|
|
||||||
-- process cardlist for skills
|
|
||||||
for i, card in ipairs(cardsToSpawn) do
|
|
||||||
if card.metadata.type == "Skill" and card.zone == "Deck" and not card.metadata.weakness then
|
|
||||||
table.insert(skillList, i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- move 5 random skills to SetAside3
|
|
||||||
for i = 1, 5 do
|
|
||||||
local skillListIndex = math.random(#skillList)
|
|
||||||
cardsToSpawn[skillList[skillListIndex]].zone = "UnderSetAside3"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- handle cards with attachments (Stick to the Plan, Underworld Market and Bewitching)
|
-- handle cards with attachments (Stick to the Plan, Underworld Market and Bewitching)
|
||||||
function handleAllAttachments(cardsToSpawn, slotsCopy, bondedList, customizations, playerColor)
|
function handleAllAttachments(cardsToSpawn, slotsCopy, bondedList, customizations, playerColor)
|
||||||
for cardId, reservedSlot in pairs(cardsWithAttachments) do
|
for cardId, reservedSlot in pairs(cardsWithAttachments) do
|
||||||
@ -574,7 +560,7 @@ function handleAllAttachments(cardsToSpawn, slotsCopy, bondedList, customization
|
|||||||
elseif cardId == "09077" then
|
elseif cardId == "09077" then
|
||||||
handleUnderworldMarket(cardsToSpawn, customizations, playerColor)
|
handleUnderworldMarket(cardsToSpawn, customizations, playerColor)
|
||||||
elseif cardId == "05002" then
|
elseif cardId == "05002" then
|
||||||
handleHunchDeck(cardsToSpawn, bondedList, playerColor)
|
handleHunchDeck(cardsToSpawn, customizations, bondedList, playerColor)
|
||||||
elseif cardId == "07303" then
|
elseif cardId == "07303" then
|
||||||
handleAncestralKnowledge(cardsToSpawn)
|
handleAncestralKnowledge(cardsToSpawn)
|
||||||
end
|
end
|
||||||
@ -601,105 +587,84 @@ function handleAttachment(parentId, cardsToSpawn, customizations)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside6
|
function handleAncestralKnowledge(cardsToSpawn)
|
||||||
---@param cardsToSpawn table Deck list being created
|
local skillList = {}
|
||||||
---@param playerColor string Color this deck is being loaded for
|
|
||||||
function handleUnderworldMarket(cardsToSpawn, customizations, playerColor)
|
|
||||||
local attachmentList = {}
|
|
||||||
if customizations["attachments_09077"] then
|
|
||||||
-- get list of cards that are attached (split by ",")
|
|
||||||
for str in string.gmatch(customizations["attachments_09077"], "([^,]+)") do
|
|
||||||
table.insert(attachmentList, str)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if #attachmentList == 10 then
|
-- process cardlist for skills
|
||||||
-- handling for 10 cards selected in deck data
|
|
||||||
for i = #attachmentList, 1, -1 do
|
|
||||||
for j = #cardsToSpawn, 1, -1 do
|
|
||||||
if cardsToSpawn[j].metadata.id == attachmentList[i] and cardsToSpawn[j].zone == "Deck" then
|
|
||||||
cardsToSpawn[j].zone = "UnderSetAside6"
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- regular handling
|
|
||||||
local illicitList = {}
|
|
||||||
|
|
||||||
-- get all possible Illicit cards
|
|
||||||
for i, card in ipairs(cardsToSpawn) do
|
for i, card in ipairs(cardsToSpawn) do
|
||||||
if card.metadata.traits ~= nil and string.find(card.metadata.traits, "Illicit", 1, true) and card.zone == "Deck" then
|
if card.metadata.type == "Skill" and card.zone == "Deck" and not card.metadata.weakness then
|
||||||
table.insert(illicitList, i)
|
table.insert(skillList, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #illicitList < 10 then
|
-- move 5 random skills to SetAside3
|
||||||
printToAll("Only " .. #illicitList .. " Illicit cards in your deck, you can't trigger Underworld Market's ability.", playerColor)
|
for i = 1, 5 do
|
||||||
else
|
local skillListIndex = math.random(#skillList)
|
||||||
for i = #illicitList, 1, -1 do
|
cardsToSpawn[skillList[skillListIndex]].zone = "UnderSetAside3"
|
||||||
cardsToSpawn[illicitList[i]].zone = "UnderSetAside6"
|
|
||||||
end
|
|
||||||
|
|
||||||
if #illicitList > 10 then
|
|
||||||
printToAll("Moved all " .. #illicitList .. " Illicit cards to the Market deck, reduce it to 10", playerColor)
|
|
||||||
else
|
|
||||||
printToAll("Built the Market deck", playerColor)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Extract all Insight events to SetAside5 to build the Hunch Deck for Joe Diamond
|
-- Extract all Insight events to SetAside5 to build the Hunch Deck for Joe Diamond
|
||||||
---@param cardList table Deck list being created
|
---@param cardsToSpawn table Deck list being created
|
||||||
|
---@param customizations table ArkhamDB data for customizations on customizable cards
|
||||||
---@param playerColor string Color this deck is being loaded for
|
---@param playerColor string Color this deck is being loaded for
|
||||||
function handleHunchDeck(cardList, bondedList, playerColor)
|
function handleHunchDeck(cardsToSpawn, customizations, bondedList, playerColor)
|
||||||
local insightList = {}
|
local attachmentList = {}
|
||||||
for i, card in ipairs(cardList) do
|
if customizations["attachments_05002"] then
|
||||||
|
-- get list of cards that are attached (split by ",")
|
||||||
|
for str in string.gmatch(customizations["attachments_05002"], "([^,]+)") do
|
||||||
|
table.insert(attachmentList, str)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- regular handling, get all possible insight events
|
||||||
|
for i, card in ipairs(cardsToSpawn) do
|
||||||
if card.metadata.type == "Event"
|
if card.metadata.type == "Event"
|
||||||
and card.metadata.traits ~= nil
|
and card.metadata.traits ~= nil
|
||||||
and string.match(card.metadata.traits, "Insight")
|
and string.match(card.metadata.traits, "Insight")
|
||||||
and bondedList[card.metadata.id] == nil then
|
and bondedList[card.metadata.id] == nil then
|
||||||
table.insert(insightList, i)
|
table.insert(attachmentList, card.metadata.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Process cards to move them to the hunch deck. This is done in reverse order because the sorting needs
|
local count = #attachmentList
|
||||||
-- 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
|
-- change zone for cards
|
||||||
for i = #insightList, 1, -1 do
|
for i = count, 1, -1 do
|
||||||
local moving = cardList[insightList[i]]
|
for j = #cardsToSpawn, 1, -1 do
|
||||||
moving.zone = "SetAside5"
|
if cardsToSpawn[j].metadata.id == attachmentList[i] and cardsToSpawn[j].zone == "Deck" then
|
||||||
table.remove(cardList, insightList[i])
|
cardsToSpawn[j].zone = "SetAside5"
|
||||||
table.insert(cardList, moving)
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #insightList < 11 then
|
if count < 11 then
|
||||||
printToAll("Joe's hunch deck must have 11 cards but the deck only has " .. #insightList .. " Insight events.", playerColor)
|
printToAll("Joe's hunch deck must have 11 cards but the deck only has " .. count .. " Insight events.", playerColor)
|
||||||
elseif #insightList > 11 then
|
elseif count > 11 then
|
||||||
printToAll("Moved all " .. #insightList .. " Insight events to the hunch deck, reduce it to 11.", playerColor)
|
printToAll("Moved all " .. count .. " Insight events to the hunch deck, reduce it to 11.", playerColor)
|
||||||
else
|
else
|
||||||
printToAll("Built Joe's hunch deck", playerColor)
|
printToAll("Built Joe's hunch deck", playerColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Extract all Ally assets to SetAside5 to build the Spirit Deck for parallel Jim Culver
|
-- Extract all Ally assets to SetAside5 to build the Spirit Deck for parallel Jim Culver
|
||||||
---@param cardList table Deck list being created
|
---@param cardsToSpawn table Deck list being created
|
||||||
---@param playerColor string Color this deck is being loaded for
|
---@param playerColor string Color this deck is being loaded for
|
||||||
---@param customizations table Additional deck information
|
---@param customizations table ArkhamDB data for customizations on customizable cards
|
||||||
function handleSpiritDeck(cardList, playerColor, customizations)
|
function handleSpiritDeck(cardsToSpawn, playerColor, customizations)
|
||||||
local spiritList = {}
|
local spiritList = {}
|
||||||
if customizations["extra_deck"] then
|
if customizations["extra_deck"] then
|
||||||
-- split by ","
|
-- split by ","
|
||||||
for str in string.gmatch(customizations["extra_deck"], "([^,]+)") do
|
for str in string.gmatch(customizations["extra_deck"], "([^,]+)") do
|
||||||
local card = allCardsBagApi.getCardById(str)
|
local card = allCardsBagApi.getCardById(str)
|
||||||
if card ~= nil then
|
if card ~= nil then
|
||||||
table.insert(cardList, { data = card.data, metadata = card.metadata, zone = "SetAside5" })
|
table.insert(cardsToSpawn, { data = card.data, metadata = card.metadata, zone = "SetAside5" })
|
||||||
table.insert(spiritList, str)
|
table.insert(spiritList, str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i, card in ipairs(cardList) do
|
for i, card in ipairs(cardsToSpawn) do
|
||||||
if card.metadata.id == "90053" or (
|
if card.metadata.id == "90053" or (
|
||||||
card.metadata.type == "Asset"
|
card.metadata.type == "Asset"
|
||||||
and card.metadata.traits ~= nil
|
and card.metadata.traits ~= nil
|
||||||
@ -710,14 +675,8 @@ function handleSpiritDeck(cardList, playerColor, customizations)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Process cards 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 = #spiritList, 1, -1 do
|
for i = #spiritList, 1, -1 do
|
||||||
local moving = cardList[spiritList[i]]
|
cardsToSpawn[spiritList[i]].zone = "SetAside5"
|
||||||
moving.zone = "SetAside5"
|
|
||||||
table.remove(cardList, spiritList[i])
|
|
||||||
table.insert(cardList, moving)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -730,6 +689,47 @@ function handleSpiritDeck(cardList, playerColor, customizations)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside6
|
||||||
|
---@param cardsToSpawn table Deck list being created
|
||||||
|
---@param customizations table ArkhamDB data for customizations on customizable cards
|
||||||
|
---@param playerColor string Color this deck is being loaded for
|
||||||
|
function handleUnderworldMarket(cardsToSpawn, customizations, playerColor)
|
||||||
|
local attachmentList = {}
|
||||||
|
if customizations["attachments_09077"] then
|
||||||
|
-- get list of cards that are attached (split by ",")
|
||||||
|
for str in string.gmatch(customizations["attachments_09077"], "([^,]+)") do
|
||||||
|
table.insert(attachmentList, str)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- regular handling, get all possible Illicit cards
|
||||||
|
for i, card in ipairs(cardsToSpawn) do
|
||||||
|
if card.metadata.traits ~= nil and string.match(card.metadata.traits, "Illicit") and card.zone == "Deck" then
|
||||||
|
table.insert(attachmentList, card.metadata.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local count = #attachmentList
|
||||||
|
|
||||||
|
-- change zone for cards
|
||||||
|
for i = count, 1, -1 do
|
||||||
|
for j = #cardsToSpawn, 1, -1 do
|
||||||
|
if cardsToSpawn[j].metadata.id == attachmentList[i] and cardsToSpawn[j].zone == "Deck" then
|
||||||
|
cardsToSpawn[j].zone = "UnderSetAside6"
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if count < 10 then
|
||||||
|
printToAll("Only " .. count .. " Illicit cards in your deck, you can't trigger Underworld Market's ability.", playerColor)
|
||||||
|
elseif count > 10 then
|
||||||
|
printToAll("Moved all " .. count .. " Illicit cards to the Market deck, reduce it to 10", playerColor)
|
||||||
|
else
|
||||||
|
printToAll("Built the Market deck", playerColor)
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user