part of switching to tags

This commit is contained in:
Chr1Z93 2023-10-02 02:05:00 +02:00
parent da63663ef2
commit de61831956
23 changed files with 104 additions and 120 deletions

View File

@ -163,7 +163,7 @@ function createCampaignFromToken(importData)
Wait.time(function() optionPanelApi.loadSettings(importData["options"]) end, 0.5)
-- destroy Tour Starter token
Global.call("getObjectFromMemo", { matColor = "Mythos", type = "TourStarter" }).destruct()
getObjectsWithTag("TourStarter")[1].destruct()
-- restore PlayArea image
playAreaApi.updateSurface(importData["playmat"])

View File

@ -143,7 +143,7 @@ end
-- reset doom on agenda
function resetDoomCounter()
local doomCounter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DoomCounter"})
local doomCounter = getObjectsWithTag("DoomCounter")[1]
if doomCounter ~= nil then
doomCounter.call("updateVal")
else
@ -228,7 +228,7 @@ end
function discardHands()
if not options["tidyPlayermats"] then return end
for i = 1, 4 do
local trash = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Trash"})
local trash = getObjectsWithAllTags({COLORS[i], "Trash"})
if trash == nil then return end
local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects()
for j = #hand, 1, -1 do
@ -239,8 +239,8 @@ end
-- clean up for play area
function tidyPlayareaCoroutine()
local trash = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"})
local playAreaZone = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"})
local trash = getObjectsWithAllTags({"Mythos", "Trash"})
local playAreaZone = getObjectsWithTag("PlayAreaZone")[1]
if playAreaZone == nil then
printToAll("Scripting zone for main play area could not be found!", "Red")
@ -270,7 +270,7 @@ function tidyPlayerMatCoroutine()
for k = 1, 30 do coroutine.yield(0) end
-- get respective trash
local trash = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Trash"})
local trash = getObjectsWithAllTags({COLORS[i], "Trash"})
if trash == nil then
printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red")
return 1
@ -300,7 +300,7 @@ function tidyPlayerMatCoroutine()
-- reset "activeInvestigatorId"
if i < 5 then
local playermat = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Playermat"})
local playermat = getObjectsWithAllTags({COLORS[i], "Playermat"})
if playermat then
playermat.setVar("activeInvestigatorId", "00000")
end
@ -308,7 +308,7 @@ function tidyPlayerMatCoroutine()
end
end
local datahelper = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"})
local datahelper = getObjectsWithTag("DataHelper")[1]
if datahelper then
datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {})
end

View File

@ -5,7 +5,7 @@ do
---@param functionName String Name of the function to cal
---@param argument Variant Parameter to pass
local function callIfExistent(functionName, argument)
local tokenArranger = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenArranger"})
local tokenArranger = getObjectsWithTag("TokenArranger")[1]
if tokenArranger ~= nil then
tokenArranger.call(functionName, argument)
end

View File

@ -13,7 +13,7 @@ do
-- investigators: True if investigator cards should be spawned
DeckImporterApi.getUiState = function()
local passthroughTable = {}
local DeckImporter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DeckImporter"})
local DeckImporter = getObjectsWithTag("DeckImporter")[1]
for k,v in pairs(DeckImporter.call("getUiState")) do
passthroughTable[k] = v
end
@ -31,7 +31,7 @@ do
-- loadNewest: True if the most upgraded version of the deck should be loaded
-- investigators: True if investigator cards should be spawned
DeckImporterApi.setUiState = function(uiStateTable)
local DeckImporter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DeckImporter"})
local DeckImporter = getObjectsWithTag("DeckImporter")[1]
return DeckImporter.call("setUiState", uiStateTable)
end

View File

@ -3,7 +3,7 @@ do
local internal = {}
internal.getManager = function()
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"})
return getObjectsWithTag("BlessCurseManager")[1]
end
-- removes all taken tokens and resets the counts

View File

@ -64,7 +64,7 @@ function startReset()
if options.Agenda then
updateVal(0)
end
local DoomInPlayCounter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DoomInPlayCounter"})
local DoomInPlayCounter = getObjectsWithTag("DoomInPlayCounter")[1]
if DoomInPlayCounter then
DoomInPlayCounter.call("removeDoom", options)
end

View File

@ -29,8 +29,8 @@ function onLoad()
color = { 0, 0, 0, 0 }
})
TRASH = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "Trash" })
ZONE = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "PlayAreaZone" })
TRASH = getObjectsWithAllTags({"Mythos", "Trash"})
ZONE = getObjectsWithAllTags({"Mythos", "PlayAreaZone" })
loopID = Wait.time(countDoom, 2, -1)
end

View File

@ -41,7 +41,7 @@ end
-- adds 1 doom to the agenda
function addDoomToAgenda()
getObjectFromMemo({matColor = "Mythos", type = "DoomCounter"}).call("addVal", 1)
getObjectsWithTag("DoomCounter")[1].call("addVal", 1)
end
-- moves the hovered card to the victory display

View File

@ -127,7 +127,7 @@ function onLoad(savedData)
if obj ~= nil then obj.interactable = false end
end
DATA_HELPER = getObjectFromMemo({matColor = "Mythos", type = "DataHelper"})
DATA_HELPER = getObjectsWithTag("DataHelper")[1]
resetChaosTokenStatTracker()
getModVersion()
math.randomseed(os.time())
@ -161,24 +161,6 @@ function tryObjectEnterContainer(container, object)
return true
end
-- gets the first object that matches the provided information
---@param searchParam Table Contains matColor and type to search for
function getObjectFromMemo(searchParam)
local matColor = searchParam.matColor
local type = searchParam.type
if matColor == nil or type == nil then return nil end
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo and memo:sub(1, 1) == "{" then
local decoded = JSON.decode(memo) or {}
if decoded.matColor == matColor and decoded.type == type then
return obj
end
end
end
return nil
end
-- gets all objects that match the provided matcolor
---@param matColor String Color of the playermat
---@return objList Table Table of type-object pairs
@ -196,23 +178,6 @@ function getObjectsForMatColor(matColor)
return objList
end
-- gets all objects that match the provided type, sorted by owner
---@param type String Object to look for (usually name without spaces)
---@return objList Table Table of matColor-object pairs
function getObjectsForType(type)
local objList = {}
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo and memo:sub(1, 1) == "{" then
local decoded = JSON.decode(memo) or {}
if decoded.type == type then
objList[decoded.matColor] = obj
end
end
end
return objList
end
---------------------------------------------------------
-- chaos token drawing
---------------------------------------------------------
@ -992,7 +957,7 @@ end
---@param rotation Table Desired rotation of the object (defaults to object's rotation)
---@param color String Matcolor this object is spawned for to set memo
function spawnHelperObject(name, position, rotation, color)
local sourceBag = getObjectFromMemo({matColor = "Mythos", type = "OptionPanelSource"})
local sourceBag = getObjectsWithTag("OptionPanelSource")[1]
-- error handling for missing sourceBag
if not sourceBag then

View File

@ -20,7 +20,8 @@ local isReshuffling = false
-- scenario metadata
local currentScenario, useFrontData, tokenData
local TRASHCAN, DATA_HELPER
-- object references
local TRASH, DATA_HELPER
-- we use this to turn off collision handling until onLoad() is complete
local collisionEnabled = false
@ -32,8 +33,8 @@ function onLoad(saveState)
useFrontData = loadedState.useFrontData or true
tokenData = loadedState.tokenData or {}
end
TRASHCAN = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"})
DATA_HELPER = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"})
TRASH = getObjectsWithAllTags({"Mythos", "Trash"})
DATA_HELPER = getObjectsWithTag("DataHelper")[1]
collisionEnabled = true
end
@ -206,7 +207,7 @@ function removeTokensFromObject(object)
obj.memo ~= nil and
obj.getLock() == false and
not tokenChecker.isChaosToken(obj) then
TRASHCAN.putObject(obj)
TRASH.putObject(obj)
end
end
end

View File

@ -3,13 +3,13 @@ do
-- returns the chaos token metadata (if provided through scenario reference card)
MythosAreaApi.returnTokenData = function()
local MythosArea = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "MythosArea"})
local MythosArea = getObjectsWithTag("MythosArea")[1]
return MythosArea.call("returnTokenData")
end
-- draw an encounter card to the requested position/rotation
MythosAreaApi.drawEncounterCard = function(pos, rotY, alwaysFaceUp)
local MythosArea = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "MythosArea"})
local MythosArea = getObjectsWithTag("MythosArea")[1]
MythosArea.call("drawEncounterCard", {
pos = pos,
rotY = rotY,

View File

@ -5,7 +5,7 @@ do
---@param startColor String Color of the player to copy from
---@param targetColor String Color of the targeted player
NavigationOverlayApi.copyVisibility = function(startColor, targetColor)
local handler = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "NavigationOverlayHandler"})
local handler = getObjectsWithTag("NavigationOverlayHandler")[1]
handler.call("copyVisibility", {
startColor = startColor,
targetColor = targetColor
@ -15,7 +15,7 @@ do
-- Changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.)
---@param playerColor String Color of the player to update the visibility for
NavigationOverlayApi.cycleVisibility = function(playerColor)
local handler = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "NavigationOverlayHandler"})
local handler = getObjectsWithTag("NavigationOverlayHandler")[1]
handler.call("cycleVisibility", playerColor)
end

View File

@ -506,7 +506,7 @@ function shiftContentsRight(playerColor)
end
function shiftContents(playerColor, direction)
local zone = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"})
local zone = getObjectsWithTag("PlayAreaZone")[1]
if not zone then
broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red")
return

View File

@ -3,19 +3,19 @@ do
local internal = {}
internal.getPlayArea = function()
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"})
return getObjectsWithTag("PlayArea")[1]
end
-- Returns the current value of the investigator counter from the playmat
---@return Integer. Number of investigators currently set on the counter
PlayAreaApi.getInvestigatorCount = function()
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "InvestigatorCounter"}).getVar("val")
return getObjectsWithTag("InvestigatorCounter")[1].getVar("val")
end
-- Updates the current value of the investigator counter from the playmat
---@param count Number of investigators to set on the counter
PlayAreaApi.setInvestigatorCount = function(count)
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "InvestigatorCounter"}).call("updateVal", count)
return getObjectsWithTag("InvestigatorCounter")[1].call("updateVal", count)
end
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain

View File

@ -9,7 +9,7 @@ do
}
local function playTriggerEffect(index)
local SoundCube = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "SoundCube"})
local SoundCube = getObjectsWithTag("SoundCube")[1]
SoundCube.AssetBundle.playTriggerEffect(index)
end

View File

@ -10,11 +10,11 @@ local countedVP = {}
local highlightMissing = false
local highlightCounted = false
local TRASHCAN
local TRASH
-- button creation when loading the game
function onLoad()
TRASHCAN = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"})
TRASH = getObjectsWithAllTags({"Mythos", "Trash"})
-- index 0: VP - "Display"
local buttonParameters = {}
@ -282,7 +282,7 @@ function placeCard(card)
local chaosBag = chaosBagApi.findChaosBag()
chaosBag.putObject(obj)
elseif obj.memo ~= nil and obj.getLock() == false then
TRASHCAN.putObject(obj)
TRASH.putObject(obj)
end
end

View File

@ -4,7 +4,7 @@ do
-- triggers an update of the Victory count
---@param delay Number Delay in seconds after which the update call is executed
VictoryDisplayApi.update = function(delay)
local VictoryDisplay = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "VictoryDisplay"})
local VictoryDisplay = getObjectsWithTag("VictoryDisplay")[1]
VictoryDisplay.call("startUpdate", delay)
end
@ -12,7 +12,7 @@ do
---@param object Object Object that should be checked and potentially moved
VictoryDisplayApi.placeCard = function(object)
if object ~= nil and object.tag == "Card" then
local VictoryDisplay = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "VictoryDisplay"})
local VictoryDisplay = getObjectsWithTag("VictoryDisplay")[1]
VictoryDisplay.call("placeCard", object)
end
end

View File

@ -335,7 +335,7 @@ do
return
end
tokenTemplates = { }
local tokenSource = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenSource"})
local tokenSource = getObjectsWithTag("TokenSource")[1]
for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do
local tokenName = tokenTemplate.Memo
tokenTemplates[tokenName] = tokenTemplate
@ -347,7 +347,7 @@ do
if playerCardData ~= nil then
return
end
local dataHelper = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"})
local dataHelper = getObjectsWithTag("DataHelper")[1]
playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')
locationData = dataHelper.getTable('LOCATIONS_DATA')
end

View File

@ -3,7 +3,7 @@ do
local internal = {}
internal.getSpawnTracker = function()
return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenSpawnTracker"})
return getObjectsWithTag("TokenSpawnTracker")[1]
end
TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)

View File

@ -1,5 +1,10 @@
do
local AllCardsBagApi = {}
local internal = {}
internal.getAllCardsBag = function()
return getObjectsWithTag("AllCardsBag")[1]
end
-- Returns a specific card from the bag, based on ArkhamDB ID
---@param id table String ID of the card to retrieve
@ -9,8 +14,7 @@ do
-- cardData: TTS object data, suitable for spawning the card
-- cardMetadata: Table of parsed metadata
AllCardsBagApi.getCardById = function(id)
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("getCardById", {id = id})
internal.getAllCardsBag().call("getCardById", {id = id})
end
-- Gets a random basic weakness from the bag. Once a given ID has been returned
@ -19,13 +23,11 @@ do
-- weaknesses.
---@return id String ID of the selected weakness.
AllCardsBagApi.getRandomWeaknessId = function()
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("getRandomWeaknessId")
internal.getAllCardsBag().call("getRandomWeaknessId")
end
AllCardsBagApi.isIndexReady = function()
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("isIndexReady")
internal.getAllCardsBag().call("isIndexReady")
end
-- Called by Hotfix bags when they load. If we are still loading indexes, then
@ -34,8 +36,7 @@ do
-- called once indexing is complete it means the hotfix bag has been added
-- later, and we should rebuild the index to integrate the hotfix bag.
AllCardsBagApi.rebuildIndexForHotfix = function()
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("rebuildIndexForHotfix")
internal.getAllCardsBag().call("rebuildIndexForHotfix")
end
-- Searches the bag for cards which match the given name and returns a list. Note that this is
@ -43,13 +44,11 @@ do
---@param name String or string fragment to search for names
---@param exact Boolean Whether the name match should be exact
AllCardsBagApi.getCardsByName = function(name, exact)
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("getCardsByName", {name = name, exact = exact})
internal.getAllCardsBag().call("getCardsByName", {name = name, exact = exact})
end
AllCardsBagApi.isBagPresent = function()
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag and true
internal.getAllCardsBag() and true
end
-- Returns a list of cards from the bag matching a class and level (0 or upgraded)
@ -60,18 +59,15 @@ do
-- cardData: TTS object data, suitable for spawning the card
-- cardMetadata: Table of parsed metadata
AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("getCardsByClassAndLevel", {class = class, upgraded = upgraded})
internal.getAllCardsBag().call("getCardsByClassAndLevel", {class = class, upgraded = upgraded})
end
AllCardsBagApi.getCardsByCycle = function(cycle)
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("getCardsByCycle", cycle)
internal.getAllCardsBag().call("getCardsByCycle", cycle)
end
AllCardsBagApi.getUniqueWeaknesses = function()
local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"})
return AllCardsBag.call("getUniqueWeaknesses")
internal.getAllCardsBag().call("getUniqueWeaknesses")
end
return AllCardsBagApi

View File

@ -23,7 +23,7 @@ function onLoad()
})
-- set MATCOLOR based on memo
MATCOLOR = JSON.decode(self.getMemo()).matColor
TRASH = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "Trash"})
TRASH = getObjectsWithAllTags({MATCOLOR, "Trash"})
loopID = Wait.time(countItems, 1, -1)
end

View File

@ -103,7 +103,7 @@ function onLoad(saveState)
self.interactable = DEBUG
-- get object references to owned objects
ownedObjects = Global.call("getObjectsForMatColor", matColor)
getOwnedObjects()
-- button creation
for i = 1, 6 do
@ -152,6 +152,13 @@ function onLoad(saveState)
math.randomseed(os.time())
end
function getOwnedObjects()
local objList = getObjectsWithTag(matColor)
for _, obj in ipairs(objList) do
end
end
---------------------------------------------------------
-- utility functions
---------------------------------------------------------

View File

@ -6,11 +6,18 @@ do
---@param startPos Table Starting position to get the closest mat from
PlaymatApi.getMatColorByPosition = function(startPos)
local result, smallestDistance
for matColor, mat in pairs(internal.getMatForColor("All")) do
for _, mat in ipairs(internal.getMatForColor("All")) do
local distance = Vector.between(startPos, mat.getPosition()):magnitude()
if smallestDistance == nil or distance < smallestDistance then
smallestDistance = distance
result = matColor
for _, tag in ipairs(mat.getTags) do
if tag == "White"
or tag == "Orange"
or tag == "Green"
or tag == "Red" then
result = tag
end
end
end
end
return result
@ -19,7 +26,7 @@ do
-- Returns the color of the player's hand that is seated next to the playmat
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.getPlayerColor = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
return mat.getVar("playerColor")
end
end
@ -27,17 +34,25 @@ do
-- Returns the color of the playmat that owns the playercolor's hand
---@param handColor String Color of the playmat
PlaymatApi.getMatColor = function(handColor)
for matColor, mat in pairs(internal.getMatForColor("All")) do
for _, mat in ipairs(internal.getMatForColor("All")) do
local playerColor = mat.getVar("playerColor")
if playerColor == handColor then return matColor end
if playerColor == handColor then
for _, tag in ipairs(mat.getTags) do
if tag == "White"
or tag == "Orange"
or tag == "Green"
or tag == "Red" then
return tag
end
end
end
end
return "NOT_FOUND"
end
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.isDES = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
return mat.getVar("isDES")
end
end
@ -45,7 +60,7 @@ do
-- Returns the draw deck of the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.getDrawDeck = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("getDrawDiscardDecks")
return mat.getVar("drawDeck")
end
@ -54,7 +69,7 @@ do
-- Returns the position of the discard pile of the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.getDiscardPosition = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
return mat.call("returnGlobalDiscardPosition")
end
end
@ -63,7 +78,7 @@ do
---@param localPos Table Local position to be transformed
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.transformLocalPosition = function(localPos, matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
return mat.positionToWorld(localPos)
end
end
@ -71,7 +86,7 @@ do
-- Returns the rotation of the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.returnRotation = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
return mat.getRotation()
end
end
@ -80,7 +95,7 @@ do
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param playerColor String Color of the calling player (for messages)
PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("doUpkeepFromHotkey", playerColor)
end
end
@ -88,7 +103,7 @@ do
-- Returns the active investigator id
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.returnInvestigatorId = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
return mat.getVar("activeInvestigatorId")
end
end
@ -100,7 +115,7 @@ do
---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("setLimitSnapsByType", matchCardTypes)
end
end
@ -109,7 +124,7 @@ do
---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("showDrawButton", isDrawButtonVisible)
end
end
@ -118,7 +133,7 @@ do
---@param showCounter Boolean Whether the clickable counter should be present or not
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.clickableClues = function(showCounter, matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("clickableClues", showCounter)
end
end
@ -126,7 +141,7 @@ do
-- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.removeClues = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("removeClues")
end
end
@ -135,7 +150,7 @@ do
---@param useClickableCounters Boolean Controls which type of counter is getting checked
PlaymatApi.getClueCount = function(useClickableCounters, matColor)
local count = 0
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
count = count + mat.call("getClueCount", useClickableCounters)
end
return count
@ -147,7 +162,7 @@ do
---@param newValue Number Value to set the counter to
---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier
PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("updateCounter", {type = type, newValue = newValue, modifier = modifier})
end
end
@ -156,7 +171,7 @@ do
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
---@param type String Counter to target
PlaymatApi.getCounterValue = function(matColor, type)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
return mat.call("getCounterValue", type)
end
end
@ -164,7 +179,7 @@ do
-- resets the specified skill tracker to "1, 1, 1, 1"
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.resetSkillTracker = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("resetSkillTracker")
end
end
@ -174,7 +189,7 @@ do
---@param filter Function Optional filter function (return true for desired objects)
PlaymatApi.searchAroundPlaymat = function(matColor, filter)
local objList = {}
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
for _, obj in ipairs(mat.call("searchAroundSelf", filter)) do
table.insert(objList, obj)
end
@ -185,14 +200,14 @@ do
-- Discard a non-hidden card from the corresponding player's hand
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.doDiscardOne = function(matColor)
for _, mat in pairs(internal.getMatForColor(matColor)) do
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("doDiscardOne")
end
end
-- Triggers the metadata sync for all playmats
PlaymatApi.syncAllCustomizableCards = function()
for _, mat in pairs(internal.getMatForColor("All")) do
for _, mat in ipairs(internal.getMatForColor("All")) do
mat.call("syncAllCustomizableCards")
end
end
@ -202,9 +217,9 @@ do
---@return array Table Single-element if only single playmat is requested
internal.getMatForColor = function(matColor)
if matColor == "All" then
return Global.call("getObjectsForType", "Playermat")
return getObjectsWithTag("Playermat")
else
return {matColor = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) }
return {matColor = getObjectsWithAllTags({matColor, "Playermat"}) }
end
end