From 695ad9fd1421f670bd5e3294e161b4321d3820f7 Mon Sep 17 00:00:00 2001 From: Buhallin Date: Thu, 24 Nov 2022 14:25:15 -0800 Subject: [PATCH 1/2] Add handling for cards to start in a player's hand Currently for Diana's Dark Insight, this add generalized handling to move a card to the player's hand on deck creation. --- .../DarkInsight.f08934.gmnotes | 1 + src/arkhamdb/DeckImporterMain.ttslua | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes b/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes index eeaf1bd3..6a4768dc 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", + "startsInPlay": true, "cost": 2, "traits": "Insight.", "cycle": "The Circle Undone" diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 738f131b..4c789624 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -373,7 +373,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 @@ -385,14 +385,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 @@ -430,6 +432,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 From 27f052231fdf1a0bd40d6ffd474a9011c412d9a5 Mon Sep 17 00:00:00 2001 From: Buhallin Date: Thu, 24 Nov 2022 14:27:47 -0800 Subject: [PATCH 2/2] Give Dark Insight the right starts* field value --- objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes b/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes index 6a4768dc..3b2202b6 100644 --- a/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes +++ b/objects/AllPlayerCards.15bb07/DarkInsight.f08934.gmnotes @@ -2,7 +2,7 @@ "id": "05014", "type": "Event", "class": "Neutral", - "startsInPlay": true, + "startsInHand": true, "cost": 2, "traits": "Insight.", "cycle": "The Circle Undone"