diff --git a/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes b/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes index eeaf1bd3..3b2202b6 100644 --- a/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes +++ b/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes @@ -2,6 +2,7 @@ "id": "05014", "type": "Event", "class": "Neutral", + "startsInHand": true, "cost": 2, "traits": "Insight.", "cycle": "The Circle Undone" diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index da00092d..b2daa7f1 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -387,7 +387,7 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa local deckPos = Zones.getZonePosition(playerColor, zone) deckPos.y = 3 - local spreadCallback = nil + local callback = nil -- 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 local spreadDistance = 1.15 @@ -399,14 +399,16 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa elseif (playerColor == "Green") then deckPos.x = deckPos.x + (#zoneCards - 1) * spreadDistance end - spreadCallback = function(deck) deck.spread(spreadDistance) end + callback = function(deck) deck.spread(spreadDistance) end + elseif zone == "Deck" then + callback = function(deck) deckSpawned(deck, playerColor) end end Spawner.spawnCards( zoneCards, deckPos, Zones.getDefaultCardRotation(playerColor, zone), true, -- Sort deck - spreadCallback) + callback) coroutine.yield(0) end @@ -444,6 +446,22 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa startLuaCoroutine(self, "coinside") end +-- Callback handler for the main deck spawning. Looks for cards which should start in hand, and +-- draws them for the appropriate player. +-- @param deck Callback-provided spawned deck object +-- @param playerColor Color of the player to draw the cards to +function deckSpawned(deck, playerColor) + local handPos = Player[playerColor].getHandTransform(1).position -- Only one hand zone per player + local deckCards = deck.getData().ContainedObjects + -- Process in reverse order so taking cards out doesn't upset the indexing + for i = #deckCards, 1, -1 do + local cardMetadata = JSON.decode(deckCards[i].GMNotes) or { } + if cardMetadata.startsInHand then + deck.takeObject({ index = i - 1, position = handPos, flip = true, smooth = true}) + end + end +end + -- Conver the Raven Quill's selections from card IDs to card names. This could be more elegant -- but the inputs are very static so we're using some brute force. -- @param An ArkhamDB string indicating the customization selections for The Raven's Quill. Should