diff --git a/src/accessories/SearchAssistant.ttslua b/src/accessories/SearchAssistant.ttslua index 4830ba4b..67bbdbf5 100644 --- a/src/accessories/SearchAssistant.ttslua +++ b/src/accessories/SearchAssistant.ttslua @@ -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() diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index e3ad7862..e65568b1 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -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()