turned cleanuphelper and playmatapi dynamic
This commit is contained in:
parent
2fd7656ab1
commit
a87b63516a
@ -15,39 +15,11 @@ local IGNORE_TAG = "CleanUpHelper_ignore"
|
|||||||
|
|
||||||
-- colors and order for following tables
|
-- colors and order for following tables
|
||||||
local COLORS = { "White", "Orange", "Green", "Red", "Mythos" }
|
local COLORS = { "White", "Orange", "Green", "Red", "Mythos" }
|
||||||
|
|
||||||
local campaignLog
|
local campaignLog
|
||||||
local RESET_VALUES = {}
|
local RESET_VALUES = {}
|
||||||
|
local loadingFailedBefore = false
|
||||||
-- values for physics.cast (4 entries for player zones, 5th entry for mythos area, 6th for campaign log)
|
|
||||||
local PHYSICS_POSITION = {
|
|
||||||
{ -54.5, 2, 21 },
|
|
||||||
{ -54.5, 2, -21 },
|
|
||||||
{ -27.0, 2, 26 },
|
|
||||||
{ -27.0, 2, -26 },
|
|
||||||
{ -02.0, 2, 10 },
|
|
||||||
{ -00.0, 2, -27 }
|
|
||||||
}
|
|
||||||
|
|
||||||
local PHYSICS_ROTATION = {
|
|
||||||
270,
|
|
||||||
270,
|
|
||||||
0,
|
|
||||||
180,
|
|
||||||
270,
|
|
||||||
0
|
|
||||||
}
|
|
||||||
|
|
||||||
local PHYSICS_SCALE = {
|
|
||||||
{ 36.6, 1, 14.5 },
|
|
||||||
{ 36.6, 1, 14.5 },
|
|
||||||
{ 34.0, 1, 14.5 },
|
|
||||||
{ 34.0, 1, 14.5 },
|
|
||||||
{ 55.0, 1, 13.5 },
|
|
||||||
{ 05.0, 1, 05.0 }
|
|
||||||
}
|
|
||||||
|
|
||||||
local optionsVisible = false
|
local optionsVisible = false
|
||||||
|
|
||||||
local options = {}
|
local options = {}
|
||||||
options["importTrauma"] = true
|
options["importTrauma"] = true
|
||||||
options["tidyPlayermats"] = true
|
options["tidyPlayermats"] = true
|
||||||
@ -56,7 +28,6 @@ options["removeDrawnLines"] = false
|
|||||||
local buttonParameters = {}
|
local buttonParameters = {}
|
||||||
buttonParameters.function_owner = self
|
buttonParameters.function_owner = self
|
||||||
|
|
||||||
local loadingFailedBefore = false
|
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- option loading and GUI setup
|
-- option loading and GUI setup
|
||||||
@ -202,13 +173,12 @@ function getTrauma()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- get campaign log
|
-- get campaign log
|
||||||
campaignLog = findObjects(6)[1]
|
campaignLog = getObjectsWithTag("CampaignLog")[1]
|
||||||
if campaignLog == nil then
|
if campaignLog == nil then
|
||||||
printToAll("Campaign log not found in standard position!", "Yellow")
|
printToAll("Campaign log not found in standard position!", "Yellow")
|
||||||
printToAll("Default values for health and sanity loaded.", "Yellow")
|
printToAll("Default values for health and sanity loaded.", "Yellow")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
campaignLog = campaignLog.hit_object
|
|
||||||
loadTrauma()
|
loadTrauma()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -306,9 +276,14 @@ function tidyPlayerMatCoroutine()
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, entry in ipairs(findObjects(i)) do
|
local objList
|
||||||
local obj = entry.hit_object
|
if i < 5 then
|
||||||
|
objList = playmatApi.searchAroundPlaymat(COLORS[i])
|
||||||
|
else
|
||||||
|
objList = searchMythosArea()
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, obj in ipairs(objList) do
|
||||||
-- ignore these elements
|
-- ignore these elements
|
||||||
if obj.hasTag(IGNORE_TAG) == false
|
if obj.hasTag(IGNORE_TAG) == false
|
||||||
and obj.hasTag("ActionToken") == false
|
and obj.hasTag("ActionToken") == false
|
||||||
@ -346,17 +321,23 @@ end
|
|||||||
-- helper functions
|
-- helper functions
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- find objects depending on index (1 to 4 for playermats, 5 for mythos area, 6 for campaign log)
|
-- find objects in the mythos area
|
||||||
function findObjects(num)
|
function searchMythosArea()
|
||||||
return Physics.cast({
|
local searchResult = Physics.cast({
|
||||||
direction = { 0, 1, 0 },
|
direction = { 0, 1, 0 },
|
||||||
max_distance = 1,
|
max_distance = 1,
|
||||||
type = 3,
|
type = 3,
|
||||||
size = PHYSICS_SCALE[num],
|
size = { 55, 1, 13.5 },
|
||||||
origin = PHYSICS_POSITION[num],
|
origin = { -2, 2, 10 },
|
||||||
orientation = { 0, PHYSICS_ROTATION[num], 0 },
|
orientation = { 0, 270, 0 },
|
||||||
debug = false
|
debug = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local objList = {}
|
||||||
|
for _, v in ipairs(searchResult) do
|
||||||
|
table.insert(objList, v.hit_object)
|
||||||
|
end
|
||||||
|
return objList
|
||||||
end
|
end
|
||||||
|
|
||||||
-- checks if the object is owned by a playermat or the mythos, returns boolean
|
-- checks if the object is owned by a playermat or the mythos, returns boolean
|
||||||
|
@ -105,7 +105,7 @@ function takeClueFromLocation(playerColor, hoveredObject)
|
|||||||
local pos = nil
|
local pos = nil
|
||||||
if clickableClues then
|
if clickableClues then
|
||||||
pos = {x = 0.49, y = 2.66, z = 0.00}
|
pos = {x = 0.49, y = 2.66, z = 0.00}
|
||||||
playmatApi.updateClueClicker(playerColor, playmatApi.getClueCount(clickableClues, playerColor) + 1)
|
playmatApi.updateCounter(matColor, "ClickableClueCounter", _, 1)
|
||||||
else
|
else
|
||||||
pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor)
|
pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor)
|
||||||
end
|
end
|
||||||
|
@ -328,7 +328,7 @@ function loadCamera(player, index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- search on the playmat for objects
|
-- search on the playmat for objects
|
||||||
local bounds = getDynamicViewBounds(playmatApi.searchPlaymat(matColor))
|
local bounds = getDynamicViewBounds(playmatApi.searchAroundPlaymat(matColor))
|
||||||
|
|
||||||
lookHere = {
|
lookHere = {
|
||||||
position = { bounds.middleX, 0, bounds.middleZ },
|
position = { bounds.middleX, 0, bounds.middleZ },
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local playmatAPI = require("playermat/PlaymatApi")
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
self.addContextMenuItem("Discard 10 cards", shortSupply)
|
self.addContextMenuItem("Discard 10 cards", shortSupply)
|
||||||
@ -6,11 +6,11 @@ end
|
|||||||
|
|
||||||
-- called by context menu entry
|
-- called by context menu entry
|
||||||
function shortSupply(color)
|
function shortSupply(color)
|
||||||
local matColor = playmatAPI.getMatColorByPosition(self.getPosition())
|
local matColor = playmatApi.getMatColorByPosition(self.getPosition())
|
||||||
|
|
||||||
-- get draw deck and discard position
|
-- get draw deck and discard position
|
||||||
local drawDeck = playmatAPI.getDrawDeck(matColor)
|
local drawDeck = playmatApi.getDrawDeck(matColor)
|
||||||
local discardPos = playmatAPI.getDiscardPosition(matColor)
|
local discardPos = playmatApi.getDiscardPosition(matColor)
|
||||||
|
|
||||||
-- error handling
|
-- error handling
|
||||||
if discardPos == nil then
|
if discardPos == nil then
|
||||||
|
@ -183,7 +183,7 @@ function isCard(x) return x.type == 'Card' end
|
|||||||
function isDeck(x) return x.type == 'Deck' end
|
function isDeck(x) return x.type == 'Deck' end
|
||||||
function isCardOrDeck(x) return x.type == 'Card' or x.type == 'Deck' end
|
function isCardOrDeck(x) return x.type == 'Card' or x.type == 'Deck' end
|
||||||
|
|
||||||
-- Finds all objects on the playmat and associated set aside zone.
|
-- finds all objects on the playmat and associated set aside zone.
|
||||||
function searchAroundSelf(filter)
|
function searchAroundSelf(filter)
|
||||||
local bounds = self.getBoundsNormalized()
|
local bounds = self.getBoundsNormalized()
|
||||||
-- Increase the width to cover the set aside zone
|
-- Increase the width to cover the set aside zone
|
||||||
|
@ -2,216 +2,210 @@ do
|
|||||||
local PlaymatApi = {}
|
local PlaymatApi = {}
|
||||||
local internal = {}
|
local internal = {}
|
||||||
|
|
||||||
-- Returns the color of the by position requested playermat as string
|
-- Returns the color of the closest playmat
|
||||||
---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat
|
---@param startPos Table Starting position to get the closest mat from
|
||||||
PlaymatApi.getMatColorByPosition = function(startPos)
|
PlaymatApi.getMatColorByPosition = function(startPos)
|
||||||
if startPos.x < -42 then
|
local result, smallestDistance
|
||||||
if startPos.z > 0 then
|
for matColor, mat in pairs(internal.getMatForColor("All")) do
|
||||||
return "White"
|
local distance = Vector.between(startPos, mat.getPosition()):magnitude()
|
||||||
else
|
if smallestDistance == nil or distance < smallestDistance then
|
||||||
return "Orange"
|
smallestDistance = distance
|
||||||
end
|
result = matColor
|
||||||
else
|
|
||||||
if startPos.z > 0 then
|
|
||||||
return "Green"
|
|
||||||
else
|
|
||||||
return "Red"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the color of the player's hand that is seated next to the playermat
|
-- Returns the color of the player's hand that is seated next to the playmat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.getPlayerColor = function(matColor)
|
PlaymatApi.getPlayerColor = function(matColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.getVar("playerColor")
|
return mat.getVar("playerColor")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns the color of the playermat that owns the playercolor's hand
|
-- Returns the color of the playmat that owns the playercolor's hand
|
||||||
---@param handColor String Color of the playermat
|
---@param handColor String Color of the playmat
|
||||||
PlaymatApi.getMatColor = function(handColor)
|
PlaymatApi.getMatColor = function(handColor)
|
||||||
local matColors = {"White", "Orange", "Green", "Red"}
|
for matColor, mat in pairs(internal.getMatForColor("All")) do
|
||||||
for i, mat in ipairs(internal.getMatForColor("All")) do
|
local playerColor = mat.getVar("playerColor")
|
||||||
local color = mat.getVar("playerColor")
|
if playerColor == handColor then return matColor end
|
||||||
if color == handColor then return matColors[i] end
|
|
||||||
end
|
end
|
||||||
return "NOT_FOUND"
|
return "NOT_FOUND"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the result of a cast in the specificed playermat's area
|
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.searchPlaymat = function(matColor)
|
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
|
||||||
return mat.call("searchAroundSelf")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat
|
|
||||||
---@param matColor String Color of the playermat
|
|
||||||
PlaymatApi.isDES = function(matColor)
|
PlaymatApi.isDES = function(matColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.getVar("isDES")
|
return mat.getVar("isDES")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns the draw deck of the requested playmat
|
-- Returns the draw deck of the requested playmat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.getDrawDeck = function(matColor)
|
PlaymatApi.getDrawDeck = function(matColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("getDrawDiscardDecks")
|
mat.call("getDrawDiscardDecks")
|
||||||
return mat.getVar("drawDeck")
|
return mat.getVar("drawDeck")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns the position of the discard pile of the requested playmat
|
-- Returns the position of the discard pile of the requested playmat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.getDiscardPosition = function(matColor)
|
PlaymatApi.getDiscardPosition = function(matColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.call("returnGlobalDiscardPosition")
|
return mat.call("returnGlobalDiscardPosition")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Transforms a local position into a global position
|
-- Transforms a local position into a global position
|
||||||
---@param localPos Table Local position to be transformed
|
---@param localPos Table Local position to be transformed
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.transformLocalPosition = function(localPos, matColor)
|
PlaymatApi.transformLocalPosition = function(localPos, matColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.positionToWorld(localPos)
|
return mat.positionToWorld(localPos)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns the rotation of the requested playmat
|
-- Returns the rotation of the requested playmat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.returnRotation = function(matColor)
|
PlaymatApi.returnRotation = function(matColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.getRotation()
|
return mat.getRotation()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Triggers the Upkeep for the requested playmat
|
-- Triggers the Upkeep for the requested playmat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
---@param playerColor String Color of the calling player (for messages)
|
---@param playerColor String Color of the calling player (for messages)
|
||||||
PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)
|
PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.call("doUpkeepFromHotkey", playerColor)
|
mat.call("doUpkeepFromHotkey", playerColor)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the active investigator id
|
-- Returns the active investigator id
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.returnInvestigatorId = function(matColor)
|
PlaymatApi.returnInvestigatorId = function(matColor)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.getVar("activeInvestigatorId")
|
return mat.getVar("activeInvestigatorId")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Sets the requested playermat's snap points to limit snapping to matching card types or not. If
|
-- Sets the requested playmat's snap points to limit snapping to matching card types or not. If
|
||||||
-- matchTypes is true, the main card slot snap points will only snap assets, while the
|
-- matchTypes is true, the main card slot snap points will only snap assets, while the
|
||||||
-- investigator area point will only snap Investigators. If matchTypes is false, snap points will
|
-- investigator area point will only snap Investigators. If matchTypes is false, snap points will
|
||||||
-- be reset to snap all cards.
|
-- be reset to snap all cards.
|
||||||
---@param matchCardTypes Boolean. Whether snap points should only snap for the matching card
|
---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types
|
||||||
-- types.
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
|
||||||
-- accepts "All" as a special value which will apply the setting to all four mats.
|
|
||||||
PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)
|
PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("setLimitSnapsByType", matchCardTypes)
|
mat.call("setLimitSnapsByType", matchCardTypes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sets the requested playermat's draw 1 button to visible
|
-- Sets the requested playmat's draw 1 button to visible
|
||||||
---@param isDrawButtonVisible Boolean. Whether the draw 1 button should be visible or not
|
---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
-- accepts "All" as a special value which will apply the setting to all four mats.
|
|
||||||
PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)
|
PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("showDrawButton", isDrawButtonVisible)
|
mat.call("showDrawButton", isDrawButtonVisible)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Shows or hides the clickable clue counter for the requested playermat
|
-- Shows or hides the clickable clue counter for the requested playmat
|
||||||
---@param showCounter Boolean. Whether the clickable counter should be present or not
|
---@param showCounter Boolean Whether the clickable counter should be present or not
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
-- accepts "All" as a special value which will apply the setting to all four mats.
|
|
||||||
PlaymatApi.clickableClues = function(showCounter, matColor)
|
PlaymatApi.clickableClues = function(showCounter, matColor)
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("clickableClues", showCounter)
|
mat.call("clickableClues", showCounter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Removes all clues (to the trash for tokens and counters set to 0) for the requested playermat
|
-- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
-- accepts "All" as a special value which will apply the setting to all four mats.
|
|
||||||
PlaymatApi.removeClues = function(matColor)
|
PlaymatApi.removeClues = function(matColor)
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("removeClues")
|
mat.call("removeClues")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Reports the clue count for the requested playermat
|
-- Reports the clue count for the requested playmat
|
||||||
---@param useClickableCounters Boolean Controls which type of counter is getting checked
|
---@param useClickableCounters Boolean Controls which type of counter is getting checked
|
||||||
PlaymatApi.getClueCount = function(useClickableCounters, matColor)
|
PlaymatApi.getClueCount = function(useClickableCounters, matColor)
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
count = count + tonumber(mat.call("getClueCount", useClickableCounters))
|
count = count + tonumber(mat.call("getClueCount", useClickableCounters))
|
||||||
end
|
end
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
-- updates the specified owned counter
|
-- updates the specified owned counter
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
-- accepts "All" as a special value which will return all four mats.
|
|
||||||
---@param type String Counter to target
|
---@param type String Counter to target
|
||||||
---@param newValue Number Value to set the counter to
|
---@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
|
---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier
|
||||||
PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)
|
PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("updateCounter", {type = type, newValue = newValue, modifier = modifier})
|
mat.call("updateCounter", {type = type, newValue = newValue, modifier = modifier})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns the resource counter amount
|
-- returns the resource counter amount
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
---@param type String Counter to target
|
---@param type String Counter to target
|
||||||
PlaymatApi.getCounterValue = function(matColor, type)
|
PlaymatApi.getCounterValue = function(matColor, type)
|
||||||
local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"})
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
return mat.call("getCounterValue", type)
|
return mat.call("getCounterValue", type)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- resets the specified skill tracker to "1, 1, 1, 1"
|
-- resets the specified skill tracker to "1, 1, 1, 1"
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
-- accepts "All" as a special value which will return all four mats.
|
|
||||||
PlaymatApi.resetSkillTracker = function(matColor)
|
PlaymatApi.resetSkillTracker = function(matColor)
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("resetSkillTracker")
|
mat.call("resetSkillTracker")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- finds all objects on the playmat and associated set aside zone and returns a table
|
||||||
|
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
|
---@param filter Function Optional filter function (return true for desired objects)
|
||||||
|
PlaymatApi.searchAroundPlaymat = function(matColor, filter)
|
||||||
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
|
return mat.call("searchAroundSelf", filter)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Discard a non-hidden card from the corresponding player's hand
|
-- 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)
|
PlaymatApi.doDiscardOne = function(matColor)
|
||||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
for _, mat in pairs(internal.getMatForColor(matColor)) do
|
||||||
mat.call("doDiscardOne")
|
mat.call("doDiscardOne")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Triggers the metadata sync for all playmats
|
||||||
PlaymatApi.syncAllCustomizableCards = function()
|
PlaymatApi.syncAllCustomizableCards = function()
|
||||||
for _, mat in ipairs(internal.getMatForColor("All")) do
|
for _, mat in pairs(internal.getMatForColor("All")) do
|
||||||
mat.call("syncAllCustomizableCards")
|
mat.call("syncAllCustomizableCards")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
PlaymatApi.updateClueClicker = function(matColor, val)
|
|
||||||
return Global.call("getObjectFromMemo", {matColor = matColor, type = "ClickableClueCounter"}).call("updateVal", val)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Convenience function to look up a mat's object by color, or get all mats.
|
-- Convenience function to look up a mat's object by color, or get all mats.
|
||||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||||
-- accepts "All" as a special value which will return all four mats.
|
---@return array Table Single-element if only single playmat is requested
|
||||||
---@return: Array of playermat objects. If a single mat is requested, will return a single-element
|
|
||||||
-- array to simplify processing by consumers.
|
|
||||||
internal.getMatForColor = function(matColor)
|
internal.getMatForColor = function(matColor)
|
||||||
if matColor == "All" then
|
if matColor == "All" then
|
||||||
return {
|
return {
|
||||||
Global.call("getObjectFromMemo", {matColor = "White", type = "Playermat"}),
|
White = Global.call("getObjectFromMemo", {matColor = "White", type = "Playermat"}),
|
||||||
Global.call("getObjectFromMemo", {matColor = "Orange", type = "Playermat"}),
|
Orange = Global.call("getObjectFromMemo", {matColor = "Orange", type = "Playermat"}),
|
||||||
Global.call("getObjectFromMemo", {matColor = "Green", type = "Playermat"}),
|
Green = Global.call("getObjectFromMemo", {matColor = "Green", type = "Playermat"}),
|
||||||
Global.call("getObjectFromMemo", {matColor = "Red", type = "Playermat"})
|
Red = Global.call("getObjectFromMemo", {matColor = "Red", type = "Playermat"})
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return { Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) }
|
return {matColor = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user