Handle On the Mend when loading from ArkhamDB

Vincent Lee gets one copy of On the Mend per investigator, and they should start set aside.
This commit is contained in:
Buhallin 2022-11-24 11:58:57 -08:00
parent c5cceb6c3b
commit 0df51128e0
No known key found for this signature in database
GPG Key ID: DB3C362823852294
2 changed files with 26 additions and 8 deletions

View File

@ -32,6 +32,8 @@ customizationRowsWithFields["09101"].inputMap[1] = 1
customizationRowsWithFields["09101"].inputMap[2] = 2 customizationRowsWithFields["09101"].inputMap[2] = 2
customizationRowsWithFields["09101"].inputMap[3] = 3 customizationRowsWithFields["09101"].inputMap[3] = 3
local PLAY_AREA_GUID = "721ba2"
local RANDOM_WEAKNESS_ID = "01000" local RANDOM_WEAKNESS_ID = "01000"
local tags = { configuration = "import_configuration_provider" } local tags = { configuration = "import_configuration_provider" }
local Priority = { local Priority = {
@ -149,6 +151,7 @@ local function onDeckResult(deck, playerColor, configuration)
maybeAddInvestigatorCards(deck, slots) maybeAddInvestigatorCards(deck, slots)
maybeAddCustomizeUpgradeSheets(slots, configuration) maybeAddCustomizeUpgradeSheets(slots, configuration)
maybeAddSummonedServitor(slots) maybeAddSummonedServitor(slots)
maybeAddOnTheMend(slots)
extractBondedCards(slots, configuration) extractBondedCards(slots, configuration)
checkTaboos(deck.taboo_id, slots, playerColor, configuration) checkTaboos(deck.taboo_id, slots, playerColor, configuration)
@ -245,11 +248,20 @@ end
---@param slots: The slot list for cards in this deck. Table key is the cardId, value is the number ---@param slots: The slot list for cards in this deck. Table key is the cardId, value is the number
-- of those cards which will be spawned -- of those cards which will be spawned
function maybeAddSummonedServitor(slots) function maybeAddSummonedServitor(slots)
for cardId, cardCount in pairs(slots) do if slots["09080"] ~= nil then
-- spawn additional minicard for 'Summoned Servitor' slots["09080-m"] = 1
if cardId == "09080" then end
slots["09080-m"] = 1 end
return
-- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update
-- the count based on the investigator count
---@param slots: The slot list for cards in this deck. Table key is the cardId, value is the number
-- of those cards which will be spawned
function maybeAddOnTheMend(slots)
if slots["09006"] ~= nil then
local playArea = getObjectFromGUID(PLAY_AREA_GUID)
if playArea ~= nil then
slots["09006"] = playArea.call("getInvestigatorCount")
end end
end end
end end
@ -308,6 +320,8 @@ end
function getDefaultCardZone(cardMetadata) function getDefaultCardZone(cardMetadata)
if (cardMetadata.id == "09080-m") then -- Have to check the Servitor before other minicards if (cardMetadata.id == "09080-m") then -- Have to check the Servitor before other minicards
return "SetAside6" return "SetAside6"
elseif (cardMetadata.id == "09006") then -- On The Mend is set aside
return "SetAside2"
elseif cardMetadata.type == "Investigator" then elseif cardMetadata.type == "Investigator" then
return "Investigator" return "Investigator"
elseif cardMetadata.type == "Minicard" then elseif cardMetadata.type == "Minicard" then

View File

@ -8,7 +8,7 @@ DEBUG = false
-- we use this to turn off collision handling until onLoad() is complete -- we use this to turn off collision handling until onLoad() is complete
COLLISION_ENABLED = false COLLISION_ENABLED = false
local COUNTER = getObjectFromGUID('f182ee') local investigatorCounter = getObjectFromGUID('f182ee')
local clueData = {} local clueData = {}
spawnedLocationGUIDs = {} spawnedLocationGUIDs = {}
@ -76,7 +76,7 @@ function spawnCluesAtLocation(clueCount, object)
end end
log('spawning clues for ' .. object.getName() .. '_' .. object.getGUID()) log('spawning clues for ' .. object.getName() .. '_' .. object.getGUID())
log('player count is ' .. COUNTER.getVar('val') .. ', clue count is ' .. clueCount) log('player count is ' .. getInvestigatorCount() .. ', clue count is ' .. clueCount)
-- mark this location as spawned, can't happen again -- mark this location as spawned, can't happen again
spawnedLocationGUIDs[object.getGUID()] = true spawnedLocationGUIDs[object.getGUID()] = true
@ -117,7 +117,11 @@ function onCollisionEnter(collision_info)
-- check if we should spawn clues here and do so according to playercount -- check if we should spawn clues here and do so according to playercount
local object = collision_info.collision_object local object = collision_info.collision_object
if getLocation(object) ~= nil and spawnedLocationGUIDs[object.getGUID()] == nil then if getLocation(object) ~= nil and spawnedLocationGUIDs[object.getGUID()] == nil then
local clueCount = getClueCount(object, object.is_face_down, COUNTER.getVar('val')) local clueCount = getClueCount(object, object.is_face_down, getInvestigatorCount())
if clueCount > 0 then spawnCluesAtLocation(clueCount, object) end if clueCount > 0 then spawnCluesAtLocation(clueCount, object) end
end end
end end
function getInvestigatorCount()
return investigatorCounter.getVar("val")
end