Merge pull request #788 from argonui/search-assistant
Updated topcard handling
This commit is contained in:
commit
367d48cadb
@ -113,11 +113,25 @@ function startSearch(messageColor, number)
|
|||||||
|
|
||||||
-- get draw deck
|
-- get draw deck
|
||||||
local deckAreaObjects = playermatApi.getDeckAreaObjects(matColor)
|
local deckAreaObjects = playermatApi.getDeckAreaObjects(matColor)
|
||||||
if deckAreaObjects.draw == nil then
|
if deckAreaObjects.draw == nil and deckAreaObjects.topCard == nil then
|
||||||
printToColor(matColor .. " draw deck could not be found!", messageColor, "Red")
|
printToColor(matColor .. " draw deck could not be found!", messageColor, "Red")
|
||||||
return
|
return
|
||||||
end
|
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
|
-- get bounds to know the height of the deck
|
||||||
local bounds = deckAreaObjects.draw.getBounds()
|
local bounds = deckAreaObjects.draw.getBounds()
|
||||||
drawDeckPosition = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)
|
drawDeckPosition = bounds.center + Vector(0, bounds.size.y / 2 + 0.2, 0)
|
||||||
@ -158,16 +172,21 @@ function startSearch(messageColor, number)
|
|||||||
|
|
||||||
-- handling for Norman Withers
|
-- handling for Norman Withers
|
||||||
if deckAreaObjects.topCard then
|
if deckAreaObjects.topCard then
|
||||||
deckAreaObjects.topCard.setRotation(setAsideRotation)
|
deckAreaObjects.topCard.deal(1, handColor)
|
||||||
|
number = number - 1
|
||||||
topCardDetected = true
|
topCardDetected = true
|
||||||
end
|
end
|
||||||
|
|
||||||
searchView()
|
searchView()
|
||||||
|
|
||||||
Wait.time(function()
|
if number > 0 then
|
||||||
deckAreaObjects = playermatApi.getDeckAreaObjects(matColor)
|
|
||||||
deckAreaObjects.draw.deal(number, handColor)
|
deckAreaObjects.draw.deal(number, handColor)
|
||||||
end, 1)
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function isHarbinger(notes)
|
||||||
|
local md = JSON.decode(notes or "") or {}
|
||||||
|
return md.id == "08006"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- place handCards back into deck and optionally shuffle
|
-- place handCards back into deck and optionally shuffle
|
||||||
|
@ -258,7 +258,7 @@ function onObjectNumberTyped(hoveredObject, playerColor, number)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- check whether the hovered object is part of a players draw objects
|
-- check whether the hovered object is part of a players draw objects
|
||||||
for _, color in ipairs(playermatApi.getUsedMatColors()) do
|
for color, _ in pairs(guidReferenceApi.getObjectsByType("Playermat")) do
|
||||||
local deckAreaObjects = playermatApi.getDeckAreaObjects(color)
|
local deckAreaObjects = playermatApi.getDeckAreaObjects(color)
|
||||||
if deckAreaObjects.topCard == hoveredObject or deckAreaObjects.draw == hoveredObject then
|
if deckAreaObjects.topCard == hoveredObject or deckAreaObjects.draw == hoveredObject then
|
||||||
playermatApi.drawCardsWithReshuffle(color, number)
|
playermatApi.drawCardsWithReshuffle(color, number)
|
||||||
|
@ -438,14 +438,12 @@ function drawCardsWithReshuffle(numCards)
|
|||||||
local deckAreaObjects = getDeckAreaObjects()
|
local deckAreaObjects = getDeckAreaObjects()
|
||||||
|
|
||||||
-- Norman Withers handling
|
-- Norman Withers handling
|
||||||
local harbinger = false
|
local harbinger
|
||||||
if deckAreaObjects.topCard and deckAreaObjects.topCard.getName() == "The Harbinger" then
|
if deckAreaObjects.topCard then
|
||||||
harbinger = true
|
harbinger = isHarbinger(deckAreaObjects.topCard.getGMNotes())
|
||||||
elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then
|
elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then
|
||||||
local cards = deckAreaObjects.draw.getObjects()
|
local cards = deckAreaObjects.draw.getObjects()
|
||||||
if cards[#cards].name == "The Harbinger" then
|
harbinger = isHarbinger(cards[#cards].gm_notes)
|
||||||
harbinger = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if harbinger then
|
if harbinger then
|
||||||
@ -473,8 +471,7 @@ function drawCardsWithReshuffle(numCards)
|
|||||||
|
|
||||||
if deckSize >= numCards then
|
if deckSize >= numCards then
|
||||||
drawCards(numCards)
|
drawCards(numCards)
|
||||||
-- flip top card again for Norman
|
if topCardDetected then
|
||||||
if topCardDetected and string.match(activeInvestigatorId, "%d%d%d%d%d") == "08004" then
|
|
||||||
flipTopCardFromDeck()
|
flipTopCardFromDeck()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -483,8 +480,7 @@ function drawCardsWithReshuffle(numCards)
|
|||||||
shuffleDiscardIntoDeck()
|
shuffleDiscardIntoDeck()
|
||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
drawCards(numCards - deckSize)
|
drawCards(numCards - deckSize)
|
||||||
-- flip top card again for Norman
|
if topCardDetected then
|
||||||
if topCardDetected and string.match(activeInvestigatorId, "%d%d%d%d%d") == "08004" then
|
|
||||||
flipTopCardFromDeck()
|
flipTopCardFromDeck()
|
||||||
end
|
end
|
||||||
end, 1)
|
end, 1)
|
||||||
@ -493,6 +489,11 @@ function drawCardsWithReshuffle(numCards)
|
|||||||
end
|
end
|
||||||
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
|
-- get the draw deck and discard pile objects and returns the references
|
||||||
---@return table: string-indexed table with references to the found objects
|
---@return table: string-indexed table with references to the found objects
|
||||||
function getDeckAreaObjects()
|
function getDeckAreaObjects()
|
||||||
|
Loading…
Reference in New Issue
Block a user