add number typing handling

This commit is contained in:
Chr1Z93 2024-01-09 14:25:22 +01:00
parent bf1b9c82b5
commit 3beb85d633
2 changed files with 43 additions and 0 deletions

View File

@ -200,6 +200,40 @@ function onObjectEnterZone(zone, enteringObj)
end
end
-- handle card drawing via number typing for multihanded gameplay
-- (and additionally allow Norman Withers to draw multiple cards via number)
function onObjectNumberTyped(hoveredObject, playerColor, number)
-- only continue for decks or cards
if hoveredObject.type ~= "Deck" and hoveredObject.type ~= "Card" then return end
-- get playmat colors with an investigator card
local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }
local matColors = { "White", "Orange", "Green", "Red" }
local legalColors = {}
for _, color in ipairs(matColors) do
local mat = guidReferenceApi.getObjectByOwnerAndType(color, "Playermat")
if mat ~= nil then
local searchPos = mat.positionToWorld(localInvestigatorPosition)
local searchResult = searchLib.atPosition(searchPos, "isCardOrDeck")
if #searchResult > 0 then
table.insert(legalColors, color)
end
end
end
if #legalColors == 0 then return end
-- check whether the hovered object is part of a players draw objects
for _, color in ipairs(legalColors) do
local deckAreaObjects = playmatApi.getDeckAreaObjects(color)
if deckAreaObjects.topCard == hoveredObject or deckAreaObjects.draw == hoveredObject then
playmatApi.drawCardsWithReshuffle(color, number)
return true
end
end
end
---------------------------------------------------------
-- chaos token drawing
---------------------------------------------------------

View File

@ -180,6 +180,15 @@ do
end
end
-- triggers the draw function for the specified playmat
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param number Number Amount of cards to draw
PlaymatApi.drawCardsWithReshuffle = function(matColor, number)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("drawCardsWithReshuffle", number)
end
end
-- returns the resource counter amount
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
---@param type String Counter to target