diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 738f131b..da00092d 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -32,6 +32,8 @@ customizationRowsWithFields["09101"].inputMap[1] = 1 customizationRowsWithFields["09101"].inputMap[2] = 2 customizationRowsWithFields["09101"].inputMap[3] = 3 +local PLAY_AREA_GUID = "721ba2" + local RANDOM_WEAKNESS_ID = "01000" local tags = { configuration = "import_configuration_provider" } local Priority = { @@ -149,6 +151,7 @@ local function onDeckResult(deck, playerColor, configuration) maybeAddInvestigatorCards(deck, slots) maybeAddCustomizeUpgradeSheets(slots, configuration) maybeAddSummonedServitor(slots) + maybeAddOnTheMend(slots) extractBondedCards(slots, 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 -- of those cards which will be spawned function maybeAddSummonedServitor(slots) - for cardId, cardCount in pairs(slots) do - -- spawn additional minicard for 'Summoned Servitor' - if cardId == "09080" then - slots["09080-m"] = 1 - return + if slots["09080"] ~= nil then + slots["09080-m"] = 1 + end +end + +-- 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 @@ -308,6 +320,8 @@ end function getDefaultCardZone(cardMetadata) if (cardMetadata.id == "09080-m") then -- Have to check the Servitor before other minicards return "SetAside6" + elseif (cardMetadata.id == "09006") then -- On The Mend is set aside + return "SetAside2" elseif cardMetadata.type == "Investigator" then return "Investigator" elseif cardMetadata.type == "Minicard" then diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 2ad7fdd3..503cc145 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -8,7 +8,7 @@ DEBUG = false -- we use this to turn off collision handling until onLoad() is complete COLLISION_ENABLED = false -local COUNTER = getObjectFromGUID('f182ee') +local INVESTIGATOR_COUNTER_GUID = "f182ee" local clueData = {} spawnedLocationGUIDs = {} @@ -76,7 +76,7 @@ function spawnCluesAtLocation(clueCount, object) end 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 spawnedLocationGUIDs[object.getGUID()] = true @@ -117,7 +117,12 @@ function onCollisionEnter(collision_info) -- check if we should spawn clues here and do so according to playercount local object = collision_info.collision_object 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 end end + +function getInvestigatorCount() + local investigatorCounter = getObjectFromGUID('f182ee') + return investigatorCounter.getVar("val") +end