harbinger handling

This commit is contained in:
Chr1Z93 2024-08-01 19:41:29 +02:00
parent 4594629d5e
commit c88fb47647
2 changed files with 28 additions and 6 deletions

View File

@ -118,6 +118,20 @@ function startSearch(messageColor, number)
return
end
-- check for harbinger
local harbinger
if deckAreaObjects.topCard then
harbinger = isHarbinger(deckAreaObjects.topCard.getGMNotes())
elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then
local cards = deckAreaObjects.draw.getObjects()
harbinger = isHarbinger(cards[#cards].gm_notes)
end
if harbinger then
printToColor("The Harbinger is on top of your deck, searching isn't allowed", messageColor)
return
end
-- get bounds to know the height of the deck
local bounds = deckAreaObjects.draw.getBounds()
drawDeckPosition = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)
@ -170,6 +184,11 @@ function startSearch(messageColor, number)
end
end
function isHarbinger(notes)
local md = JSON.decode(notes or "") or {}
return md.id == "08006"
end
-- place handCards back into deck and optionally shuffle
function endSearch(_, _, isRightClick)
local handCards = Player[handColor].getHandObjects()

View File

@ -438,14 +438,12 @@ function drawCardsWithReshuffle(numCards)
local deckAreaObjects = getDeckAreaObjects()
-- Norman Withers handling
local harbinger = false
if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == "The Harbinger" then
harbinger = true
local harbinger
if deckAreaObjects.topCard then
harbinger = isHarbinger(deckAreaObjects.topCard.getGMNotes())
elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then
local cards = deckAreaObjects.draw.getObjects()
if cards[#cards].name == "The Harbinger" then
harbinger = true
end
harbinger = isHarbinger(cards[#cards].gm_notes)
end
if harbinger then
@ -491,6 +489,11 @@ function drawCardsWithReshuffle(numCards)
end
end
function isHarbinger(notes)
local md = JSON.decode(notes or "") or {}
return md.id == "08006"
end
-- get the draw deck and discard pile objects and returns the references
---@return table: string-indexed table with references to the found objects
function getDeckAreaObjects()