added attachment helper spawning
This commit is contained in:
parent
9be0201909
commit
591661b9fc
@ -34,6 +34,10 @@
|
|||||||
"Nickname": "Attachment Helper",
|
"Nickname": "Attachment Helper",
|
||||||
"Snap": true,
|
"Snap": true,
|
||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
|
"Tags": [
|
||||||
|
"AttachmentHelperBag",
|
||||||
|
"CleanUpHelper_ignore"
|
||||||
|
],
|
||||||
"Tooltip": true,
|
"Tooltip": true,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": 27.677,
|
"posX": 27.677,
|
||||||
|
@ -286,20 +286,36 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
|
|||||||
local slotsCopy = deepCopy(slots)
|
local slotsCopy = deepCopy(slots)
|
||||||
local cardsToSpawn = {}
|
local cardsToSpawn = {}
|
||||||
local resourceModifier = 0
|
local resourceModifier = 0
|
||||||
|
cardsWithAttachments = {
|
||||||
|
["03264"] = true,
|
||||||
|
["07303"] = true,
|
||||||
|
["09077"] = true,
|
||||||
|
["10079"] = true
|
||||||
|
}
|
||||||
|
|
||||||
-- reset the startsInPlayCount
|
-- reset the startsInPlayCount
|
||||||
startsInPlayCount = 0
|
startsInPlayCount = 0
|
||||||
|
|
||||||
-- Attachment Helper handling
|
-- reserve slots for cards with attachments
|
||||||
if GlobalApi.getOptionPanelState()["showAttachmentHelper"] then
|
for cardId, _ in pairs(cardsWithAttachments) do
|
||||||
|
if slotsCopy[cardId] and slotsCopy[cardId] > 0 then
|
||||||
else
|
-- increase startsInPlayCount by 1 and reserve slot for this card
|
||||||
|
startsInPlayCount = startsInPlayCount + 1
|
||||||
|
cardsWithAttachments[cardId] = startsInPlayCount
|
||||||
|
|
||||||
|
-- reserve an additional slot for the attachments
|
||||||
|
startsInPlayCount = startsInPlayCount + 1
|
||||||
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)
|
||||||
if card ~= nil then
|
if card ~= nil then
|
||||||
local cardZone = getDefaultCardZone(card.metadata, bondedList)
|
if cardsWithAttachments[cardId] and cardsWithAttachments[cardId] < 6 then
|
||||||
|
cardZone = "Blank" .. cardsWithAttachments[cardId]
|
||||||
|
else
|
||||||
|
cardZone = getDefaultCardZone(card.metadata, bondedList)
|
||||||
|
end
|
||||||
for i = 1, cardCount do
|
for i = 1, cardCount do
|
||||||
table.insert(cardsToSpawn, { data = card.data, metadata = card.metadata, zone = cardZone })
|
table.insert(cardsToSpawn, { data = card.data, metadata = card.metadata, zone = cardZone })
|
||||||
end
|
end
|
||||||
@ -315,8 +331,7 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
|
|||||||
end
|
end
|
||||||
|
|
||||||
updateStartingResources(playerColor, resourceModifier)
|
updateStartingResources(playerColor, resourceModifier)
|
||||||
handleAncestralKnowledge(cardsToSpawn, slotsCopy)
|
handleAllAttachments(cardsToSpawn, slotsCopy, bondedList, customizations, playerColor)
|
||||||
handleNonRandomSelections(cardsToSpawn, slotsCopy, bondedList, customizations, playerColor)
|
|
||||||
|
|
||||||
-- parallel Jim Culver handling
|
-- parallel Jim Culver handling
|
||||||
if investigatorId == "02004-p" or investigatorId == "02004-pb" then
|
if investigatorId == "02004-p" or investigatorId == "02004-pb" then
|
||||||
@ -338,6 +353,21 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
|
|||||||
local deckRot = zones.getDefaultCardRotation(playerColor, zone)
|
local deckRot = zones.getDefaultCardRotation(playerColor, zone)
|
||||||
local callback = nil
|
local callback = nil
|
||||||
|
|
||||||
|
-- spawn attachment helpers if option is enabled
|
||||||
|
if GlobalApi.getOptionPanelState()["showAttachmentHelper"] then
|
||||||
|
local objs = getObjectsWithTag("AttachmentHelperBag")
|
||||||
|
if #objs > 0 then
|
||||||
|
for cardId, reservedSlot in pairs(cardsWithAttachments) do
|
||||||
|
if reservedSlot < 7 then
|
||||||
|
objs[1].takeObject({
|
||||||
|
position = zones.getZonePosition(playerColor, "Blank" .. reservedSlot):setAt("y", 1.6),
|
||||||
|
rotation = deckRot
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- If cards are spread too close together TTS groups them weirdly, selecting multiples
|
-- If cards are spread too close together TTS groups them weirdly, selecting multiples
|
||||||
-- when hovering over a single card. This distance is the minimum to avoid that.
|
-- when hovering over a single card. This distance is the minimum to avoid that.
|
||||||
local spreadDistance = 1.15
|
local spreadDistance = 1.15
|
||||||
@ -504,15 +534,11 @@ function removeBusyZones(playerColor, zoneDecks)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check to see if the deck list has Ancestral Knowledge. If it does, move 5 random skills to SetAside3
|
function handleAncestralKnowledge(cardsToSpawn)
|
||||||
---@param cardList table Deck list being created
|
|
||||||
function handleAncestralKnowledge(cardList, slotsCopy)
|
|
||||||
if not slotsCopy["07303"] or slotsCopy["07303"] == 0 then return end
|
|
||||||
|
|
||||||
local skillList = {}
|
local skillList = {}
|
||||||
|
|
||||||
-- process cardlist for skills
|
-- process cardlist for skills
|
||||||
for i, card in ipairs(cardList) do
|
for i, card in ipairs(cardsToSpawn) do
|
||||||
if card.metadata.type == "Skill" and card.zone == "Deck" and not card.metadata.weakness then
|
if card.metadata.type == "Skill" and card.zone == "Deck" and not card.metadata.weakness then
|
||||||
table.insert(skillList, i)
|
table.insert(skillList, i)
|
||||||
end
|
end
|
||||||
@ -521,40 +547,41 @@ function handleAncestralKnowledge(cardList, slotsCopy)
|
|||||||
-- move 5 random skills to SetAside3
|
-- move 5 random skills to SetAside3
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
local skillListIndex = math.random(#skillList)
|
local skillListIndex = math.random(#skillList)
|
||||||
cardList[skillList[skillListIndex]].zone = "UnderSetAside3"
|
cardsToSpawn[skillList[skillListIndex]].zone = "UnderSetAside3"
|
||||||
table.remove(skillList, skillListIndex)
|
table.remove(skillList, skillListIndex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function handleNonRandomSelections(cardsToSpawn, slotsCopy, bondedList, customizations, playerColor)
|
|
||||||
-- handle cards with attachments (Stick to the Plan, Underworld Market and Bewitching)
|
-- handle cards with attachments (Stick to the Plan, Underworld Market and Bewitching)
|
||||||
for _, cardId in ipairs({ "03264", "09077", "10079" }) do
|
function handleAllAttachments(cardsToSpawn, slotsCopy, bondedList, customizations, playerColor)
|
||||||
|
for cardId, reservedSlot in pairs(cardsWithAttachments) do
|
||||||
if slotsCopy[cardId] and slotsCopy[cardId] > 0 then
|
if slotsCopy[cardId] and slotsCopy[cardId] > 0 then
|
||||||
if customizations["attachments_" .. cardId] then
|
if customizations["attachments_" .. cardId] and reservedSlot < 6 then
|
||||||
handleAttachment(cardId, cardsToSpawn, customizations)
|
handleAttachment(cardId, cardsToSpawn, customizations)
|
||||||
elseif cardId == "09077" then
|
elseif cardId == "09077" then
|
||||||
handleUnderworldMarket(cardsToSpawn, slotsCopy, playerColor)
|
handleUnderworldMarket(cardsToSpawn, slotsCopy, playerColor)
|
||||||
elseif cardId == "05002" then
|
elseif cardId == "05002" then
|
||||||
handleHunchDeck(cardsToSpawn, bondedList, playerColor)
|
handleHunchDeck(cardsToSpawn, bondedList, playerColor)
|
||||||
|
elseif cardId == "07303" then
|
||||||
|
handleAncestralKnowledge(cardsToSpawn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function handleAttachment(parentId, cardsToSpawn, customizations)
|
function handleAttachment(parentId, cardsToSpawn, customizations)
|
||||||
-- get list of cards that are attached
|
-- get list of cards that are attached (split by ",")
|
||||||
local attachmentList = {}
|
local attachmentList = {}
|
||||||
|
|
||||||
-- split by ","
|
|
||||||
for str in string.gmatch(customizations["attachments_" .. parentId], "([^,]+)") do
|
for str in string.gmatch(customizations["attachments_" .. parentId], "([^,]+)") do
|
||||||
table.insert(attachmentList, str)
|
table.insert(attachmentList, str)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- process cards
|
-- process cards
|
||||||
|
local zone = "Blank" .. (cardsWithAttachments[parentId] + 1)
|
||||||
for i = #attachmentList, 1, -1 do
|
for i = #attachmentList, 1, -1 do
|
||||||
for j = #cardsToSpawn, 1, -1 do
|
for j = #cardsToSpawn, 1, -1 do
|
||||||
if cardsToSpawn[j].metadata.id == attachmentList[i] and cardsToSpawn[j].zone ~= "BelowSetAside" then
|
if cardsToSpawn[j].metadata.id == attachmentList[i] and cardsToSpawn[j].zone ~= zone then
|
||||||
cardsToSpawn[j].zone = "BelowSetAside"
|
cardsToSpawn[j].zone = zone
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user