From 3c5d9e30703b7bd78e2d52dbfc8eb247cab3556a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 21 Oct 2023 12:47:29 +0200 Subject: [PATCH] added topcard flipping --- src/accessories/SearchAssistant.ttslua | 12 +++++++++++- src/playermat/Playmat.ttslua | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/accessories/SearchAssistant.ttslua b/src/accessories/SearchAssistant.ttslua index e1f305c4..36382e5d 100644 --- a/src/accessories/SearchAssistant.ttslua +++ b/src/accessories/SearchAssistant.ttslua @@ -1,7 +1,7 @@ local playmatApi = require("playermat/PlaymatApi") -- forward declaration of variables that are used across functions -local matColor, handColor, setAsidePosition, setAsideRotation, drawDeckPosition +local matColor, handColor, setAsidePosition, setAsideRotation, drawDeckPosition, topCardDetected local quickParameters = {} quickParameters.function_owner = self @@ -101,6 +101,7 @@ end function startSearch(messageColor, number) matColor = playmatApi.getMatColorByPosition(self.getPosition()) handColor = playmatApi.getPlayerColor(matColor) + topCardDetected = false -- get draw deck local drawDeck = playmatApi.getDrawDeck(matColor) @@ -134,6 +135,7 @@ function startSearch(messageColor, number) local object = v.hit_object if object.tag == "Card" and not object.is_face_down then object.flip() + topCardDetected = true Wait.time(function() drawDeck = playmatApi.getDrawDeck(matColor) end, 1) break end @@ -177,6 +179,14 @@ function endSearch(_, _, isRightClick) end normalView() + + -- Norman Withers handling + if topCardDetected then + local deck = playmatApi.getDrawDeck(matColor) + if deck then + deck.takeObject({ position = deck.getPosition() + Vector(0, 1, 0), flip = true }) + end + end end -- utility function diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 1f62619b..5879362a 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -421,6 +421,7 @@ function drawCardsWithReshuffle(numCards) getDrawDiscardDecks() -- Norman Withers handling + local topCardDrawn = false if string.match(activeInvestigatorId, "%d%d%d%d%d") == "08004" then local harbinger = false if topCard ~= nil and topCard.getName() == "The Harbinger" then @@ -438,7 +439,8 @@ function drawCardsWithReshuffle(numCards) end if topCard ~= nil then - topCard.deal(numCards, playerColor) + topCard.deal(1, playerColor) + topCardDrawn = true numCards = numCards - 1 if numCards == 0 then return end end @@ -462,6 +464,14 @@ function drawCardsWithReshuffle(numCards) Wait.time(|| drawCards(numCards - deckSize), 1) end printToColor("Take 1 horror (drawing card from empty deck)", messageColor) + + -- more Norman Withers handling + if topCardDrawn then + getDrawDiscardDecks() + if drawDeck then + drawDeck.takeObject({ position = drawDeck.getPosition() + Vector(0, 1, 0), flip = true }) + end + end end -- get the draw deck and discard pile objects