fixed annotations
This commit is contained in:
parent
d9c89ff2fa
commit
bb82e6b432
@ -3,8 +3,8 @@ do
|
|||||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||||
|
|
||||||
-- local function to call the token arranger, if it is on the table
|
-- local function to call the token arranger, if it is on the table
|
||||||
---@param functionName String Name of the function to cal
|
---@param functionName string Name of the function to cal
|
||||||
---@param argument Variant Parameter to pass
|
---@param argument? table Parameter to pass
|
||||||
local function callIfExistent(functionName, argument)
|
local function callIfExistent(functionName, argument)
|
||||||
local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger")
|
local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger")
|
||||||
if tokenArranger ~= nil then
|
if tokenArranger ~= nil then
|
||||||
@ -13,7 +13,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- updates the token modifiers with the provided data
|
-- updates the token modifiers with the provided data
|
||||||
---@param fullData Table Contains the chaos token metadata
|
---@param fullData table Contains the chaos token metadata
|
||||||
TokenArrangerApi.onTokenDataChanged = function(fullData)
|
TokenArrangerApi.onTokenDataChanged = function(fullData)
|
||||||
callIfExistent("onTokenDataChanged", fullData)
|
callIfExistent("onTokenDataChanged", fullData)
|
||||||
end
|
end
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
do
|
do
|
||||||
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||||
local playAreaApi = require("core/PlayAreaApi")
|
local playAreaApi = require("core/PlayAreaApi")
|
||||||
|
|
||||||
|
local ArkhamDb = {}
|
||||||
|
local internal = {}
|
||||||
|
|
||||||
local ArkhamDb = { }
|
local tabooList = {}
|
||||||
local internal = { }
|
local configuration
|
||||||
|
|
||||||
local RANDOM_WEAKNESS_ID = "01000"
|
local RANDOM_WEAKNESS_ID = "01000"
|
||||||
|
|
||||||
local tabooList = { }
|
---@class Request
|
||||||
--Forward declaration
|
|
||||||
---@type Request
|
|
||||||
local Request = {}
|
local Request = {}
|
||||||
local configuration
|
|
||||||
|
|
||||||
-- Sets up the ArkhamDb interface. Should be called from the parent object on load.
|
-- Sets up the ArkhamDb interface. Should be called from the parent object on load.
|
||||||
ArkhamDb.initialize = function()
|
ArkhamDb.initialize = function()
|
||||||
@ -19,7 +19,6 @@ do
|
|||||||
Request.start({ configuration.api_uri, configuration.taboo }, function(status)
|
Request.start({ configuration.api_uri, configuration.taboo }, function(status)
|
||||||
local json = JSON.decode(internal.fixUtf16String(status.text))
|
local json = JSON.decode(internal.fixUtf16String(status.text))
|
||||||
for _, taboo in pairs(json) do
|
for _, taboo in pairs(json) do
|
||||||
---@type <string, boolean>
|
|
||||||
local cards = {}
|
local cards = {}
|
||||||
|
|
||||||
for _, card in pairs(JSON.decode(taboo.cards)) do
|
for _, card in pairs(JSON.decode(taboo.cards)) do
|
||||||
@ -37,18 +36,19 @@ do
|
|||||||
|
|
||||||
-- Start the deck build process for the given player color and deck ID. This
|
-- Start the deck build process for the given player color and deck ID. This
|
||||||
-- will retrieve the deck from ArkhamDB, and pass to a callback for processing.
|
-- will retrieve the deck from ArkhamDB, and pass to a callback for processing.
|
||||||
---@param playerColor String. Color name of the player mat to place this deck on (e.g. "Red").
|
---@param playerColor string Color name of the player mat to place this deck on (e.g. "Red").
|
||||||
---@param deckId String. ArkhamDB deck id to be loaded
|
---@param deckId string ArkhamDB deck id to be loaded
|
||||||
---@param isPrivate Boolean. Whether this deck is published or private on ArkhamDB
|
---@param isPrivate boolean Whether this deck is published or private on ArkhamDB
|
||||||
---@param loadNewest Boolean. Whether the newest version of this deck should be loaded
|
---@param loadNewest boolean Whether the newest version of this deck should be loaded
|
||||||
---@param loadInvestigators Boolean. Whether investigator cards should be loaded as part of this
|
---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck
|
||||||
--- deck
|
---@param callback function Callback which will be sent the results of this load
|
||||||
---@param callback Function. Callback which will be sent the results of this load. Parameters
|
--- Parameters to the callback will be:
|
||||||
--- to the callback will be:
|
--- slots table A map of card ID to count in the deck
|
||||||
--- slots Table. A map of card ID to count in the deck
|
|
||||||
--- investigatorCode String. ID of the investigator in this deck
|
--- investigatorCode String. ID of the investigator in this deck
|
||||||
--- customizations Table. The decoded table of customization upgrades in this deck
|
--- customizations table The decoded table of customization upgrades in this deck
|
||||||
--- playerColor String. Color this deck is being loaded for
|
--- playerColor String. Color this deck is being loaded for
|
||||||
|
---@return boolean
|
||||||
|
---@return string
|
||||||
ArkhamDb.getDecklist = function(
|
ArkhamDb.getDecklist = function(
|
||||||
playerColor,
|
playerColor,
|
||||||
deckId,
|
deckId,
|
||||||
@ -60,7 +60,7 @@ do
|
|||||||
-- the deck load. The called method will handle player notification.
|
-- the deck load. The called method will handle player notification.
|
||||||
local checkCard = allCardsBagApi.getCardById("01001")
|
local checkCard = allCardsBagApi.getCardById("01001")
|
||||||
if (checkCard ~= nil and checkCard.data == nil) then
|
if (checkCard ~= nil and checkCard.data == nil) then
|
||||||
return
|
return false, "Indexing not complete"
|
||||||
end
|
end
|
||||||
|
|
||||||
local deckUri = { configuration.api_uri,
|
local deckUri = { configuration.api_uri,
|
||||||
@ -69,7 +69,7 @@ do
|
|||||||
local deck = Request.start(deckUri, function(status)
|
local deck = Request.start(deckUri, function(status)
|
||||||
if string.find(status.text, "<!DOCTYPE html>") then
|
if string.find(status.text, "<!DOCTYPE html>") then
|
||||||
internal.maybePrint("Private deck ID " .. deckId .. " is not shared", playerColor)
|
internal.maybePrint("Private deck ID " .. deckId .. " is not shared", playerColor)
|
||||||
return false, table.concat({ "Private deck ", deckId, " is not shared" })
|
return false, "Private deck " .. deckId .. " is not shared"
|
||||||
end
|
end
|
||||||
local json = JSON.decode(status.text)
|
local json = JSON.decode(status.text)
|
||||||
|
|
||||||
@ -87,8 +87,8 @@ do
|
|||||||
-- Logs that a card could not be loaded in the mod by printing it to the console in the given
|
-- Logs that a card could not be loaded in the mod by printing it to the console in the given
|
||||||
-- color of the player owning the deck. Attempts to look up the name on ArkhamDB for clarity,
|
-- color of the player owning the deck. Attempts to look up the name on ArkhamDB for clarity,
|
||||||
-- but prints the card ID if the name cannot be retrieved.
|
-- but prints the card ID if the name cannot be retrieved.
|
||||||
---@param cardId String. ArkhamDB ID of the card that could not be found
|
---@param cardId string ArkhamDB ID of the card that could not be found
|
||||||
---@param playerColor String. Color of the player's deck that had the problem
|
---@param playerColor string Color of the player's deck that had the problem
|
||||||
ArkhamDb.logCardNotFound = function(cardId, playerColor)
|
ArkhamDb.logCardNotFound = function(cardId, playerColor)
|
||||||
local request = Request.start({
|
local request = Request.start({
|
||||||
configuration.api_uri,
|
configuration.api_uri,
|
||||||
@ -113,18 +113,17 @@ do
|
|||||||
-- response then applies standard transformations to the deck such as adding
|
-- response then applies standard transformations to the deck such as adding
|
||||||
-- random weaknesses and checking for taboos. Once the deck is processed,
|
-- random weaknesses and checking for taboos. Once the deck is processed,
|
||||||
-- passes to loadCards to actually spawn the defined deck.
|
-- passes to loadCards to actually spawn the defined deck.
|
||||||
---@param deck ArkhamImportDeck
|
---@param deck table ArkhamImportDeck
|
||||||
---@param playerColor String Color name of the player mat to place this deck on (e.g. "Red")
|
---@param playerColor string Color name of the player mat to place this deck on (e.g. "Red")
|
||||||
---@param loadNewest Boolean Whether the newest version of this deck should be loaded
|
---@param loadNewest boolean Whether the newest version of this deck should be loaded
|
||||||
---@param loadInvestigators Boolean Whether investigator cards should be loaded as part of this
|
---@param loadInvestigators boolean Whether investigator cards should be loaded as part of this deck
|
||||||
--- deck
|
---@param callback function Callback which will be sent the results of this load.
|
||||||
---@param callback Function Callback which will be sent the results of this load. Parameters
|
--- Parameters to the callback will be:
|
||||||
--- to the callback will be:
|
--- slots table A map of card ID to count in the deck
|
||||||
--- slots Table. A map of card ID to count in the deck
|
|
||||||
--- investigatorCode String. ID of the investigator in this deck
|
--- investigatorCode String. ID of the investigator in this deck
|
||||||
--- bondedList A table of cardID keys to meaningless values. Card IDs in this list were
|
--- bondedList A table of cardID keys to meaningless values. Card IDs in this list were
|
||||||
--- added from a parent bonded card.
|
--- added from a parent bonded card.
|
||||||
--- customizations Table. The decoded table of customization upgrades in this deck
|
--- customizations table The decoded table of customization upgrades in this deck
|
||||||
--- playerColor String. Color this deck is being loaded for
|
--- playerColor String. Color this deck is being loaded for
|
||||||
internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback)
|
internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback)
|
||||||
-- Load the next deck in the upgrade path if the option is enabled
|
-- Load the next deck in the upgrade path if the option is enabled
|
||||||
@ -165,9 +164,9 @@ do
|
|||||||
-- Checks to see if the slot list includes the random weakness ID. If it does,
|
-- Checks to see if the slot list includes the random weakness ID. If it does,
|
||||||
-- removes it from the deck and replaces it with the ID of a random basic weakness provided by the
|
-- removes it from the deck and replaces it with the ID of a random basic weakness provided by the
|
||||||
-- all cards bag
|
-- all cards bag
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number
|
||||||
--- of those cards which will be spawned
|
--- of those cards which will be spawned
|
||||||
---@param playerColor String Color of the player this deck is being loaded for. Used for broadcast
|
---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast
|
||||||
--- if a weakness is added.
|
--- if a weakness is added.
|
||||||
internal.maybeDrawRandomWeakness = function(slots, playerColor)
|
internal.maybeDrawRandomWeakness = function(slots, playerColor)
|
||||||
local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0
|
local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0
|
||||||
@ -183,8 +182,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each
|
-- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each
|
||||||
---@param deck Table The processed ArkhamDB deck response
|
---@param deck table The processed ArkhamDB deck response
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the
|
||||||
--- number of those cards which will be spawned
|
--- number of those cards which will be spawned
|
||||||
---@return string: Contains the name of the art that should be loaded ("normal", "promo" or "revised")
|
---@return string: Contains the name of the art that should be loaded ("normal", "promo" or "revised")
|
||||||
internal.addInvestigatorCards = function(deck, slots)
|
internal.addInvestigatorCards = function(deck, slots)
|
||||||
@ -238,7 +237,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Process the card list looking for the customizable cards, and add their upgrade sheets if needed
|
-- Process the card list looking for the customizable cards, and add their upgrade sheets if needed
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number
|
||||||
-- of those cards which will be spawned
|
-- of those cards which will be spawned
|
||||||
internal.maybeAddUpgradeSheets = function(slots)
|
internal.maybeAddUpgradeSheets = function(slots)
|
||||||
for cardId, _ in pairs(slots) do
|
for cardId, _ in pairs(slots) do
|
||||||
@ -252,7 +251,7 @@ do
|
|||||||
|
|
||||||
-- Process the card list looking for the Summoned Servitor, and add its minicard to the list if
|
-- Process the card list looking for the Summoned Servitor, and add its minicard to the list if
|
||||||
-- needed
|
-- needed
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number
|
||||||
-- of those cards which will be spawned
|
-- of those cards which will be spawned
|
||||||
internal.maybeAddSummonedServitor = function(slots)
|
internal.maybeAddSummonedServitor = function(slots)
|
||||||
if slots["09080"] ~= nil then
|
if slots["09080"] ~= nil then
|
||||||
@ -262,9 +261,9 @@ do
|
|||||||
|
|
||||||
-- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update
|
-- On the Mend should have 1-per-investigator copies set aside, but ArkhamDB always sends 1. Update
|
||||||
-- the count based on the investigator count
|
-- the count based on the investigator count
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number
|
||||||
-- of those cards which will be spawned
|
-- of those cards which will be spawned
|
||||||
---@param playerColor String Color of the player this deck is being loaded for. Used for broadcast if an error occurs
|
---@param playerColor string Color of the player this deck is being loaded for. Used for broadcast if an error occurs
|
||||||
internal.maybeAddOnTheMend = function(slots, playerColor)
|
internal.maybeAddOnTheMend = function(slots, playerColor)
|
||||||
if slots["09006"] ~= nil then
|
if slots["09006"] ~= nil then
|
||||||
local investigatorCount = playAreaApi.getInvestigatorCount()
|
local investigatorCount = playAreaApi.getInvestigatorCount()
|
||||||
@ -278,7 +277,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Process the card list looking for Reality Acid and adds the reference sheet when needed
|
-- Process the card list looking for Reality Acid and adds the reference sheet when needed
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number
|
||||||
-- of those cards which will be spawned
|
-- of those cards which will be spawned
|
||||||
internal.maybeAddRealityAcidReference = function(slots)
|
internal.maybeAddRealityAcidReference = function(slots)
|
||||||
if slots["89004"] ~= nil then
|
if slots["89004"] ~= nil then
|
||||||
@ -287,8 +286,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Processes the deck description from ArkhamDB and modifies the slot list accordingly
|
-- Processes the deck description from ArkhamDB and modifies the slot list accordingly
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number
|
||||||
---@param description String The deck desription from ArkhamDB
|
---@param description string The deck desription from ArkhamDB
|
||||||
internal.maybeModifyDeckFromDescription = function(slots, description)
|
internal.maybeModifyDeckFromDescription = function(slots, description)
|
||||||
-- check for import instructions
|
-- check for import instructions
|
||||||
local pos = string.find(description, "++SCED import instructions++")
|
local pos = string.find(description, "++SCED import instructions++")
|
||||||
@ -331,7 +330,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.
|
-- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned
|
||||||
internal.extractBondedCards = function(slots)
|
internal.extractBondedCards = function(slots)
|
||||||
-- Create a list of bonded cards first so we don't modify slots while iterating
|
-- Create a list of bonded cards first so we don't modify slots while iterating
|
||||||
local bondedCards = { }
|
local bondedCards = { }
|
||||||
@ -362,8 +361,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Check the deck for cards on its taboo list. If they're found, replace the entry in the slot with the Taboo id (i.e. "XXXX" becomes "XXXX-t")
|
-- Check the deck for cards on its taboo list. If they're found, replace the entry in the slot with the Taboo id (i.e. "XXXX" becomes "XXXX-t")
|
||||||
---@param tabooId String The deck's taboo ID, taken from the deck response taboo_id field. May be nil, indicating that no taboo list should be used
|
---@param tabooId string The deck's taboo ID, taken from the deck response taboo_id field. May be nil, indicating that no taboo list should be used
|
||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned
|
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned
|
||||||
internal.checkTaboos = function(tabooId, slots, playerColor)
|
internal.checkTaboos = function(tabooId, slots, playerColor)
|
||||||
if tabooId then
|
if tabooId then
|
||||||
for cardId, _ in pairs(tabooList[tabooId].cards) do
|
for cardId, _ in pairs(tabooList[tabooId].cards) do
|
||||||
@ -391,9 +390,9 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Gets the ArkhamDB config info from the configuration object.
|
-- Gets the ArkhamDB config info from the configuration object.
|
||||||
---@return Table. Configuration data
|
---@return table: configuration data
|
||||||
internal.getConfiguration = function()
|
internal.getConfiguration = function()
|
||||||
local configuration = getObjectsWithTag("import_configuration_provider")[1]:getTable("configuration")
|
local configuation = getObjectsWithTag("import_configuration_provider")[1].getTable("configuration")
|
||||||
printPriority = configuration.priority
|
printPriority = configuration.priority
|
||||||
return configuration
|
return configuration
|
||||||
end
|
end
|
||||||
@ -404,7 +403,6 @@ do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type Request
|
|
||||||
Request = {
|
Request = {
|
||||||
is_done = false,
|
is_done = false,
|
||||||
is_successful = false
|
is_successful = false
|
||||||
@ -425,18 +423,15 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
this.uri = uri
|
this.uri = uri
|
||||||
|
WebRequest.get(uri, function(status) configure(this, status) end)
|
||||||
WebRequest.get(uri, function(status)
|
|
||||||
configure(this, status)
|
|
||||||
end)
|
|
||||||
|
|
||||||
return this
|
return this
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Creates a new request. on_success should set the request's is_done, is_successful, and content variables.
|
-- Creates a new request. on_success should set the request's is_done, is_successful, and content variables.
|
||||||
-- Deferred should be used when you don't want to set is_done immediately (such as if you want to wait for another request to finish)
|
-- Deferred should be used when you don't want to set is_done immediately (such as if you want to wait for another request to finish)
|
||||||
---@param uri string
|
---@param uri table
|
||||||
---@param on_success fun(request: Request, status: WebRequestStatus, vararg any)
|
---@param on_success fun(request: Request, status: WebRequestStatus, vararg: any)
|
||||||
---@param on_error fun(status: WebRequestStatus)|nil
|
---@param on_error fun(status: WebRequestStatus)|nil
|
||||||
---@vararg any[]
|
---@vararg any[]
|
||||||
---@return Request
|
---@return Request
|
||||||
@ -456,10 +451,10 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Creates a new request. on_success should return weather the resultant data is as expected, and the processed content of the request.
|
-- Creates a new request. on_success should return weather the resultant data is as expected, and the processed content of the request.
|
||||||
---@param uri string
|
---@param uri table
|
||||||
---@param on_success fun(status: WebRequestStatus, vararg any): boolean, any
|
---@param on_success fun(status: WebRequestStatus, vararg: any): boolean, any
|
||||||
---@param on_error nil|fun(status: WebRequestStatus, vararg any): string
|
---@param on_error nil|fun(status: WebRequestStatus, vararg: any): string
|
||||||
---@vararg any[]
|
---@vararg any
|
||||||
---@return Request
|
---@return Request
|
||||||
function Request.start(uri, on_success, on_error, ...)
|
function Request.start(uri, on_success, on_error, ...)
|
||||||
local parameters = table.pack(...)
|
local parameters = table.pack(...)
|
||||||
@ -472,17 +467,14 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param requests Request[]
|
---@param requests Request[]
|
||||||
---@param on_success fun(content: any[], vararg any[])
|
---@param on_success fun(content: any, vararg: any)
|
||||||
---@param on_error fun(requests: Request[], vararg any[])|nil
|
---@param on_error fun(requests: Request, vararg: any)|nil
|
||||||
---@vararg any
|
---@vararg any
|
||||||
function Request.with_all(requests, on_success, on_error, ...)
|
function Request.with_all(requests, on_success, on_error, ...)
|
||||||
local parameters = table.pack(...)
|
local parameters = table.pack(...)
|
||||||
|
|
||||||
Wait.condition(function()
|
Wait.condition(function()
|
||||||
---@type any[]
|
|
||||||
local results = {}
|
local results = {}
|
||||||
|
|
||||||
---@type Request[]
|
|
||||||
local errors = {}
|
local errors = {}
|
||||||
|
|
||||||
for _, request in ipairs(requests) do
|
for _, request in ipairs(requests) do
|
||||||
@ -510,7 +502,6 @@ do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param callback fun(content: any, vararg any)
|
|
||||||
function Request:with(callback, ...)
|
function Request:with(callback, ...)
|
||||||
local arguments = table.pack(...)
|
local arguments = table.pack(...)
|
||||||
Wait.condition(function()
|
Wait.condition(function()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
---@type ArkhamImportConfiguration
|
---@type table Contains fields used by the deck importer
|
||||||
configuration = {
|
configuration = {
|
||||||
api_uri = "https://arkhamdb.com/api/public",
|
api_uri = "https://arkhamdb.com/api/public",
|
||||||
public_deck = "decklist",
|
public_deck = "decklist",
|
||||||
|
@ -25,7 +25,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Updates the state of the UI based on the provided table. Any values not provided will be left the same.
|
-- Updates the state of the UI based on the provided table. Any values not provided will be left the same.
|
||||||
---@param uiStateTable Table of values to update on importer
|
---@param uiStateTable table Table of values to update on importer
|
||||||
-- Table values:
|
-- Table values:
|
||||||
-- redDeck: Deck ID to load for the red player
|
-- redDeck: Deck ID to load for the red player
|
||||||
-- orangeDeck: Deck ID to load for the orange player
|
-- orangeDeck: Deck ID to load for the orange player
|
||||||
|
@ -18,8 +18,8 @@ end
|
|||||||
function onSave() return JSON.encode(getUiState()) end
|
function onSave() return JSON.encode(getUiState()) end
|
||||||
|
|
||||||
-- Returns the zone name where the specified card should be placed, based on its metadata.
|
-- Returns the zone name where the specified card should be placed, based on its metadata.
|
||||||
---@param cardMetadata Table of card metadata.
|
---@param cardMetadata table Contains card metadata
|
||||||
---@return Zone String Name of the zone such as "Deck", "SetAside1", etc.
|
---@return string Zone Name of the zone such as "Deck", "SetAside1", etc.
|
||||||
-- See Zones object documentation for a list of valid zones.
|
-- See Zones object documentation for a list of valid zones.
|
||||||
function getDefaultCardZone(cardMetadata, bondedList)
|
function getDefaultCardZone(cardMetadata, bondedList)
|
||||||
if (cardMetadata.id == "09080-m") then -- Have to check the Servitor before other minicards
|
if (cardMetadata.id == "09080-m") then -- Have to check the Servitor before other minicards
|
||||||
@ -70,17 +70,17 @@ end
|
|||||||
-- This is a callback function which handles the results of ArkhamDb.getDecklist()
|
-- This is a callback function which handles the results of ArkhamDb.getDecklist()
|
||||||
-- This method uses an encapsulated coroutine with yields to make the card spawning cleaner.
|
-- This method uses an encapsulated coroutine with yields to make the card spawning cleaner.
|
||||||
--
|
--
|
||||||
---@param slots Table Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn,
|
---@param slots table Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn,
|
||||||
-- and count is the number which should be spawned
|
-- and count is the number which should be spawned
|
||||||
---@param investigatorId String ArkhamDB ID (code) for this deck's investigator.
|
---@param investigatorId string ArkhamDB ID (code) for this deck's investigator.
|
||||||
-- Investigator cards should already be added to the slots list if they
|
-- Investigator cards should already be added to the slots list if they
|
||||||
-- should be spawned, but this value is separate to check for special
|
-- should be spawned, but this value is separate to check for special
|
||||||
-- handling for certain investigators
|
-- handling for certain investigators
|
||||||
---@param bondedList Table A table of cardID keys to meaningless values. Card IDs in this list were added
|
---@param bondedList table A table of cardID keys to meaningless values. Card IDs in this list were added
|
||||||
-- from a parent bonded card.
|
-- from a parent bonded card.
|
||||||
---@param customizations String ArkhamDB data for customizations on customizable cards
|
---@param customizations string ArkhamDB data for customizations on customizable cards
|
||||||
---@param playerColor String Color name of the player mat to place this deck on (e.g. "Red")
|
---@param playerColor string Color name of the player mat to place this deck on (e.g. "Red")
|
||||||
---@param loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
|
---@param loadAltInvestigator string Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
|
||||||
function loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator)
|
function loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator)
|
||||||
function coinside()
|
function coinside()
|
||||||
local cardsToSpawn = {}
|
local cardsToSpawn = {}
|
||||||
@ -162,8 +162,8 @@ end
|
|||||||
|
|
||||||
-- Callback handler for the main deck spawning. Looks for cards which should start in hand, and
|
-- Callback handler for the main deck spawning. Looks for cards which should start in hand, and
|
||||||
-- draws them for the appropriate player.
|
-- draws them for the appropriate player.
|
||||||
---@param deck Object Callback-provided spawned deck object
|
---@param deck tts__GameObject Callback-provided spawned deck object
|
||||||
---@param playerColor String Color of the player to draw the cards to
|
---@param playerColor string Color of the player to draw the cards to
|
||||||
function deckSpawned(deck, playerColor)
|
function deckSpawned(deck, playerColor)
|
||||||
local player = Player[playmatApi.getPlayerColor(playerColor)]
|
local player = Player[playmatApi.getPlayerColor(playerColor)]
|
||||||
local handPos = player.getHandTransform(1).position -- Only one hand zone per player
|
local handPos = player.getHandTransform(1).position -- Only one hand zone per player
|
||||||
@ -185,7 +185,7 @@ end
|
|||||||
|
|
||||||
-- Converts the Raven Quill's selections from card IDs to card names. This could be more elegant
|
-- Converts the Raven Quill's selections from card IDs to card names. This could be more elegant
|
||||||
-- but the inputs are very static so we're using some brute force.
|
-- but the inputs are very static so we're using some brute force.
|
||||||
---@param selectionString String provided by ArkhamDB, indicates the customization selections
|
---@param selectionString string provided by ArkhamDB, indicates the customization selections
|
||||||
-- Should be either a single card ID or two separated by a ^ (e.g. XXXXX^YYYYY)
|
-- Should be either a single card ID or two separated by a ^ (e.g. XXXXX^YYYYY)
|
||||||
function convertRavenQuillSelections(selectionString)
|
function convertRavenQuillSelections(selectionString)
|
||||||
if (string.len(selectionString) == 5) then
|
if (string.len(selectionString) == 5) then
|
||||||
@ -196,7 +196,7 @@ function convertRavenQuillSelections(selectionString)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Converts Grizzled's selections from a single string with "^".
|
-- Converts Grizzled's selections from a single string with "^".
|
||||||
---@param selectionString String provided by ArkhamDB, indicates the customization selections
|
---@param selectionString string provided by ArkhamDB, indicates the customization selections
|
||||||
-- Should be two Traits separated by a ^ (e.g. XXXXX^YYYYY)
|
-- Should be two Traits separated by a ^ (e.g. XXXXX^YYYYY)
|
||||||
function convertGrizzledSelections(selectionString)
|
function convertGrizzledSelections(selectionString)
|
||||||
return selectionString:gsub("%^", ", ")
|
return selectionString:gsub("%^", ", ")
|
||||||
@ -217,8 +217,8 @@ function getCardName(cardId)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Split a single list of cards into a separate table of lists, keyed by the zone
|
-- Split a single list of cards into a separate table of lists, keyed by the zone
|
||||||
---@param cards Table Table of {cardData, cardMetadata, zone}
|
---@param cards table Table of {cardData, cardMetadata, zone}
|
||||||
---@return: Table of {zoneName=card list}
|
---@return table ZoneNames Table with zoneName as index: {zoneName=card list}
|
||||||
function buildZoneLists(cards)
|
function buildZoneLists(cards)
|
||||||
local zoneList = {}
|
local zoneList = {}
|
||||||
for _, card in ipairs(cards) do
|
for _, card in ipairs(cards) do
|
||||||
@ -232,7 +232,7 @@ function buildZoneLists(cards)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Check to see if the deck list has Ancestral Knowledge. If it does, move 5 random skills to SetAside3
|
-- Check to see if the deck list has Ancestral Knowledge. If it does, move 5 random skills to SetAside3
|
||||||
---@param cardList Table Deck list being created
|
---@param cardList table Deck list being created
|
||||||
function handleAncestralKnowledge(cardList)
|
function handleAncestralKnowledge(cardList)
|
||||||
local hasAncestralKnowledge = false
|
local hasAncestralKnowledge = false
|
||||||
local skillList = {}
|
local skillList = {}
|
||||||
@ -258,8 +258,8 @@ function handleAncestralKnowledge(cardList)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside3
|
-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside3
|
||||||
---@param cardList Table Deck list being created
|
---@param cardList table Deck list being created
|
||||||
---@param playerColor String Color this deck is being loaded for
|
---@param playerColor string Color this deck is being loaded for
|
||||||
function handleUnderworldMarket(cardList, playerColor)
|
function handleUnderworldMarket(cardList, playerColor)
|
||||||
local hasMarket = false
|
local hasMarket = false
|
||||||
local illicitList = {}
|
local illicitList = {}
|
||||||
@ -276,9 +276,7 @@ function handleUnderworldMarket(cardList, playerColor)
|
|||||||
|
|
||||||
if hasMarket then
|
if hasMarket then
|
||||||
if #illicitList < 10 then
|
if #illicitList < 10 then
|
||||||
printToAll("Only " .. #illicitList ..
|
printToAll("Only " .. #illicitList .. " Illicit cards in your deck, you can't trigger Underworld Market's ability.", playerColor)
|
||||||
" Illicit cards in your deck, you can't trigger Underworld Market's ability.",
|
|
||||||
playerColor)
|
|
||||||
else
|
else
|
||||||
-- Process cards to move them to the market deck. This is done in reverse
|
-- Process cards to move them to the market deck. This is done in reverse
|
||||||
-- order because the sorting needs to be reversed (deck sorts for face down)
|
-- order because the sorting needs to be reversed (deck sorts for face down)
|
||||||
@ -293,9 +291,7 @@ function handleUnderworldMarket(cardList, playerColor)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #illicitList > 10 then
|
if #illicitList > 10 then
|
||||||
printToAll("Moved all " .. #illicitList ..
|
printToAll("Moved all " .. #illicitList .. " Illicit cards to the Market deck, reduce it to 10", playerColor)
|
||||||
" Illicit cards to the Market deck, reduce it to 10",
|
|
||||||
playerColor)
|
|
||||||
else
|
else
|
||||||
printToAll("Built the Market deck", playerColor)
|
printToAll("Built the Market deck", playerColor)
|
||||||
end
|
end
|
||||||
@ -303,12 +299,11 @@ function handleUnderworldMarket(cardList, playerColor)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch
|
-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch Deck
|
||||||
-- Deck.
|
---@param investigatorId string ID for the deck's investigator card. Passed separately because the
|
||||||
---@param investigatorId String ID for the deck's investigator card. Passed separately because the
|
|
||||||
--- investigator may not be included in the cardList
|
--- investigator may not be included in the cardList
|
||||||
---@param cardList Table Deck list being created
|
---@param cardList table Deck list being created
|
||||||
---@param playerColor String Color this deck is being loaded for
|
---@param playerColor string Color this deck is being loaded for
|
||||||
function handleHunchDeck(investigatorId, cardList, playerColor)
|
function handleHunchDeck(investigatorId, cardList, playerColor)
|
||||||
if investigatorId == "05002" then -- Joe Diamond
|
if investigatorId == "05002" then -- Joe Diamond
|
||||||
local insightList = {}
|
local insightList = {}
|
||||||
@ -343,12 +338,11 @@ function handleHunchDeck(investigatorId, cardList, playerColor)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit
|
-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit Deck
|
||||||
-- Deck.
|
---@param investigatorId string ID for the deck's investigator card. Passed separately because the
|
||||||
---@param investigatorId String ID for the deck's investigator card. Passed separately because the
|
|
||||||
--- investigator may not be included in the cardList
|
--- investigator may not be included in the cardList
|
||||||
---@param cardList Table Deck list being created
|
---@param cardList table Deck list being created
|
||||||
---@param playerColor String Color this deck is being loaded for
|
---@param playerColor string Color this deck is being loaded for
|
||||||
function handleSpiritDeck(investigatorId, cardList, playerColor)
|
function handleSpiritDeck(investigatorId, cardList, playerColor)
|
||||||
if investigatorId == "02004-p" or investigatorId == "02004-pb" then -- Parallel Jim Culver
|
if investigatorId == "02004-p" or investigatorId == "02004-pb" then -- Parallel Jim Culver
|
||||||
local spiritList = {}
|
local spiritList = {}
|
||||||
@ -387,8 +381,8 @@ end
|
|||||||
|
|
||||||
-- For any customization upgrade cards in the card list, process the metadata from the deck to
|
-- For any customization upgrade cards in the card list, process the metadata from the deck to
|
||||||
-- set the save state to show the correct checkboxes/text field values
|
-- set the save state to show the correct checkboxes/text field values
|
||||||
---@param cardList Table Deck list being created
|
---@param cardList table Deck list being created
|
||||||
---@param customizations String ArkhamDB data for customizations on customizable cards
|
---@param customizations string ArkhamDB data for customizations on customizable cards
|
||||||
function handleCustomizableUpgrades(cardList, customizations)
|
function handleCustomizableUpgrades(cardList, customizations)
|
||||||
for _, card in ipairs(cardList) do
|
for _, card in ipairs(cardList) do
|
||||||
if card.metadata.type == "UpgradeSheet" then
|
if card.metadata.type == "UpgradeSheet" then
|
||||||
@ -457,9 +451,9 @@ function handleCustomizableUpgrades(cardList, customizations)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Handles cards that start in play under specific conditions for Ashcan Pete (Regular Pete - Duke, Parallel Pete - Guitar)
|
-- Handles cards that start in play under specific conditions for Ashcan Pete (Regular Pete - Duke, Parallel Pete - Guitar)
|
||||||
---@param investigatorId String ID for the deck's investigator card. Passed separately because the
|
---@param investigatorId string ID for the deck's investigator card. Passed separately because the
|
||||||
--- investigator may not be included in the cardList
|
--- investigator may not be included in the cardList
|
||||||
---@param cardList Table Deck list being created
|
---@param cardList table Deck list being created
|
||||||
function handlePeteSignatureAssets(investigatorId, cardList)
|
function handlePeteSignatureAssets(investigatorId, cardList)
|
||||||
if investigatorId == "02005" or investigatorId == "02005-pb" then -- regular Pete's front
|
if investigatorId == "02005" or investigatorId == "02005-pb" then -- regular Pete's front
|
||||||
for i, card in ipairs(cardList) do
|
for i, card in ipairs(cardList) do
|
||||||
@ -477,8 +471,8 @@ function handlePeteSignatureAssets(investigatorId, cardList)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Callback function for investigator cards and minicards to set the correct state for alt art
|
-- Callback function for investigator cards and minicards to set the correct state for alt art
|
||||||
---@param card Object Card which needs to be set the state for
|
---@param card tts__GameObject Card which needs to be set the state for
|
||||||
---@param loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
|
---@param loadAltInvestigator string Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
|
||||||
function loadAltArt(card, loadAltInvestigator)
|
function loadAltArt(card, loadAltInvestigator)
|
||||||
-- states are set up this way:
|
-- states are set up this way:
|
||||||
-- 1 - normal, 2 - revised/promo, 3 - promo (if 2 is revised)
|
-- 1 - normal, 2 - revised/promo, 3 - promo (if 2 is revised)
|
||||||
|
@ -48,7 +48,7 @@ function getUiState()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Updates the state of the UI based on the provided table. Any values not provided will be left the same.
|
-- Updates the state of the UI based on the provided table. Any values not provided will be left the same.
|
||||||
---@param uiStateTable Table of values to update on importer
|
---@param uiStateTable table Table of values to update on importer
|
||||||
-- Table values:
|
-- Table values:
|
||||||
-- redDeck: Deck ID to load for the red player
|
-- redDeck: Deck ID to load for the red player
|
||||||
-- orangeDeck: Deck ID to load for the orange player
|
-- orangeDeck: Deck ID to load for the orange player
|
||||||
|
@ -207,9 +207,10 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- returns a formatted string with information about the provided token type (bless / curse)
|
-- returns a formatted string with information about the provided token type (bless / curse)
|
||||||
|
---@param type string "Bless" or "Curse"
|
||||||
|
---@param omitBrackets? boolean Controls whether the brackets should be omitted from the return
|
||||||
|
---@return string tokenCount
|
||||||
function formatTokenCount(type, omitBrackets)
|
function formatTokenCount(type, omitBrackets)
|
||||||
if type == nil then type = mode end
|
|
||||||
|
|
||||||
if omitBrackets then
|
if omitBrackets then
|
||||||
return (numInPlay[type] - #tokensTaken[type]) .. " + " .. #tokensTaken[type]
|
return (numInPlay[type] - #tokensTaken[type]) .. " + " .. #tokensTaken[type]
|
||||||
else
|
else
|
||||||
@ -218,7 +219,7 @@ function formatTokenCount(type, omitBrackets)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- seals a token on a card (called by cards that seal bless/curse tokens)
|
-- seals a token on a card (called by cards that seal bless/curse tokens)
|
||||||
---@param param Table This contains the type and guid of the sealed token
|
---@param param table This contains the type and guid of the sealed token
|
||||||
function sealedToken(param)
|
function sealedToken(param)
|
||||||
table.insert(tokensTaken[param.type], param.guid)
|
table.insert(tokensTaken[param.type], param.guid)
|
||||||
broadcastCount(param.type)
|
broadcastCount(param.type)
|
||||||
@ -226,7 +227,7 @@ function sealedToken(param)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- returns a token to the bag (called by cards that seal bless/curse tokens)
|
-- returns a token to the bag (called by cards that seal bless/curse tokens)
|
||||||
---@param param Table This contains the type and guid of the released token
|
---@param param table This contains the type and guid of the released token
|
||||||
function releasedToken(param)
|
function releasedToken(param)
|
||||||
for i, v in ipairs(tokensTaken[param.type]) do
|
for i, v in ipairs(tokensTaken[param.type]) do
|
||||||
if v == param.guid then
|
if v == param.guid then
|
||||||
@ -238,7 +239,7 @@ function releasedToken(param)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- removes a token (called by cards that seal bless/curse tokens)
|
-- removes a token (called by cards that seal bless/curse tokens)
|
||||||
---@param param Table This contains the type and guid of the released token
|
---@param param table This contains the type and guid of the released token
|
||||||
function returnedToken(param)
|
function returnedToken(param)
|
||||||
for i, v in ipairs(tokensTaken[param.type]) do
|
for i, v in ipairs(tokensTaken[param.type]) do
|
||||||
if v == param.guid then
|
if v == param.guid then
|
||||||
|
@ -30,20 +30,20 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- broadcasts the current status for bless/curse tokens
|
-- broadcasts the current status for bless/curse tokens
|
||||||
---@param playerColor String Color of the player to show the broadcast to
|
---@param playerColor string Color of the player to show the broadcast to
|
||||||
BlessCurseManagerApi.broadcastStatus = function(playerColor)
|
BlessCurseManagerApi.broadcastStatus = function(playerColor)
|
||||||
getManager().call("broadcastStatus", playerColor)
|
getManager().call("broadcastStatus", playerColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- removes all bless / curse tokens from the chaos bag and play
|
-- removes all bless / curse tokens from the chaos bag and play
|
||||||
---@param playerColor String Color of the player to show the broadcast to
|
---@param playerColor string Color of the player to show the broadcast to
|
||||||
BlessCurseManagerApi.removeAll = function(playerColor)
|
BlessCurseManagerApi.removeAll = function(playerColor)
|
||||||
getManager().call("doRemove", playerColor)
|
getManager().call("doRemove", playerColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- adds bless / curse sealing to the hovered card
|
-- adds bless / curse sealing to the hovered card
|
||||||
---@param playerColor String Color of the player to show the broadcast to
|
---@param playerColor string Color of the player to show the broadcast to
|
||||||
---@param hoveredObject TTSObject Hovered object
|
---@param hoveredObject tts__GameObject Hovered object
|
||||||
BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)
|
BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)
|
||||||
getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
|
getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@ do
|
|||||||
local ChaosBagApi = {}
|
local ChaosBagApi = {}
|
||||||
|
|
||||||
-- respawns the chaos bag with a new state of tokens
|
-- respawns the chaos bag with a new state of tokens
|
||||||
---@param tokenList Table List of chaos token ids
|
---@param tokenList table List of chaos token ids
|
||||||
ChaosBagApi.setChaosBagState = function(tokenList)
|
ChaosBagApi.setChaosBagState = function(tokenList)
|
||||||
return Global.call("setChaosBagState", tokenList)
|
return Global.call("setChaosBagState", tokenList)
|
||||||
end
|
end
|
||||||
@ -39,19 +39,19 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- removes the specified chaos token from the chaos bag
|
-- removes the specified chaos token from the chaos bag
|
||||||
---@param id String ID of the chaos token
|
---@param id string ID of the chaos token
|
||||||
ChaosBagApi.removeChaosToken = function(id)
|
ChaosBagApi.removeChaosToken = function(id)
|
||||||
return Global.call("removeChaosToken", id)
|
return Global.call("removeChaosToken", id)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns a chaos token to the bag and calls all relevant functions
|
-- returns a chaos token to the bag and calls all relevant functions
|
||||||
---@param token TTSObject Chaos Token to return
|
---@param token tts__GameObject Chaos Token to return
|
||||||
ChaosBagApi.returnChaosTokenToBag = function(token)
|
ChaosBagApi.returnChaosTokenToBag = function(token)
|
||||||
return Global.call("returnChaosTokenToBag", token)
|
return Global.call("returnChaosTokenToBag", token)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- spawns the specified chaos token and puts it into the chaos bag
|
-- spawns the specified chaos token and puts it into the chaos bag
|
||||||
---@param id String ID of the chaos token
|
---@param id string ID of the chaos token
|
||||||
ChaosBagApi.spawnChaosToken = function(id)
|
ChaosBagApi.spawnChaosToken = function(id)
|
||||||
return Global.call("spawnChaosToken", id)
|
return Global.call("spawnChaosToken", id)
|
||||||
end
|
end
|
||||||
@ -60,7 +60,7 @@ do
|
|||||||
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
|
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
|
||||||
-- contents of the bag should check this method before doing so.
|
-- contents of the bag should check this method before doing so.
|
||||||
-- This method will broadcast a message to all players if the bag is being searched.
|
-- This method will broadcast a message to all players if the bag is being searched.
|
||||||
---@return Boolean. True if the bag is manipulated, false if it should be blocked.
|
---@return any canTouch True if the bag is manipulated, false if it should be blocked.
|
||||||
ChaosBagApi.canTouchChaosTokens = function()
|
ChaosBagApi.canTouchChaosTokens = function()
|
||||||
return Global.call("canTouchChaosTokens")
|
return Global.call("canTouchChaosTokens")
|
||||||
end
|
end
|
||||||
|
@ -6,28 +6,28 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- returns all matching objects as a table with references
|
-- returns all matching objects as a table with references
|
||||||
---@param owner String Parent object for this search
|
---@param owner string Parent object for this search
|
||||||
---@param type String Type of object to search for
|
---@param type string Type of object to search for
|
||||||
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
|
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
|
||||||
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
|
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns all matching objects as a table with references
|
-- returns all matching objects as a table with references
|
||||||
---@param type String Type of object to search for
|
---@param type string Type of object to search for
|
||||||
GUIDReferenceApi.getObjectsByType = function(type)
|
GUIDReferenceApi.getObjectsByType = function(type)
|
||||||
return getGuidHandler().call("getObjectsByType", type)
|
return getGuidHandler().call("getObjectsByType", type)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns all matching objects as a table with references
|
-- returns all matching objects as a table with references
|
||||||
---@param owner String Parent object for this search
|
---@param owner string Parent object for this search
|
||||||
GUIDReferenceApi.getObjectsByOwner = function(owner)
|
GUIDReferenceApi.getObjectsByOwner = function(owner)
|
||||||
return getGuidHandler().call("getObjectsByOwner", owner)
|
return getGuidHandler().call("getObjectsByOwner", owner)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- sends new information to the reference handler to edit the main index
|
-- sends new information to the reference handler to edit the main index
|
||||||
---@param owner String Parent of the object
|
---@param owner string Parent of the object
|
||||||
---@param type String Type of the object
|
---@param type string Type of the object
|
||||||
---@param guid String GUID of the object
|
---@param guid string GUID of the object
|
||||||
GUIDReferenceApi.editIndex = function(owner, type, guid)
|
GUIDReferenceApi.editIndex = function(owner, type, guid)
|
||||||
return getGuidHandler().call("editIndex", {
|
return getGuidHandler().call("editIndex", {
|
||||||
owner = owner,
|
owner = owner,
|
||||||
|
@ -333,8 +333,8 @@ function addBlurseSealingMenu(playerColor, hoveredObject)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Simple method to check if the given point is in a specified area
|
-- Simple method to check if the given point is in a specified area
|
||||||
---@param point Vector Point to check, only x and z values are relevant
|
---@param point tts__Vector Point to check, only x and z values are relevant
|
||||||
---@param bounds Table Defined area to see if the point is within
|
---@param bounds table Defined area to see if the point is within
|
||||||
function inArea(point, bounds)
|
function inArea(point, bounds)
|
||||||
return (point.x > bounds.minX
|
return (point.x > bounds.minX
|
||||||
and point.x < bounds.maxX
|
and point.x < bounds.maxX
|
||||||
|
@ -268,7 +268,7 @@ end
|
|||||||
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
|
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
|
||||||
-- contents of the bag should check this method before doing so.
|
-- contents of the bag should check this method before doing so.
|
||||||
-- This method will broadcast a message to all players if the bag is being searched.
|
-- This method will broadcast a message to all players if the bag is being searched.
|
||||||
---@return Boolean. True if the bag is manipulated, false if it should be blocked.
|
---@return boolean: True if the bag is manipulated, false if it should be blocked.
|
||||||
function canTouchChaosTokens()
|
function canTouchChaosTokens()
|
||||||
for color, searching in pairs(bagSearchers) do
|
for color, searching in pairs(bagSearchers) do
|
||||||
if searching then
|
if searching then
|
||||||
@ -329,7 +329,7 @@ end
|
|||||||
|
|
||||||
-- DEPRECATED. Use TokenManager instead.
|
-- DEPRECATED. Use TokenManager instead.
|
||||||
-- Spawns a single token.
|
-- Spawns a single token.
|
||||||
---@param params Table. Array with arguments to the method. 1 = position, 2 = type, 3 = rotation
|
---@param params table Array with arguments to the method. 1 = position, 2 = type, 3 = rotation
|
||||||
function spawnToken(params)
|
function spawnToken(params)
|
||||||
return tokenManager.spawnToken(params[1], params[2], params[3])
|
return tokenManager.spawnToken(params[1], params[2], params[3])
|
||||||
end
|
end
|
||||||
@ -416,7 +416,7 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- called for button creation on the difficulty selectors
|
-- called for button creation on the difficulty selectors
|
||||||
---@param args Table Parameters for this function:
|
---@param args table Parameters for this function:
|
||||||
-- object TTSObject Usually "self"
|
-- object TTSObject Usually "self"
|
||||||
-- key String Name of the scenario
|
-- key String Name of the scenario
|
||||||
function createSetupButtons(args)
|
function createSetupButtons(args)
|
||||||
@ -467,7 +467,7 @@ function createSetupButtons(args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- called for adding chaos tokens
|
-- called for adding chaos tokens
|
||||||
---@param args Table Parameters for this function:
|
---@param args table Parameters for this function:
|
||||||
-- object object Usually "self"
|
-- object object Usually "self"
|
||||||
-- key string Name of the scenario
|
-- key string Name of the scenario
|
||||||
-- mode string difficulty (e.g. "hard" or "expert")
|
-- mode string difficulty (e.g. "hard" or "expert")
|
||||||
@ -567,7 +567,7 @@ function getChaosBagState()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- respawns the chaos bag with a new state of tokens
|
-- respawns the chaos bag with a new state of tokens
|
||||||
---@param tokenList Table List of chaos token ids
|
---@param tokenList table List of chaos token ids
|
||||||
---@api ChaosBag / ChaosBagApi
|
---@api ChaosBag / ChaosBagApi
|
||||||
function setChaosBagState(tokenList)
|
function setChaosBagState(tokenList)
|
||||||
if not canTouchChaosTokens() then return end
|
if not canTouchChaosTokens() then return end
|
||||||
@ -608,7 +608,7 @@ function setChaosBagState(tokenList)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- spawns the specified chaos token and puts it into the chaos bag
|
-- spawns the specified chaos token and puts it into the chaos bag
|
||||||
---@param id String ID of the chaos token
|
---@param id string ID of the chaos token
|
||||||
function spawnChaosToken(id)
|
function spawnChaosToken(id)
|
||||||
if not canTouchChaosTokens() then return end
|
if not canTouchChaosTokens() then return end
|
||||||
|
|
||||||
@ -636,7 +636,7 @@ function spawnChaosToken(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- removes the specified chaos token from the chaos bag
|
-- removes the specified chaos token from the chaos bag
|
||||||
---@param id String ID of the chaos token
|
---@param id string ID of the chaos token
|
||||||
function removeChaosToken(id)
|
function removeChaosToken(id)
|
||||||
if not canTouchChaosTokens() then return end
|
if not canTouchChaosTokens() then return end
|
||||||
|
|
||||||
@ -688,7 +688,7 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- forwards the requested content type to the update function and sets highlight to clicked tab
|
-- forwards the requested content type to the update function and sets highlight to clicked tab
|
||||||
---@param tabId String Id of the clicked tab
|
---@param tabId string Id of the clicked tab
|
||||||
function onClick_tab(_, _, tabId)
|
function onClick_tab(_, _, tabId)
|
||||||
for listId, listContent in pairs(tabIdTable) do
|
for listId, listContent in pairs(tabIdTable) do
|
||||||
if listId == tabId then
|
if listId == tabId then
|
||||||
@ -747,7 +747,7 @@ function onClick_download(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- the download button on the placeholder objects calls this to directly initiate a download
|
-- the download button on the placeholder objects calls this to directly initiate a download
|
||||||
---@param params Table contains url and guid of replacement object
|
---@param params table contains url and guid of replacement object
|
||||||
function placeholder_download(params)
|
function placeholder_download(params)
|
||||||
local url = SOURCE_REPO .. '/' .. params.url
|
local url = SOURCE_REPO .. '/' .. params.url
|
||||||
requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, params) end)
|
requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, params) end)
|
||||||
@ -825,7 +825,7 @@ function coroutineDownloadAll()
|
|||||||
broadcastToAll("Downloading " .. contentType .. "...")
|
broadcastToAll("Downloading " .. contentType .. "...")
|
||||||
local contained = ""
|
local contained = ""
|
||||||
for _, params in ipairs(objectList) do
|
for _, params in ipairs(objectList) do
|
||||||
local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url)
|
local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url, function() end)
|
||||||
local start = os.time()
|
local start = os.time()
|
||||||
while true do
|
while true do
|
||||||
if request.is_done then
|
if request.is_done then
|
||||||
@ -908,8 +908,8 @@ function onClick_spawnPlaceholder()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- toggles the visibility of the respective UI
|
-- toggles the visibility of the respective UI
|
||||||
---@param player LuaPlayer Player that triggered this
|
---@param player tts__Player Player that triggered this
|
||||||
---@param title String Name of the UI to toggle
|
---@param title string Name of the UI to toggle
|
||||||
function onClick_toggleUi(player, title)
|
function onClick_toggleUi(player, title)
|
||||||
if title == "Navigation Overlay" then
|
if title == "Navigation Overlay" then
|
||||||
navigationOverlayApi.cycleVisibility(player.color)
|
navigationOverlayApi.cycleVisibility(player.color)
|
||||||
@ -1162,8 +1162,8 @@ function libraryDownloadCallback(request)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- loops through an XML table and returns the specified object
|
-- loops through an XML table and returns the specified object
|
||||||
---@param ui Table XmlTable (get this via getXmlTable)
|
---@param ui table XmlTable (get this via getXmlTable)
|
||||||
---@param id String Id of the object to return
|
---@param id string Id of the object to return
|
||||||
function getXmlTableElementById(ui, id)
|
function getXmlTableElementById(ui, id)
|
||||||
for _, obj in ipairs(ui) do
|
for _, obj in ipairs(ui) do
|
||||||
if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end
|
if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end
|
||||||
@ -1251,7 +1251,7 @@ function playermatRemovalSelected(player, selectedIndex, id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- removes a playermat and all related objects from play
|
-- removes a playermat and all related objects from play
|
||||||
---@param matColor String Color of the playermat to remove
|
---@param matColor string Color of the playermat to remove
|
||||||
function removePlayermat(matColor)
|
function removePlayermat(matColor)
|
||||||
local matObjects = guidReferenceApi.getObjectsByOwner(matColor)
|
local matObjects = guidReferenceApi.getObjectsByOwner(matColor)
|
||||||
if not matObjects.Playermat then return end
|
if not matObjects.Playermat then return end
|
||||||
@ -1290,8 +1290,8 @@ function updateOptionPanelState()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- handles the applying of option selections and calls the respective functions based
|
-- handles the applying of option selections and calls the respective functions based
|
||||||
---@param id String ID of the option that was selected or deselected
|
---@param id string ID of the option that was selected or deselected
|
||||||
---@param state Boolean State of the option (true = enabled)
|
---@param state boolean State of the option (true = enabled)
|
||||||
function applyOptionPanelChange(id, state)
|
function applyOptionPanelChange(id, state)
|
||||||
-- option: Snap tags
|
-- option: Snap tags
|
||||||
if id == "useSnapTags" then
|
if id == "useSnapTags" then
|
||||||
@ -1366,7 +1366,7 @@ function applyOptionPanelChange(id, state)
|
|||||||
|
|
||||||
-- option: Show CYOA campaign guides
|
-- option: Show CYOA campaign guides
|
||||||
elseif id == "showCYOA" then
|
elseif id == "showCYOA" then
|
||||||
optionPanel[id] = spawnOrRemoveHelper(state, "CYOA Campaign Guides", {39, 1.3, -20})
|
optionPanel[id] = spawnOrRemoveHelper(state, "CYOA Campaign Guides", { 39, 1.3, -20})
|
||||||
|
|
||||||
-- option: Show displacement tool
|
-- option: Show displacement tool
|
||||||
elseif id == "showDisplacementTool" then
|
elseif id == "showDisplacementTool" then
|
||||||
@ -1375,12 +1375,12 @@ function applyOptionPanelChange(id, state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- handler for spawn / remove functions of helper objects
|
-- handler for spawn / remove functions of helper objects
|
||||||
---@param state Boolean Contains the state of the option: true = spawn it, false = remove it
|
---@param state boolean Contains the state of the option: true = spawn it, false = remove it
|
||||||
---@param name String Name of the helper object
|
---@param name string Name of the helper object
|
||||||
---@param position Vector Position of the object (where it will spawn)
|
---@param position tts__Vector Position of the object (where it will spawn)
|
||||||
---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0})
|
---@param rotation? tts__Vector Rotation of the object for spawning (default: {0, 270, 0})
|
||||||
---@param owner String Owner of the object (defaults to "Mythos")
|
---@param owner? string Owner of the object (defaults to "Mythos")
|
||||||
---@return. GUID of the spawnedObj (or nil if object was removed)
|
---@return string|nil GUID GUID of the spawnedObj (or nil if object was removed)
|
||||||
function spawnOrRemoveHelper(state, name, position, rotation, owner)
|
function spawnOrRemoveHelper(state, name, position, rotation, owner)
|
||||||
if (type(state) == "table" and #state == 0) then
|
if (type(state) == "table" and #state == 0) then
|
||||||
return removeHelperObject(name)
|
return removeHelperObject(name)
|
||||||
@ -1396,9 +1396,9 @@ function spawnOrRemoveHelper(state, name, position, rotation, owner)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- copies the specified tool (by name) from the option panel source bag
|
-- copies the specified tool (by name) from the option panel source bag
|
||||||
---@param name String Name of the object that should be copied
|
---@param name string Name of the object that should be copied
|
||||||
---@param position Table Desired position of the object
|
---@param position table Desired position of the object
|
||||||
---@param rotation Table Desired rotation of the object (defaults to object's rotation)
|
---@param rotation table Desired rotation of the object (defaults to object's rotation)
|
||||||
function spawnHelperObject(name, position, rotation)
|
function spawnHelperObject(name, position, rotation)
|
||||||
local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos","OptionPanelSource")
|
local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos","OptionPanelSource")
|
||||||
|
|
||||||
@ -1427,7 +1427,7 @@ function spawnHelperObject(name, position, rotation)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- removes the specified tool (by name)
|
-- removes the specified tool (by name)
|
||||||
---@param name String Object that should be removed
|
---@param name string Object that should be removed
|
||||||
function removeHelperObject(name)
|
function removeHelperObject(name)
|
||||||
-- links objects name to the respective option name (to grab the GUID for removal)
|
-- links objects name to the respective option name (to grab the GUID for removal)
|
||||||
local referenceTable = {
|
local referenceTable = {
|
||||||
@ -1553,7 +1553,7 @@ function compareVersion(request)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- converts a version number to a string
|
-- converts a version number to a string
|
||||||
---@param version String Version number, separated by dots (e.g. 3.3.1)
|
---@param version string Version number, separated by dots (e.g. 3.3.1)
|
||||||
function convertVersionToNumber(version)
|
function convertVersionToNumber(version)
|
||||||
local major, minor, patch = string.match(version, "(%d+)%.(%d+)%.(%d+)")
|
local major, minor, patch = string.match(version, "(%d+)%.(%d+)%.(%d+)")
|
||||||
return major * 100 + minor * 10 + patch
|
return major * 100 + minor * 10 + patch
|
||||||
|
@ -212,9 +212,9 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- Simple method to check if the given point is in a specified area
|
-- Simple method to check if the given point is in a specified area
|
||||||
---@param point Vector Point to check, only x and z values are relevant
|
---@param point tts__Vector Point to check, only x and z values are relevant
|
||||||
---@param bounds Table Defined area to see if the point is within
|
---@param bounds table Defined area to see if the point is within
|
||||||
---@return Boolean: True if the point is in the area defined by bounds
|
---@return boolean: True if the point is in the area defined by bounds
|
||||||
function inArea(point, bounds)
|
function inArea(point, bounds)
|
||||||
return (point.x < bounds.upperLeft.x
|
return (point.x < bounds.upperLeft.x
|
||||||
and point.x > bounds.lowerRight.x
|
and point.x > bounds.lowerRight.x
|
||||||
|
@ -7,8 +7,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Copies the visibility for the Navigation overlay
|
-- Copies the visibility for the Navigation overlay
|
||||||
---@param startColor String Color of the player to copy from
|
---@param startColor string Color of the player to copy from
|
||||||
---@param targetColor String Color of the targeted player
|
---@param targetColor string Color of the targeted player
|
||||||
NavigationOverlayApi.copyVisibility = function(startColor, targetColor)
|
NavigationOverlayApi.copyVisibility = function(startColor, targetColor)
|
||||||
getNOHandler().call("copyVisibility", {
|
getNOHandler().call("copyVisibility", {
|
||||||
startColor = startColor,
|
startColor = startColor,
|
||||||
@ -17,14 +17,14 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.)
|
-- Changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.)
|
||||||
---@param playerColor String Color of the player to update the visibility for
|
---@param playerColor string Color of the player to update the visibility for
|
||||||
NavigationOverlayApi.cycleVisibility = function(playerColor)
|
NavigationOverlayApi.cycleVisibility = function(playerColor)
|
||||||
getNOHandler().call("cycleVisibility", playerColor)
|
getNOHandler().call("cycleVisibility", playerColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- loads the specified camera for a player
|
-- loads the specified camera for a player
|
||||||
---@param player TTSPlayerInstance Player whose camera should be moved
|
---@param player tts__Player Player whose camera should be moved
|
||||||
---@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to
|
---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to
|
||||||
NavigationOverlayApi.loadCamera = function(player, camera)
|
NavigationOverlayApi.loadCamera = function(player, camera)
|
||||||
getNOHandler().call("loadCameraFromApi", {
|
getNOHandler().call("loadCameraFromApi", {
|
||||||
player = player,
|
player = player,
|
||||||
|
@ -296,8 +296,8 @@ function loadCameraFromApi(params)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- loads the specified camera for a player
|
-- loads the specified camera for a player
|
||||||
---@param player TTSPlayerInstance Player whose camera should be moved
|
---@param player tts__Player Player whose camera should be moved
|
||||||
---@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to
|
---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to
|
||||||
function loadCamera(player, camera)
|
function loadCamera(player, camera)
|
||||||
local lookHere, index, matColor
|
local lookHere, index, matColor
|
||||||
local matColorList = { "White", "Orange", "Green", "Red" }
|
local matColorList = { "White", "Orange", "Green", "Red" }
|
||||||
|
@ -2,7 +2,7 @@ do
|
|||||||
local OptionPanelApi = {}
|
local OptionPanelApi = {}
|
||||||
|
|
||||||
-- loads saved options
|
-- loads saved options
|
||||||
---@param options Table New options table
|
---@param options table New options table
|
||||||
OptionPanelApi.loadSettings = function(options)
|
OptionPanelApi.loadSettings = function(options)
|
||||||
return Global.call("loadSettings", options)
|
return Global.call("loadSettings", options)
|
||||||
end
|
end
|
||||||
|
@ -71,7 +71,7 @@ end
|
|||||||
|
|
||||||
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
|
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
|
||||||
-- data to the local token manager instance.
|
-- data to the local token manager instance.
|
||||||
---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call
|
---@param args table Single-value array holding the GUID of the Custom Data Helper making the call
|
||||||
function updateLocations(args)
|
function updateLocations(args)
|
||||||
customDataHelper = getObjectFromGUID(args[1])
|
customDataHelper = getObjectFromGUID(args[1])
|
||||||
if customDataHelper ~= nil then
|
if customDataHelper ~= nil then
|
||||||
@ -213,7 +213,7 @@ end
|
|||||||
|
|
||||||
-- Checks the given card and adds it to the list of locations tracked for connection purposes.
|
-- Checks the given card and adds it to the list of locations tracked for connection purposes.
|
||||||
-- A card will be added to the tracking if it is a location in the play area (based on centerpoint).
|
-- A card will be added to the tracking if it is a location in the play area (based on centerpoint).
|
||||||
---@param card Object A card object, possibly a location.
|
---@param card tts__GameObject A card object, possibly a location.
|
||||||
function maybeTrackLocation(card)
|
function maybeTrackLocation(card)
|
||||||
-- Collision checks for any part of the card overlap, but our other tracking is centerpoint
|
-- Collision checks for any part of the card overlap, but our other tracking is centerpoint
|
||||||
-- Ignore any collision where the centerpoint isn't in the area
|
-- Ignore any collision where the centerpoint isn't in the area
|
||||||
@ -243,7 +243,7 @@ end
|
|||||||
-- and destruction, as a destroyed object does not trigger collision exit. An object can also be
|
-- and destruction, as a destroyed object does not trigger collision exit. An object can also be
|
||||||
-- deleted mid-drag, but the ordering for drag events means we can't clear those here and those will
|
-- deleted mid-drag, but the ordering for drag events means we can't clear those here and those will
|
||||||
-- be cleared in the next onUpdate() cycle.
|
-- be cleared in the next onUpdate() cycle.
|
||||||
---@param card Object Card to (maybe) stop tracking
|
---@param card tts__GameObject Card to (maybe) stop tracking
|
||||||
function maybeUntrackLocation(card)
|
function maybeUntrackLocation(card)
|
||||||
-- Locked objects no longer collide (hence triggering an exit event) but are still in the play
|
-- Locked objects no longer collide (hence triggering an exit event) but are still in the play
|
||||||
-- area. If the object is now locked, don't remove it.
|
-- area. If the object is now locked, don't remove it.
|
||||||
@ -299,9 +299,9 @@ function rebuildConnectionList()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Extracts the card's icon string into a list of individual location icons
|
-- Extracts the card's icon string into a list of individual location icons
|
||||||
---@param cardId String GUID of the card to pull the icon data from
|
---@param cardId string GUID of the card to pull the icon data from
|
||||||
---@param iconCardList Table A table of icon->GUID list. Mutable, will be updated by this method
|
---@param iconCardList table A table of icon->GUID list. Mutable, will be updated by this method
|
||||||
---@param locData Table A table containing the metadata for the card (for the correct side)
|
---@param locData table A table containing the metadata for the card (for the correct side)
|
||||||
function buildLocListByIcon(cardId, iconCardList, locData)
|
function buildLocListByIcon(cardId, iconCardList, locData)
|
||||||
if locData ~= nil and locData.icons ~= nil then
|
if locData ~= nil and locData.icons ~= nil then
|
||||||
for icon in string.gmatch(locData.icons, "%a+") do
|
for icon in string.gmatch(locData.icons, "%a+") do
|
||||||
@ -315,9 +315,9 @@ end
|
|||||||
|
|
||||||
-- Builds the connections for the given cardID by finding matching icons and adding them to the
|
-- Builds the connections for the given cardID by finding matching icons and adding them to the
|
||||||
-- Playarea's locationConnections table.
|
-- Playarea's locationConnections table.
|
||||||
---@param cardId String GUID of the card to build the connections for
|
---@param cardId string GUID of the card to build the connections for
|
||||||
---@param iconCardList Table A table of icon->GUID List. Used to find matching icons for connections.
|
---@param iconCardList table A table of icon->GUID List. Used to find matching icons for connections.
|
||||||
---@param locData Table A table containing the metadata for the card (for the correct side)
|
---@param locData table A table containing the metadata for the card (for the correct side)
|
||||||
function buildConnection(cardId, iconCardList, locData)
|
function buildConnection(cardId, iconCardList, locData)
|
||||||
if locData ~= nil and locData.connections ~= nil then
|
if locData ~= nil and locData.connections ~= nil then
|
||||||
locationConnections[cardId] = {}
|
locationConnections[cardId] = {}
|
||||||
@ -412,11 +412,11 @@ end
|
|||||||
|
|
||||||
-- Draws a bidirectional location connection between the two cards, adding the lines to do so to the
|
-- Draws a bidirectional location connection between the two cards, adding the lines to do so to the
|
||||||
-- given lines list.
|
-- given lines list.
|
||||||
---@param card1 Object One of the card objects to connect
|
---@param card1 tts__GameObject One of the card objects to connect
|
||||||
---@param card2 Object The other card object to connect
|
---@param card2 tts__GameObject The other card object to connect
|
||||||
---@param vectorOwner Object The object which these lines will be set to. Used for relative
|
---@param vectorOwner tts__GameObject The object which these lines will be set to. Used for relative
|
||||||
--- positioning and scaling, as well as highlighting connections during a drag operation
|
--- positioning and scaling, as well as highlighting connections during a drag operation
|
||||||
---@param lines Table List of vector line elements. Mutable, will be updated to add this connector
|
---@param lines table List of vector line elements. Mutable, will be updated to add this connector
|
||||||
function addBidirectionalVector(card1, card2, vectorOwner, lines)
|
function addBidirectionalVector(card1, card2, vectorOwner, lines)
|
||||||
local cardPos1 = card1.getPosition()
|
local cardPos1 = card1.getPosition()
|
||||||
local cardPos2 = card2.getPosition()
|
local cardPos2 = card2.getPosition()
|
||||||
@ -435,11 +435,11 @@ end
|
|||||||
|
|
||||||
-- Draws a one-way location connection between the two cards, adding the lines to do so to the
|
-- Draws a one-way location connection between the two cards, adding the lines to do so to the
|
||||||
-- given lines list. Arrows will point towards the target card.
|
-- given lines list. Arrows will point towards the target card.
|
||||||
---@param origin Object Origin card in the connection
|
---@param origin tts__GameObject Origin card in the connection
|
||||||
---@param target Object Target card object to connect
|
---@param target tts__GameObject Target card object to connect
|
||||||
---@param vectorOwner Object The object which these lines will be set to. Used for relative
|
---@param vectorOwner tts__GameObject The object which these lines will be set to. Used for relative
|
||||||
--- positioning and scaling, as well as highlighting connections during a drag operation
|
--- positioning and scaling, as well as highlighting connections during a drag operation
|
||||||
---@param lines Table List of vector line elements. Mutable, will be updated to add this connector
|
---@param lines table List of vector line elements. Mutable, will be updated to add this connector
|
||||||
function addOneWayVector(origin, target, vectorOwner, lines)
|
function addOneWayVector(origin, target, vectorOwner, lines)
|
||||||
-- Start with the BiDi then add the arrow lines to it
|
-- Start with the BiDi then add the arrow lines to it
|
||||||
addBidirectionalVector(origin, target, vectorOwner, lines)
|
addBidirectionalVector(origin, target, vectorOwner, lines)
|
||||||
@ -470,11 +470,11 @@ function addOneWayVector(origin, target, vectorOwner, lines)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Draws an arrowhead at the given position.
|
-- Draws an arrowhead at the given position.
|
||||||
---@param arrowheadPos Table Centerpoint of the arrowhead to draw (NOT the tip of the arrow)
|
---@param arrowheadPos table Centerpoint of the arrowhead to draw (NOT the tip of the arrow)
|
||||||
---@param originPos Table Origin point of the connection, used to position the arrow arms
|
---@param originPos table Origin point of the connection, used to position the arrow arms
|
||||||
---@param vectorOwner Object The object which these lines will be set to. Used for relative
|
---@param vectorOwner tts__GameObject The object which these lines will be set to. Used for relative
|
||||||
--- positioning and scaling, as well as highlighting connections during a drag operation
|
--- positioning and scaling, as well as highlighting connections during a drag operation
|
||||||
---@param lines Table List of vector line elements. Mutable, will be updated to add this arrow
|
---@param lines table List of vector line elements. Mutable, will be updated to add this arrow
|
||||||
function addArrowLines(arrowheadPos, originPos, vectorOwner, lines)
|
function addArrowLines(arrowheadPos, originPos, vectorOwner, lines)
|
||||||
local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y",
|
local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y",
|
||||||
-1 * ARROW_ANGLE):add(arrowheadPos)
|
-1 * ARROW_ANGLE):add(arrowheadPos)
|
||||||
@ -493,7 +493,7 @@ end
|
|||||||
|
|
||||||
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
|
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
|
||||||
-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'
|
-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'
|
||||||
---@param playerColor String Color of the player requesting the shift. Used solely to send an error
|
---@param playerColor string Color of the player requesting the shift. Used solely to send an error
|
||||||
--- message in the unlikely case that the scripting zone has been deleted
|
--- message in the unlikely case that the scripting zone has been deleted
|
||||||
function shiftContentsUp(playerColor)
|
function shiftContentsUp(playerColor)
|
||||||
shiftContents(playerColor, "up")
|
shiftContents(playerColor, "up")
|
||||||
@ -528,8 +528,8 @@ end
|
|||||||
|
|
||||||
-- Check to see if the given object is within the bounds of the play area, based solely on the X and
|
-- Check to see if the given object is within the bounds of the play area, based solely on the X and
|
||||||
-- Z coordinates, ignoring height
|
-- Z coordinates, ignoring height
|
||||||
---@param object Object Object to check
|
---@param object tts__GameObject Object to check
|
||||||
---@return. True if the object is inside the play area
|
---@return boolean: True if the object is inside the play area
|
||||||
function isInPlayArea(object)
|
function isInPlayArea(object)
|
||||||
local bounds = self.getBounds()
|
local bounds = self.getBounds()
|
||||||
local position = object.getPosition()
|
local position = object.getPosition()
|
||||||
@ -558,7 +558,7 @@ end
|
|||||||
|
|
||||||
-- Sets this playmat's snap points to limit snapping to locations or not.
|
-- Sets this playmat's snap points to limit snapping to locations or not.
|
||||||
-- If matchTypes is false, snap points will be reset to snap all cards.
|
-- If matchTypes is false, snap points will be reset to snap all cards.
|
||||||
---@param matchTypes Boolean Whether snap points should only snap for the matching card types.
|
---@param matchTypes boolean Whether snap points should only snap for the matching card types.
|
||||||
function setLimitSnapsByType(matchTypes)
|
function setLimitSnapsByType(matchTypes)
|
||||||
local snaps = self.getSnapPoints()
|
local snaps = self.getSnapPoints()
|
||||||
for i, snap in ipairs(snaps) do
|
for i, snap in ipairs(snaps) do
|
||||||
@ -591,7 +591,7 @@ function setConnectionColor(color)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- count victory points on locations in play area
|
-- count victory points on locations in play area
|
||||||
---@param highlightOff Boolean True if highlighting should be enabled
|
---@param highlightOff boolean True if highlighting should be enabled
|
||||||
---@return. Returns the total amount of VP found in the play area
|
---@return. Returns the total amount of VP found in the play area
|
||||||
function countVP(highlightOff)
|
function countVP(highlightOff)
|
||||||
local totalVP = 0
|
local totalVP = 0
|
||||||
@ -617,14 +617,14 @@ function countVP(highlightOff)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- checks if a card has clues on it, returns true if clues are on it
|
-- checks if a card has clues on it, returns true if clues are on it
|
||||||
---@param card TTSObject Card to check for clues
|
---@param card tts__GameObject Card to check for clues
|
||||||
function cardHasClues(card)
|
function cardHasClues(card)
|
||||||
local searchResult = searchLib.onObject(card, "isClue")
|
local searchResult = searchLib.onObject(card, "isClue")
|
||||||
return #searchResult > 0
|
return #searchResult > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- highlights all locations in the play area without metadata
|
-- highlights all locations in the play area without metadata
|
||||||
---@param state Boolean True if highlighting should be enabled
|
---@param state boolean True if highlighting should be enabled
|
||||||
function highlightMissingData(state)
|
function highlightMissingData(state)
|
||||||
for i, obj in pairs(missingData) do
|
for i, obj in pairs(missingData) do
|
||||||
if obj ~= nil then
|
if obj ~= nil then
|
||||||
|
@ -11,20 +11,20 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the current value of the investigator counter from the playmat
|
-- Returns the current value of the investigator counter from the playmat
|
||||||
---@return Integer. Number of investigators currently set on the counter
|
---@return number: Number of investigators currently set on the counter
|
||||||
PlayAreaApi.getInvestigatorCount = function()
|
PlayAreaApi.getInvestigatorCount = function()
|
||||||
return getInvestigatorCounter().getVar("val")
|
return getInvestigatorCounter().getVar("val")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Updates the current value of the investigator counter from the playmat
|
-- Updates the current value of the investigator counter from the playmat
|
||||||
---@param count Number of investigators to set on the counter
|
---@param count number Number of investigators to set on the counter
|
||||||
PlayAreaApi.setInvestigatorCount = function(count)
|
PlayAreaApi.setInvestigatorCount = function(count)
|
||||||
getInvestigatorCounter().call("updateVal", count)
|
getInvestigatorCounter().call("updateVal", count)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
|
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
|
||||||
-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'
|
-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'
|
||||||
---@param playerColor Color Color of the player requesting the shift for messages
|
---@param playerColor string Color of the player requesting the shift for messages
|
||||||
PlayAreaApi.shiftContentsUp = function(playerColor)
|
PlayAreaApi.shiftContentsUp = function(playerColor)
|
||||||
return getPlayArea().call("shiftContentsUp", playerColor)
|
return getPlayArea().call("shiftContentsUp", playerColor)
|
||||||
end
|
end
|
||||||
@ -57,14 +57,14 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Event to be called when the current scenario has changed.
|
-- Event to be called when the current scenario has changed.
|
||||||
---@param scenarioName Name of the new scenario
|
---@param scenarioName string Name of the new scenario
|
||||||
PlayAreaApi.onScenarioChanged = function(scenarioName)
|
PlayAreaApi.onScenarioChanged = function(scenarioName)
|
||||||
getPlayArea().call("onScenarioChanged", scenarioName)
|
getPlayArea().call("onScenarioChanged", scenarioName)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sets this playmat's snap points to limit snapping to locations or not.
|
-- Sets this playmat's snap points to limit snapping to locations or not.
|
||||||
-- If matchTypes is false, snap points will be reset to snap all cards.
|
-- If matchTypes is false, snap points will be reset to snap all cards.
|
||||||
---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types.
|
---@param matchCardTypes boolean Whether snap points should only snap for the matching card types.
|
||||||
PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)
|
PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)
|
||||||
getPlayArea().call("setLimitSnapsByType", matchCardTypes)
|
getPlayArea().call("setLimitSnapsByType", matchCardTypes)
|
||||||
end
|
end
|
||||||
@ -81,13 +81,13 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- highlights all locations in the play area without metadata
|
-- highlights all locations in the play area without metadata
|
||||||
---@param state Boolean True if highlighting should be enabled
|
---@param state boolean True if highlighting should be enabled
|
||||||
PlayAreaApi.highlightMissingData = function(state)
|
PlayAreaApi.highlightMissingData = function(state)
|
||||||
return getPlayArea().call("highlightMissingData", state)
|
return getPlayArea().call("highlightMissingData", state)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- highlights all locations in the play area with VP
|
-- highlights all locations in the play area with VP
|
||||||
---@param state Boolean True if highlighting should be enabled
|
---@param state boolean True if highlighting should be enabled
|
||||||
PlayAreaApi.highlightCountedVP = function(state)
|
PlayAreaApi.highlightCountedVP = function(state)
|
||||||
return getPlayArea().call("countVP", state)
|
return getPlayArea().call("countVP", state)
|
||||||
end
|
end
|
||||||
@ -107,7 +107,7 @@ do
|
|||||||
|
|
||||||
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
|
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
|
||||||
-- data to the local token manager instance.
|
-- data to the local token manager instance.
|
||||||
---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call
|
---@param args table Single-value array holding the GUID of the Custom Data Helper making the call
|
||||||
PlayAreaApi.updateLocations = function(args)
|
PlayAreaApi.updateLocations = function(args)
|
||||||
getPlayArea().call("updateLocations", args)
|
getPlayArea().call("updateLocations", args)
|
||||||
end
|
end
|
||||||
|
@ -131,8 +131,8 @@ function highlightTabAndItem()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- loops through an XML table and returns the specified object
|
-- loops through an XML table and returns the specified object
|
||||||
---@param ui Table XmlTable (get this via getXmlTable)
|
---@param ui table XmlTable (get this via getXmlTable)
|
||||||
---@param id String Id of the object to return
|
---@param id string Id of the object to return
|
||||||
function getXmlTableElementById(ui, id)
|
function getXmlTableElementById(ui, id)
|
||||||
for _, obj in ipairs(ui) do
|
for _, obj in ipairs(ui) do
|
||||||
if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end
|
if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end
|
||||||
|
@ -15,7 +15,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- plays the by name requested sound
|
-- plays the by name requested sound
|
||||||
---@param soundName String Name of the sound to play
|
---@param soundName string Name of the sound to play
|
||||||
SoundCubeApi.playSoundByName = function(soundName)
|
SoundCubeApi.playSoundByName = function(soundName)
|
||||||
playTriggerEffect(soundIndices[soundName])
|
playTriggerEffect(soundIndices[soundName])
|
||||||
end
|
end
|
||||||
|
@ -7,13 +7,13 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- triggers an update of the Victory count
|
-- triggers an update of the Victory count
|
||||||
---@param delay Number Delay in seconds after which the update call is executed
|
---@param delay number Delay in seconds after which the update call is executed
|
||||||
VictoryDisplayApi.update = function(delay)
|
VictoryDisplayApi.update = function(delay)
|
||||||
getVictoryDisplay().call("startUpdate", delay)
|
getVictoryDisplay().call("startUpdate", delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- moves a card to the victory display (in the first empty spot)
|
-- moves a card to the victory display (in the first empty spot)
|
||||||
---@param object Object Object that should be checked and potentially moved
|
---@param object tts__GameObject Object that should be checked and potentially moved
|
||||||
VictoryDisplayApi.placeCard = function(object)
|
VictoryDisplayApi.placeCard = function(object)
|
||||||
if object ~= nil and object.tag == "Card" then
|
if object ~= nil and object.tag == "Card" then
|
||||||
getVictoryDisplay().call("placeCard", object)
|
getVictoryDisplay().call("placeCard", object)
|
||||||
|
@ -135,8 +135,8 @@ do
|
|||||||
-- the work once a card has hit an area where it might spawn tokens. It will check to see if
|
-- the work once a card has hit an area where it might spawn tokens. It will check to see if
|
||||||
-- the card has already spawned, find appropriate data from either the uses metadata or the Data
|
-- the card has already spawned, find appropriate data from either the uses metadata or the Data
|
||||||
-- Helper, and spawn the tokens.
|
-- Helper, and spawn the tokens.
|
||||||
---@param card Object Card to maybe spawn tokens for
|
---@param card tts__GameObject Card to maybe spawn tokens for
|
||||||
---@param extraUses Table A table of <use type>=<count> which will modify the number of tokens
|
---@param extraUses table A table of <use type>=<count> which will modify the number of tokens
|
||||||
--- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1
|
--- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1
|
||||||
TokenManager.spawnForCard = function(card, extraUses)
|
TokenManager.spawnForCard = function(card, extraUses)
|
||||||
if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then
|
if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then
|
||||||
@ -151,13 +151,12 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Spawns a set of tokens on the given card.
|
-- Spawns a set of tokens on the given card.
|
||||||
---@param card Object Card to spawn tokens on
|
---@param card tts__GameObject Card to spawn tokens on
|
||||||
---@param tokenType String Type of token to spawn, valid values are "damage", "horror",
|
---@param tokenType string Type of token to spawn, for example "damage", "horror" or "resource"
|
||||||
-- "resource", "doom", or "clue"
|
---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the
|
||||||
---@param tokenCount Number How many tokens to spawn. For damage or horror this value will be set to the
|
|
||||||
-- spawned state object rather than spawning multiple tokens
|
-- spawned state object rather than spawning multiple tokens
|
||||||
---@param shiftDown Number An offset for the z-value of this group of tokens
|
---@param shiftDown? number An offset for the z-value of this group of tokens
|
||||||
---@param subType String Subtype of token to spawn. This will only differ from the tokenName for resource tokens
|
---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens
|
||||||
TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)
|
TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)
|
||||||
local optionPanel = optionPanelApi.getOptions()
|
local optionPanel = optionPanelApi.getOptions()
|
||||||
|
|
||||||
@ -174,10 +173,10 @@ do
|
|||||||
|
|
||||||
-- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror
|
-- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror
|
||||||
-- tokens.
|
-- tokens.
|
||||||
---@param card Object Card to spawn tokens on
|
---@param card tts__GameObject Card to spawn tokens on
|
||||||
---@param tokenType String type of token to spawn, valid values are "damage" and "horror". Other
|
---@param tokenType string type of token to spawn, valid values are "damage" and "horror". Other
|
||||||
-- types should use spawnMultipleTokens()
|
-- types should use spawnMultipleTokens()
|
||||||
---@param tokenValue Number Value to set the damage/horror to
|
---@param tokenValue number Value to set the damage/horror to
|
||||||
TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)
|
TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)
|
||||||
if tokenValue < 1 or tokenValue > 50 then return end
|
if tokenValue < 1 or tokenValue > 50 then return end
|
||||||
|
|
||||||
@ -195,11 +194,11 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Spawns a number of tokens.
|
-- Spawns a number of tokens.
|
||||||
---@param tokenType String type of token to spawn, valid values are resource", "doom", or "clue".
|
---@param tokenType string type of token to spawn, valid values are resource", "doom", or "clue".
|
||||||
-- Other types should use spawnCounterToken()
|
-- Other types should use spawnCounterToken()
|
||||||
---@param tokenCount Number How many tokens to spawn
|
---@param tokenCount number How many tokens to spawn
|
||||||
---@param shiftDown Number An offset for the z-value of this group of tokens
|
---@param shiftDown? number An offset for the z-value of this group of tokens
|
||||||
---@param subType String Subtype of token to spawn. This will only differ from the tokenName for resource tokens
|
---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens
|
||||||
TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)
|
TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)
|
||||||
-- not checking the max at this point since clue offsets are calculated dynamically
|
-- not checking the max at this point since clue offsets are calculated dynamically
|
||||||
if tokenCount < 1 then return end
|
if tokenCount < 1 then return end
|
||||||
@ -253,12 +252,12 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Spawns a single token at the given global position by copying it from the template bag.
|
-- Spawns a single token at the given global position by copying it from the template bag.
|
||||||
---@param position Global position to spawn the token
|
---@param position tts__Vector Global position to spawn the token
|
||||||
---@param tokenType String type of token to spawn, valid values are "damage", "horror",
|
---@param tokenType string type of token to spawn, valid values are "damage", "horror",
|
||||||
-- "resource", "doom", or "clue"
|
-- "resource", "doom", or "clue"
|
||||||
---@param rotation Vector Rotation to be used for the new token. Only the y-value will be used,
|
---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,
|
||||||
-- x and z will use the default rotation from the source bag
|
-- x and z will use the default rotation from the source bag
|
||||||
---@param callback function A callback function triggered after the new token is spawned
|
---@param callback? function A callback function triggered after the new token is spawned
|
||||||
TokenManager.spawnToken = function(position, tokenType, rotation, callback)
|
TokenManager.spawnToken = function(position, tokenType, rotation, callback)
|
||||||
internal.initTokenTemplates()
|
internal.initTokenTemplates()
|
||||||
local loadTokenType = tokenType
|
local loadTokenType = tokenType
|
||||||
@ -292,9 +291,9 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Checks a card for metadata to maybe replenish it
|
-- Checks a card for metadata to maybe replenish it
|
||||||
---@param card Object Card object to be replenished
|
---@param card tts__GameObject Card object to be replenished
|
||||||
---@param uses Table The already decoded metadata.uses (to avoid decoding again)
|
---@param uses table The already decoded metadata.uses (to avoid decoding again)
|
||||||
---@param mat Object The playmat the card is placed on (for rotation and casting)
|
---@param mat tts__GameObject The playmat the card is placed on (for rotation and casting)
|
||||||
TokenManager.maybeReplenishCard = function(card, uses, mat)
|
TokenManager.maybeReplenishCard = function(card, uses, mat)
|
||||||
-- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)
|
-- TODO: support for cards with multiple uses AND replenish (as of yet, no official card needs that)
|
||||||
if uses[1].count and uses[1].replenish then
|
if uses[1].count and uses[1].replenish then
|
||||||
@ -304,13 +303,13 @@ do
|
|||||||
|
|
||||||
-- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some
|
-- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some
|
||||||
-- callers.
|
-- callers.
|
||||||
---@param card Object Card object to reset the tokens for
|
---@param card tts__GameObject Card object to reset the tokens for
|
||||||
TokenManager.resetTokensSpawned = function(card)
|
TokenManager.resetTokensSpawned = function(card)
|
||||||
tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())
|
tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Pushes new player card data into the local copy of the Data Helper player data.
|
-- Pushes new player card data into the local copy of the Data Helper player data.
|
||||||
---@param dataTable Table Key/Value pairs following the DataHelper style
|
---@param dataTable table Key/Value pairs following the DataHelper style
|
||||||
TokenManager.addPlayerCardData = function(dataTable)
|
TokenManager.addPlayerCardData = function(dataTable)
|
||||||
internal.initDataHelperData()
|
internal.initDataHelperData()
|
||||||
for k, v in pairs(dataTable) do
|
for k, v in pairs(dataTable) do
|
||||||
@ -319,7 +318,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Pushes new location data into the local copy of the Data Helper location data.
|
-- Pushes new location data into the local copy of the Data Helper location data.
|
||||||
---@param dataTable Table Key/Value pairs following the DataHelper style
|
---@param dataTable table Key/Value pairs following the DataHelper style
|
||||||
TokenManager.addLocationData = function(dataTable)
|
TokenManager.addLocationData = function(dataTable)
|
||||||
internal.initDataHelperData()
|
internal.initDataHelperData()
|
||||||
for k, v in pairs(dataTable) do
|
for k, v in pairs(dataTable) do
|
||||||
@ -328,8 +327,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Checks to see if the given card has location data in the DataHelper
|
-- Checks to see if the given card has location data in the DataHelper
|
||||||
---@param card Object Card to check for data
|
---@param card tts__GameObject Card to check for data
|
||||||
---@return Boolean True if this card has data in the helper, false otherwise
|
---@return boolean: True if this card has data in the helper, false otherwise
|
||||||
TokenManager.hasLocationData = function(card)
|
TokenManager.hasLocationData = function(card)
|
||||||
internal.initDataHelperData()
|
internal.initDataHelperData()
|
||||||
return internal.getLocationData(card) ~= nil
|
return internal.getLocationData(card) ~= nil
|
||||||
@ -359,8 +358,8 @@ do
|
|||||||
|
|
||||||
-- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state
|
-- Spawn tokens for a card based on the uses metadata. This will consider the face up/down state
|
||||||
-- of the card for both locations and standard cards.
|
-- of the card for both locations and standard cards.
|
||||||
---@param card Object Card to maybe spawn tokens for
|
---@param card tts__GameObject Card to maybe spawn tokens for
|
||||||
---@param extraUses Table A table of <use type>=<count> which will modify the number of tokens
|
---@param extraUses table A table of <use type>=<count> which will modify the number of tokens
|
||||||
--- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1
|
--- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1
|
||||||
internal.spawnTokensFromUses = function(card, extraUses)
|
internal.spawnTokensFromUses = function(card, extraUses)
|
||||||
local uses = internal.getUses(card)
|
local uses = internal.getUses(card)
|
||||||
@ -382,7 +381,7 @@ do
|
|||||||
|
|
||||||
-- Spawn tokens for a card based on the data helper data. This will consider the face up/down state
|
-- Spawn tokens for a card based on the data helper data. This will consider the face up/down state
|
||||||
-- of the card for both locations and standard cards.
|
-- of the card for both locations and standard cards.
|
||||||
---@param card Object Card to maybe spawn tokens for
|
---@param card tts__GameObject Card to maybe spawn tokens for
|
||||||
internal.spawnTokensFromDataHelper = function(card)
|
internal.spawnTokensFromDataHelper = function(card)
|
||||||
internal.initDataHelperData()
|
internal.initDataHelperData()
|
||||||
local playerData = internal.getPlayerCardData(card)
|
local playerData = internal.getPlayerCardData(card)
|
||||||
@ -396,8 +395,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Spawn tokens for a player card using data retrieved from the Data Helper.
|
-- Spawn tokens for a player card using data retrieved from the Data Helper.
|
||||||
---@param card Object Card to maybe spawn tokens for
|
---@param card tts__GameObject Card to maybe spawn tokens for
|
||||||
---@param playerData Table Player card data structure retrieved from the DataHelper. Should be
|
---@param playerData table Player card data structure retrieved from the DataHelper. Should be
|
||||||
-- the right data for this card.
|
-- the right data for this card.
|
||||||
internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)
|
internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)
|
||||||
local token = playerData.tokenType
|
local token = playerData.tokenType
|
||||||
@ -407,8 +406,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Spawn tokens for a location using data retrieved from the Data Helper.
|
-- Spawn tokens for a location using data retrieved from the Data Helper.
|
||||||
---@param card Object Card to maybe spawn tokens for
|
---@param card tts__GameObject Card to maybe spawn tokens for
|
||||||
---@param locationData Table Location data structure retrieved from the DataHelper. Should be
|
---@param locationData table Location data structure retrieved from the DataHelper. Should be
|
||||||
-- the right data for this card.
|
-- the right data for this card.
|
||||||
internal.spawnLocationTokensFromDataHelper = function(card, locationData)
|
internal.spawnLocationTokensFromDataHelper = function(card, locationData)
|
||||||
local clueCount = internal.getClueCountFromData(card, locationData)
|
local clueCount = internal.getClueCountFromData(card, locationData)
|
||||||
@ -447,7 +446,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Gets the right uses structure for this card, based on metadata and face up/down state
|
-- Gets the right uses structure for this card, based on metadata and face up/down state
|
||||||
---@param card Object Card to pull the uses from
|
---@param card tts__GameObject Card to pull the uses from
|
||||||
internal.getUses = function(card)
|
internal.getUses = function(card)
|
||||||
local metadata = JSON.decode(card.getGMNotes()) or { }
|
local metadata = JSON.decode(card.getGMNotes()) or { }
|
||||||
if metadata.type == "Location" then
|
if metadata.type == "Location" then
|
||||||
@ -464,9 +463,9 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Dynamically create positions for clues on a card.
|
-- Dynamically create positions for clues on a card.
|
||||||
---@param card Object Card the clues will be placed on
|
---@param card tts__GameObject Card the clues will be placed on
|
||||||
---@param count Integer How many clues?
|
---@param count number How many clues?
|
||||||
---@return Table Array of global positions to spawn the clues at
|
---@return table: Array of global positions to spawn the clues at
|
||||||
internal.buildClueOffsets = function(card, count)
|
internal.buildClueOffsets = function(card, count)
|
||||||
local pos = card.getPosition()
|
local pos = card.getPosition()
|
||||||
local cluePositions = { }
|
local cluePositions = { }
|
||||||
@ -478,9 +477,9 @@ do
|
|||||||
return cluePositions
|
return cluePositions
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param card Object Card object to be replenished
|
---@param card tts__GameObject Card object to be replenished
|
||||||
---@param uses Table The already decoded metadata.uses (to avoid decoding again)
|
---@param uses table The already decoded metadata.uses (to avoid decoding again)
|
||||||
---@param mat Object The playmat the card is placed on (for rotation and casting)
|
---@param mat tts__GameObject The playmat the card is placed on (for rotation and casting)
|
||||||
internal.replenishTokens = function(card, uses, mat)
|
internal.replenishTokens = function(card, uses, mat)
|
||||||
local cardPos = card.getPosition()
|
local cardPos = card.getPosition()
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ do
|
|||||||
|
|
||||||
-- Kicks off the tour by initializing the card and camera hook. A callback on the hook creation
|
-- Kicks off the tour by initializing the card and camera hook. A callback on the hook creation
|
||||||
-- will then show the first card.
|
-- will then show the first card.
|
||||||
---@param playerColor String Player color to start the tour for
|
---@param playerColor string Player color to start the tour for
|
||||||
TourManager.startTour = function(playerColor)
|
TourManager.startTour = function(playerColor)
|
||||||
tourState[playerColor] = {
|
tourState[playerColor] = {
|
||||||
currentCardIndex = 1
|
currentCardIndex = 1
|
||||||
@ -83,7 +83,7 @@ do
|
|||||||
|
|
||||||
-- Shows the next card in the tour script. This method is exposed (rather than being part of
|
-- Shows the next card in the tour script. This method is exposed (rather than being part of
|
||||||
-- internal) because the XMLUI callbacks expect the method to be on the object directly.
|
-- internal) because the XMLUI callbacks expect the method to be on the object directly.
|
||||||
---@param player Player object to show the next card for, provided by XMLUI callback
|
---@param player tts__Player object to show the next card for, provided by XMLUI callback
|
||||||
function nextCard(player)
|
function nextCard(player)
|
||||||
internal.hideCard(player.color)
|
internal.hideCard(player.color)
|
||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
@ -98,7 +98,7 @@ do
|
|||||||
|
|
||||||
-- Ends the tour and cleans up the camera. This method is exposed (rather than being part of
|
-- Ends the tour and cleans up the camera. This method is exposed (rather than being part of
|
||||||
-- internal) because the XMLUI callbacks expect the method to be on the object directly.
|
-- internal) because the XMLUI callbacks expect the method to be on the object directly.
|
||||||
---@param player Player object to end the tour for, provided by XMLUI callback
|
---@param player tts__Player object to end the tour for, provided by XMLUI callback
|
||||||
function stopTour(player)
|
function stopTour(player)
|
||||||
internal.hideCard(player.color)
|
internal.hideCard(player.color)
|
||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
@ -108,7 +108,7 @@ do
|
|||||||
|
|
||||||
-- Updates the card UI for the script at the current index, moves the camera to the proper
|
-- Updates the card UI for the script at the current index, moves the camera to the proper
|
||||||
-- position, and shows the card.
|
-- position, and shows the card.
|
||||||
---@param playerColor String Player color to show the current card for
|
---@param playerColor string Player color to show the current card for
|
||||||
internal.showCurrentCard = function(playerColor)
|
internal.showCurrentCard = function(playerColor)
|
||||||
internal.updateCardDisplay(playerColor)
|
internal.updateCardDisplay(playerColor)
|
||||||
local delay = 0
|
local delay = 0
|
||||||
@ -143,7 +143,7 @@ do
|
|||||||
|
|
||||||
-- Hides the current card being shown to a player. This can be in preparation for showing the
|
-- Hides the current card being shown to a player. This can be in preparation for showing the
|
||||||
-- next card, or ending the tour.
|
-- next card, or ending the tour.
|
||||||
---@param playerColor String Player color to hide the current card for
|
---@param playerColor string Player color to hide the current card for
|
||||||
internal.hideCard = function(playerColor)
|
internal.hideCard = function(playerColor)
|
||||||
Global.UI.hide(internal.getUiId(CARD_ID, playerColor))
|
Global.UI.hide(internal.getUiId(CARD_ID, playerColor))
|
||||||
end
|
end
|
||||||
@ -151,7 +151,7 @@ do
|
|||||||
-- Cleans up all the various resources associated with the tour, and (hopefully) resets the
|
-- Cleans up all the various resources associated with the tour, and (hopefully) resets the
|
||||||
-- camera to the default position. Camera handling is erratic, the final card in the script
|
-- camera to the default position. Camera handling is erratic, the final card in the script
|
||||||
-- should include instructions for the player to fix it.
|
-- should include instructions for the player to fix it.
|
||||||
---@param playerColor String Player color to clean up
|
---@param playerColor string Player color to clean up
|
||||||
internal.finalizeTour = function(playerColor)
|
internal.finalizeTour = function(playerColor)
|
||||||
local cameraHook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)
|
local cameraHook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)
|
||||||
cameraHook.destruct()
|
cameraHook.destruct()
|
||||||
@ -163,7 +163,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Updates the card UI to show the appropriate card configuration.
|
-- Updates the card UI to show the appropriate card configuration.
|
||||||
---@param playerColor String Player color to update card for
|
---@param playerColor string Player color to update card for
|
||||||
internal.updateCardDisplay = function(playerColor)
|
internal.updateCardDisplay = function(playerColor)
|
||||||
local index = tourState[playerColor].currentCardIndex
|
local index = tourState[playerColor].currentCardIndex
|
||||||
Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), "image", "Inv-" .. TOUR_SCRIPT[index].narrator)
|
Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), "image", "Inv-" .. TOUR_SCRIPT[index].narrator)
|
||||||
@ -195,7 +195,7 @@ do
|
|||||||
-- user's view around the table. This should be called only at the beginning of the tour. Once
|
-- user's view around the table. This should be called only at the beginning of the tour. Once
|
||||||
-- creation is complete the user's camera will be attached to the hook and the first card will be
|
-- creation is complete the user's camera will be attached to the hook and the first card will be
|
||||||
-- shown.
|
-- shown.
|
||||||
---@param playerColor String Player color to create the hook for
|
---@param playerColor string Player color to create the hook for
|
||||||
internal.createCameraHook = function(playerColor)
|
internal.createCameraHook = function(playerColor)
|
||||||
local hookData = {
|
local hookData = {
|
||||||
Name = "BlockSquare",
|
Name = "BlockSquare",
|
||||||
@ -225,7 +225,7 @@ do
|
|||||||
|
|
||||||
-- Callback for creation of the camera hook object. Will attach the camera and show the current
|
-- Callback for creation of the camera hook object. Will attach the camera and show the current
|
||||||
-- (presumably first) card.
|
-- (presumably first) card.
|
||||||
---@param hook Created object
|
---@param hook tts__GameObject Created object
|
||||||
internal.onHookCreated = function(hook)
|
internal.onHookCreated = function(hook)
|
||||||
local playerColor = hook.getGMNotes()
|
local playerColor = hook.getGMNotes()
|
||||||
tourState[playerColor].cameraHookGuid = hook.getGUID()
|
tourState[playerColor].cameraHookGuid = hook.getGUID()
|
||||||
@ -238,7 +238,7 @@ do
|
|||||||
|
|
||||||
-- Creates an XMLUI entry in Global for a player-specific tour card. Dynamically creating this
|
-- Creates an XMLUI entry in Global for a player-specific tour card. Dynamically creating this
|
||||||
-- is somewhat complex, but ensures we can properly handle any player color.
|
-- is somewhat complex, but ensures we can properly handle any player color.
|
||||||
---@param playerColor String Player color to create the card for
|
---@param playerColor string Player color to create the card for
|
||||||
internal.createTourCard = function(playerColor)
|
internal.createTourCard = function(playerColor)
|
||||||
-- Make sure the card doesn't exist before we create a new one
|
-- Make sure the card doesn't exist before we create a new one
|
||||||
if Global.UI.getAttributes(internal.getUiId(CARD_ID, playerColor)) ~= nil then return end
|
if Global.UI.getAttributes(internal.getUiId(CARD_ID, playerColor)) ~= nil then return end
|
||||||
@ -261,8 +261,8 @@ do
|
|||||||
|
|
||||||
-- Panels don't cause their children to inherit their visibility value, so this recurses down the
|
-- Panels don't cause their children to inherit their visibility value, so this recurses down the
|
||||||
-- XML table to set all children to the same visibility.
|
-- XML table to set all children to the same visibility.
|
||||||
---@param xmlUi Table. Lua table describing the XML
|
---@param xmlUi table Lua table describing the XML
|
||||||
---@param playerColor String. String color of the player to make this visible for
|
---@param playerColor string String color of the player to make this visible for
|
||||||
internal.setDeepVisibility = function(xmlUi, playerColor)
|
internal.setDeepVisibility = function(xmlUi, playerColor)
|
||||||
xmlUi.attributes.visibility = "" .. playerColor
|
xmlUi.attributes.visibility = "" .. playerColor
|
||||||
if xmlUi.children ~= nil then
|
if xmlUi.children ~= nil then
|
||||||
|
@ -5,7 +5,6 @@ local uniqueWeaknessList = { }
|
|||||||
local cycleIndex = { }
|
local cycleIndex = { }
|
||||||
|
|
||||||
local indexingDone = false
|
local indexingDone = false
|
||||||
local allowRemoval = false
|
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
self.addContextMenuItem("Rebuild Index", startIndexBuild)
|
self.addContextMenuItem("Rebuild Index", startIndexBuild)
|
||||||
@ -47,25 +46,17 @@ function clearIndexes()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Clears the bag indexes and starts the coroutine to rebuild the indexes
|
-- Clears the bag indexes and starts the coroutine to rebuild the indexes
|
||||||
function startIndexBuild(playerColor)
|
function startIndexBuild()
|
||||||
clearIndexes()
|
clearIndexes()
|
||||||
startLuaCoroutine(self, "buildIndex")
|
startLuaCoroutine(self, "buildIndex")
|
||||||
end
|
end
|
||||||
|
|
||||||
function onObjectLeaveContainer(container, object)
|
function onObjectLeaveContainer(container, _)
|
||||||
if (container == self and not allowRemoval) then
|
if container == self then
|
||||||
broadcastToAll(
|
broadcastToAll("Removing cards from the All Player Cards bag may break some functions.", "Red")
|
||||||
"Removing cards from the All Player Cards bag may break some functions. Please replace the card.",
|
|
||||||
{0.9, 0.2, 0.2}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug option to suppress the warning when cards are removed from the bag
|
|
||||||
function setAllowCardRemoval()
|
|
||||||
allowRemoval = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create the card indexes by iterating all cards in the bag, parsing their
|
-- Create the card indexes by iterating all cards in the bag, parsing their
|
||||||
-- metadata, and creating the keyed lookup tables for the cards. This is a
|
-- metadata, and creating the keyed lookup tables for the cards. This is a
|
||||||
-- coroutine which will spread the workload by processing 20 cards before
|
-- coroutine which will spread the workload by processing 20 cards before
|
||||||
@ -124,8 +115,8 @@ function buildIndex()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Adds a card to any indexes it should be a part of, based on its metadata.
|
-- Adds a card to any indexes it should be a part of, based on its metadata.
|
||||||
---@param cardData: TTS object data for the card
|
---@param cardData table TTS object data for the card
|
||||||
---@param cardMetadata: SCED metadata for the card
|
---@param cardMetadata table SCED metadata for the card
|
||||||
function addCardToIndex(cardData, cardMetadata)
|
function addCardToIndex(cardData, cardMetadata)
|
||||||
-- use the ZoopGuid as fallback if no id present
|
-- use the ZoopGuid as fallback if no id present
|
||||||
if cardMetadata.id == nil and cardMetadata.TtsZoopGuid then
|
if cardMetadata.id == nil and cardMetadata.TtsZoopGuid then
|
||||||
|
@ -21,7 +21,7 @@ do
|
|||||||
-- it will be removed from the list and cannot be selected again until a reload
|
-- it will be removed from the list and cannot be selected again until a reload
|
||||||
-- occurs or the indexes are rebuilt, which will refresh the list to include all
|
-- occurs or the indexes are rebuilt, which will refresh the list to include all
|
||||||
-- weaknesses.
|
-- weaknesses.
|
||||||
---@return id String ID of the selected weakness.
|
---@return string: ID of the selected weakness.
|
||||||
AllCardsBagApi.getRandomWeaknessId = function()
|
AllCardsBagApi.getRandomWeaknessId = function()
|
||||||
return getAllCardsBag().call("getRandomWeaknessId")
|
return getAllCardsBag().call("getRandomWeaknessId")
|
||||||
end
|
end
|
||||||
@ -41,8 +41,8 @@ do
|
|||||||
|
|
||||||
-- Searches the bag for cards which match the given name and returns a list. Note that this is
|
-- Searches the bag for cards which match the given name and returns a list. Note that this is
|
||||||
-- an O(n) search without index support. It may be slow.
|
-- an O(n) search without index support. It may be slow.
|
||||||
---@param name String or string fragment to search for names
|
---@param name string or string fragment to search for names
|
||||||
---@param exact Boolean Whether the name match should be exact
|
---@param exact boolean Whether the name match should be exact
|
||||||
AllCardsBagApi.getCardsByName = function(name, exact)
|
AllCardsBagApi.getCardsByName = function(name, exact)
|
||||||
return getAllCardsBag().call("getCardsByName", {name = name, exact = exact})
|
return getAllCardsBag().call("getCardsByName", {name = name, exact = exact})
|
||||||
end
|
end
|
||||||
@ -52,9 +52,9 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns a list of cards from the bag matching a class and level (0 or upgraded)
|
-- Returns a list of cards from the bag matching a class and level (0 or upgraded)
|
||||||
---@param class String class to retrieve ("Guardian", "Seeker", etc)
|
---@param class string class to retrieve ("Guardian", "Seeker", etc)
|
||||||
---@param upgraded Boolean true for upgraded cards (Level 1-5), false for Level 0
|
---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0
|
||||||
---@return: If the indexes are still being constructed, returns an empty table.
|
---@return table: If the indexes are still being constructed, returns an empty table.
|
||||||
-- Otherwise, a list of tables, each with the following fields
|
-- Otherwise, a list of tables, each with the following fields
|
||||||
-- cardData: TTS object data, suitable for spawning the card
|
-- cardData: TTS object data, suitable for spawning the card
|
||||||
-- cardMetadata: Table of parsed metadata
|
-- cardMetadata: Table of parsed metadata
|
||||||
|
@ -386,8 +386,7 @@ function updateStarterModeButtons()
|
|||||||
createInvestigatorModeButtons()
|
createInvestigatorModeButtons()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clears the table and updates positions based on scale. Should be called before ANY card
|
-- Clears the table and updates positions based on scale (should be called before ANY card placement)
|
||||||
-- placement
|
|
||||||
function prepareToPlaceCards()
|
function prepareToPlaceCards()
|
||||||
deleteAll()
|
deleteAll()
|
||||||
scalePositions()
|
scalePositions()
|
||||||
@ -422,7 +421,7 @@ end
|
|||||||
|
|
||||||
-- Spawn an investigator group, based on the current UI setting for either investigators or starter
|
-- Spawn an investigator group, based on the current UI setting for either investigators or starter
|
||||||
-- decks.
|
-- decks.
|
||||||
---@param groupName String. Name of the group to spawn, matching a key in InvestigatorPanelData
|
---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData
|
||||||
function spawnInvestigatorGroup(groupName)
|
function spawnInvestigatorGroup(groupName)
|
||||||
local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS
|
local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS
|
||||||
prepareToPlaceCards()
|
prepareToPlaceCards()
|
||||||
@ -437,7 +436,7 @@ end
|
|||||||
|
|
||||||
-- Spawn cards for all investigators in the given group. This creates piles for all defined
|
-- Spawn cards for all investigators in the given group. This creates piles for all defined
|
||||||
-- investigator cards and minicards as well as the signature cards.
|
-- investigator cards and minicards as well as the signature cards.
|
||||||
---@param groupName String. Name of the group to spawn, matching a key in InvestigatorPanelData
|
---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData
|
||||||
function spawnInvestigators(groupName)
|
function spawnInvestigators(groupName)
|
||||||
if INVESTIGATOR_GROUPS[groupName] == nil then
|
if INVESTIGATOR_GROUPS[groupName] == nil then
|
||||||
printToAll("No " .. groupName .. " data yet")
|
printToAll("No " .. groupName .. " data yet")
|
||||||
@ -480,11 +479,9 @@ function getInvestigatorRowStartPos(investigatorCount, row)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Creates the spawn spec for the investigator's signature cards.
|
-- Creates the spawn spec for the investigator's signature cards.
|
||||||
---@param investigatorName String. Name of the investigator, matching a key in
|
---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData
|
||||||
--- InvestigatorPanelData
|
---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS
|
||||||
---@param investigatorData Table. Spawn definition for the investigator, retrieved from
|
---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below
|
||||||
--- INVESTIGATORS
|
|
||||||
---@param position Vector. Where to spawn the minicard; investigagor cards will be placed below
|
|
||||||
function buildInvestigatorSpawnSpec(investigatorName, investigatorData, position)
|
function buildInvestigatorSpawnSpec(investigatorName, investigatorData, position)
|
||||||
local sigPos = Vector(position):add(investigatorSignatureOffset)
|
local sigPos = Vector(position):add(investigatorSignatureOffset)
|
||||||
local spawns = buildCommonSpawnSpec(investigatorName, investigatorData, position)
|
local spawns = buildCommonSpawnSpec(investigatorName, investigatorData, position)
|
||||||
@ -501,12 +498,10 @@ end
|
|||||||
-- Builds the spawn specs for minicards and investigator cards. These are common enough to be
|
-- Builds the spawn specs for minicards and investigator cards. These are common enough to be
|
||||||
-- shared, and will only differ in whether they spawn the full stack of possible investigator and
|
-- shared, and will only differ in whether they spawn the full stack of possible investigator and
|
||||||
-- minicards, or only the first of each.
|
-- minicards, or only the first of each.
|
||||||
---@param investigatorName String. Name of the investigator, matching a key in
|
---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData
|
||||||
--- InvestigatorPanelData
|
---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS
|
||||||
---@param investigatorData Table. Spawn definition for the investigator, retrieved from
|
---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below
|
||||||
--- INVESTIGATORS
|
---@param oneCardOnly? boolean If true, will spawn only the first card in the investigator card
|
||||||
---@param position Vector. Where to spawn the minicard; investigagor cards will be placed below
|
|
||||||
---@param oneCardOnly Boolean. If true, will spawn only the first card in the investigator card
|
|
||||||
--- and minicard lists. Otherwise, spawn them all in a deck
|
--- and minicard lists. Otherwise, spawn them all in a deck
|
||||||
function buildCommonSpawnSpec(investigatorName, investigatorData, position, oneCardOnly)
|
function buildCommonSpawnSpec(investigatorName, investigatorData, position, oneCardOnly)
|
||||||
local cardPos = Vector(position):add(investigatorCardOffset)
|
local cardPos = Vector(position):add(investigatorCardOffset)
|
||||||
@ -528,7 +523,7 @@ end
|
|||||||
|
|
||||||
-- Spawns all starter decks (single minicard and investigator card, plus the starter deck) for
|
-- Spawns all starter decks (single minicard and investigator card, plus the starter deck) for
|
||||||
-- investigators in the given group.
|
-- investigators in the given group.
|
||||||
---@param groupName String. Name of the group to spawn, matching a key in InvestigatorPanelData
|
---@param groupName string Name of the group to spawn, matching a key in InvestigatorPanelData
|
||||||
function spawnStarters(groupName)
|
function spawnStarters(groupName)
|
||||||
local col = 1
|
local col = 1
|
||||||
local row = 1
|
local row = 1
|
||||||
@ -547,8 +542,7 @@ function spawnStarters(groupName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Spawns the defined starter deck for the given investigator's.
|
-- Spawns the defined starter deck for the given investigator's.
|
||||||
---@param investigatorName String. Name of the investigator, matching a key in
|
---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData
|
||||||
--- InvestigatorPanelData
|
|
||||||
function spawnStarterDeck(investigatorName, investigatorData, position)
|
function spawnStarterDeck(investigatorName, investigatorData, position)
|
||||||
for _, spawnSpec in ipairs(
|
for _, spawnSpec in ipairs(
|
||||||
buildCommonSpawnSpec(investigatorName, INVESTIGATORS[investigatorName], position, true)) do
|
buildCommonSpawnSpec(investigatorName, INVESTIGATORS[investigatorName], position, true)) do
|
||||||
@ -571,16 +565,16 @@ function spawnStarterDeck(investigatorName, investigatorData, position)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
-- Clears the currently placed cards, then places cards for the given class and level spread
|
-- Clears the currently placed cards, then places cards for the given class and level spread
|
||||||
---@param cardClass String. Class to place ("Guardian", "Seeker", etc)
|
---@param cardClass string Class to place ("Guardian", "Seeker", etc)
|
||||||
---@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0.
|
---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.
|
||||||
function spawnClassCards(cardClass, isUpgraded)
|
function spawnClassCards(cardClass, isUpgraded)
|
||||||
prepareToPlaceCards()
|
prepareToPlaceCards()
|
||||||
Wait.frames(function() placeClassCards(cardClass, isUpgraded) end, 2)
|
Wait.frames(function() placeClassCards(cardClass, isUpgraded) end, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Spawn the class cards.
|
-- Spawn the class cards.
|
||||||
---@param cardClass String. Class to place ("Guardian", "Seeker", etc)
|
---@param cardClass string Class to place ("Guardian", "Seeker", etc)
|
||||||
---@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0.
|
---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.
|
||||||
function placeClassCards(cardClass, isUpgraded)
|
function placeClassCards(cardClass, isUpgraded)
|
||||||
local indexReady = allCardsBagApi.isIndexReady()
|
local indexReady = allCardsBagApi.isIndexReady()
|
||||||
if (not indexReady) then
|
if (not indexReady) then
|
||||||
@ -638,7 +632,7 @@ function placeClassCards(cardClass, isUpgraded)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Spawns the investigator sets and all cards for the given cycle
|
-- Spawns the investigator sets and all cards for the given cycle
|
||||||
---@param cycle String Name of a cycle, should match the standard used in card metadata
|
---@param cycle string Name of a cycle, should match the standard used in card metadata
|
||||||
function spawnCycle(cycle)
|
function spawnCycle(cycle)
|
||||||
prepareToPlaceCards()
|
prepareToPlaceCards()
|
||||||
spawnInvestigators(cycle)
|
spawnInvestigators(cycle)
|
||||||
|
@ -77,7 +77,7 @@ end
|
|||||||
|
|
||||||
-- Spawn a specific list of cards. This method is for internal use and should not be called
|
-- Spawn a specific list of cards. This method is for internal use and should not be called
|
||||||
-- directly, use spawnCards instead.
|
-- directly, use spawnCards instead.
|
||||||
---@param cardList: A list of Player Card data structures (data/metadata)
|
---@param cardList table A list of Player Card data structures (data/metadata)
|
||||||
---@param pos table Position where the cards should be spawned (global)
|
---@param pos table Position where the cards should be spawned (global)
|
||||||
---@param rot table Rotation for the orientation of the spawned cards (global)
|
---@param rot table Rotation for the orientation of the spawned cards (global)
|
||||||
---@param callback function callback to be called after the card/deck spawns.
|
---@param callback function callback to be called after the card/deck spawns.
|
||||||
@ -130,8 +130,8 @@ end
|
|||||||
-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's
|
-- 3. Extract the card's CustomDeck table and add it to the deck. The deck's
|
||||||
-- "CustomDeck" field is a list of all CustomDecks used by cards within the
|
-- "CustomDeck" field is a list of all CustomDecks used by cards within the
|
||||||
-- deck, keyed by the DeckID and referencing the custom deck table
|
-- deck, keyed by the DeckID and referencing the custom deck table
|
||||||
---@param deck: TTS deck data structure to add to
|
---@param deck table TTS deck data structure to add to
|
||||||
---@param cardData: Data for the card to be inserted
|
---@param cardData table Data for the card to be inserted
|
||||||
Spawner.addCardToDeck = function(deck, cardData)
|
Spawner.addCardToDeck = function(deck, cardData)
|
||||||
for customDeckId, customDeckData in pairs(cardData.CustomDeck) do
|
for customDeckId, customDeckData in pairs(cardData.CustomDeck) do
|
||||||
if (deck.CustomDeck[customDeckId] == nil) then
|
if (deck.CustomDeck[customDeckId] == nil) then
|
||||||
@ -166,7 +166,7 @@ end
|
|||||||
-- Create an empty deck data table which can have cards added to it. This
|
-- Create an empty deck data table which can have cards added to it. This
|
||||||
-- creates a new table on each call without using metatables or previous
|
-- creates a new table on each call without using metatables or previous
|
||||||
-- definitions because we can't be sure that TTS doesn't modify the structure
|
-- definitions because we can't be sure that TTS doesn't modify the structure
|
||||||
---@return: Table containing the minimal TTS deck data structure
|
---@return table deck Table containing the minimal TTS deck data structure
|
||||||
Spawner.buildDeckDataTemplate = function()
|
Spawner.buildDeckDataTemplate = function()
|
||||||
local deck = {}
|
local deck = {}
|
||||||
deck.Name = "Deck"
|
deck.Name = "Deck"
|
||||||
@ -200,7 +200,7 @@ Spawner.findNextAvailableId = function(objectTable, startId)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.
|
-- Get the PBCN (Permanent/Bonded/Customizable/Normal) value from the given metadata.
|
||||||
---@return: 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are
|
---@return number PBCN 1 for Permanent, 2 for Bonded or 4 for Normal. The actual values are
|
||||||
-- irrelevant as they provide only grouping and the order between them doesn't matter.
|
-- irrelevant as they provide only grouping and the order between them doesn't matter.
|
||||||
Spawner.getpbcn = function(metadata)
|
Spawner.getpbcn = function(metadata)
|
||||||
if metadata.permanent then
|
if metadata.permanent then
|
||||||
|
@ -54,7 +54,7 @@ do
|
|||||||
Locked = true,
|
Locked = true,
|
||||||
Grid = true,
|
Grid = true,
|
||||||
Snap = false,
|
Snap = false,
|
||||||
Tooltip = false,
|
Tooltip = false
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Tracks what has been placed by this "bag" so they can be recalled
|
-- Tracks what has been placed by this "bag" so they can be recalled
|
||||||
@ -113,7 +113,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Recalls all spawned objects to the bag, and clears the placedObjectGuids list
|
-- Recalls all spawned objects to the bag, and clears the placedObjectGuids list
|
||||||
---@param fast Boolean. If true, cards will be deleted directly without faking the bag recall.
|
---@param fast boolean If true, cards will be deleted directly without faking the bag recall.
|
||||||
SpawnBag.recall = function(fast)
|
SpawnBag.recall = function(fast)
|
||||||
if fast then
|
if fast then
|
||||||
internal.deleteSpawned()
|
internal.deleteSpawned()
|
||||||
@ -194,30 +194,30 @@ do
|
|||||||
local thick = 0.05
|
local thick = 0.05
|
||||||
Global.setVectorLines({
|
Global.setVectorLines({
|
||||||
{
|
{
|
||||||
points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} },
|
points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} },
|
||||||
color = {1,0,0},
|
color = {1,0,0},
|
||||||
thickness = thick,
|
thickness = thick,
|
||||||
rotation = {0,0,0},
|
rotation = {0,0,0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} },
|
points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} },
|
||||||
color = {1,0,0},
|
color = {1,0,0},
|
||||||
thickness = thick,
|
thickness = thick,
|
||||||
rotation = {0,0,0},
|
rotation = {0,0,0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} },
|
points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} },
|
||||||
color = {1,0,0},
|
color = {1,0,0},
|
||||||
thickness = thick,
|
thickness = thick,
|
||||||
rotation = {0,0,0},
|
rotation = {0,0,0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} },
|
points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} },
|
||||||
color = {1,0,0},
|
color = {1,0,0},
|
||||||
thickness = thick,
|
thickness = thick,
|
||||||
rotation = {0,0,0},
|
rotation = {0,0,0}
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ function onLoad(savedData)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- marks a button as active
|
-- marks a button as active
|
||||||
---@param index Number Index of the button to mark (starts at 0 from the top)
|
---@param index number Index of the button to mark (starts at 0 from the top)
|
||||||
function selectButton(index)
|
function selectButton(index)
|
||||||
local lastindex = #hypothesisList - 1
|
local lastindex = #hypothesisList - 1
|
||||||
for i = 0, lastindex do
|
for i = 0, lastindex do
|
||||||
|
@ -44,7 +44,7 @@ function updateButtonLabel(index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- update the stats to the provided values
|
-- update the stats to the provided values
|
||||||
---@param newStats Table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}
|
---@param newStats table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}
|
||||||
function updateStats(newStats)
|
function updateStats(newStats)
|
||||||
if newStats and #newStats == 4 then
|
if newStats and #newStats == 4 then
|
||||||
stats = newStats
|
stats = newStats
|
||||||
|
@ -190,8 +190,8 @@ function doNotReady(card)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- rounds a number to the specified amount of decimal places
|
-- rounds a number to the specified amount of decimal places
|
||||||
---@param num Number Initial value
|
---@param num number Initial value
|
||||||
---@param numDecimalPlaces Number Amount of decimal places
|
---@param numDecimalPlaces number Amount of decimal places
|
||||||
function round(num, numDecimalPlaces)
|
function round(num, numDecimalPlaces)
|
||||||
local mult = 10^(numDecimalPlaces or 0)
|
local mult = 10^(numDecimalPlaces or 0)
|
||||||
return math.floor(num * mult + 0.5) / mult
|
return math.floor(num * mult + 0.5) / mult
|
||||||
@ -202,7 +202,7 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- handles discarding for a list of objects
|
-- handles discarding for a list of objects
|
||||||
---@param objList Table List of objects to discard
|
---@param objList table List of objects to discard
|
||||||
function discardListOfObjects(objList)
|
function discardListOfObjects(objList)
|
||||||
for _, obj in ipairs(objList) do
|
for _, obj in ipairs(objList) do
|
||||||
if obj.type == "Card" or obj.type == "Deck" then
|
if obj.type == "Card" or obj.type == "Deck" then
|
||||||
@ -447,7 +447,6 @@ function flipTopCardFromDeck()
|
|||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
local deckAreaObjects = getDeckAreaObjects()
|
local deckAreaObjects = getDeckAreaObjects()
|
||||||
if deckAreaObjects.topCard then
|
if deckAreaObjects.topCard then
|
||||||
return
|
|
||||||
elseif deckAreaObjects.draw then
|
elseif deckAreaObjects.draw then
|
||||||
if deckAreaObjects.draw.type == "Card" then
|
if deckAreaObjects.draw.type == "Card" then
|
||||||
deckAreaObjects.draw.flip()
|
deckAreaObjects.draw.flip()
|
||||||
@ -756,7 +755,7 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
-- updates the specific owned counter
|
-- updates the specific owned counter
|
||||||
---@param param Table Contains the information to update:
|
---@param param table Contains the information to update:
|
||||||
--- type: String Counter to target
|
--- type: String Counter to target
|
||||||
--- newValue: Number Value to set the counter to
|
--- newValue: Number Value to set the counter to
|
||||||
--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier
|
--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier
|
||||||
@ -770,7 +769,7 @@ function updateCounter(param)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- returns the resource counter amount
|
-- returns the resource counter amount
|
||||||
---@param type String Counter to target
|
---@param type string Counter to target
|
||||||
function getCounterValue(type)
|
function getCounterValue(type)
|
||||||
return ownedObjects[type].getVar("val")
|
return ownedObjects[type].getVar("val")
|
||||||
end
|
end
|
||||||
@ -802,7 +801,7 @@ function returnGlobalDiscardPosition()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Sets this playermat's draw 1 button to visible
|
-- Sets this playermat's draw 1 button to visible
|
||||||
---@param visible Boolean. Whether the draw 1 button should be visible
|
---@param visible boolean Whether the draw 1 button should be visible
|
||||||
function showDrawButton(visible)
|
function showDrawButton(visible)
|
||||||
isDrawButtonVisible = visible
|
isDrawButtonVisible = visible
|
||||||
|
|
||||||
@ -831,7 +830,7 @@ function showDrawButton(visible)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues
|
-- shows / hides a clickable clue counter for this playmat and sets the correct amount of clues
|
||||||
---@param showCounter Boolean Whether the clickable clue counter should be visible
|
---@param showCounter boolean Whether the clickable clue counter should be visible
|
||||||
function clickableClues(showCounter)
|
function clickableClues(showCounter)
|
||||||
local clickerPos = ownedObjects.ClickableClueCounter.getPosition()
|
local clickerPos = ownedObjects.ClickableClueCounter.getPosition()
|
||||||
local clueCount = 0
|
local clueCount = 0
|
||||||
@ -869,7 +868,7 @@ function removeClues()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- reports the clue count
|
-- reports the clue count
|
||||||
---@param useClickableCounters Boolean Controls which type of counter is getting checked
|
---@param useClickableCounters boolean Controls which type of counter is getting checked
|
||||||
function getClueCount(useClickableCounters)
|
function getClueCount(useClickableCounters)
|
||||||
if useClickableCounters then
|
if useClickableCounters then
|
||||||
return ownedObjects.ClickableClueCounter.getVar("val")
|
return ownedObjects.ClickableClueCounter.getVar("val")
|
||||||
@ -878,11 +877,10 @@ function getClueCount(useClickableCounters)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes
|
-- Sets this playermat'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 investigator area point
|
-- 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 be reset to snap all
|
-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all cards.
|
||||||
-- cards.
|
---@param matchTypes boolean Whether snap points should only snap for the matching card types.
|
||||||
---@param matchTypes Boolean. Whether snap points should only snap for the matching card types.
|
|
||||||
function setLimitSnapsByType(matchTypes)
|
function setLimitSnapsByType(matchTypes)
|
||||||
local snaps = self.getSnapPoints()
|
local snaps = self.getSnapPoints()
|
||||||
for i, snap in ipairs(snaps) do
|
for i, snap in ipairs(snaps) do
|
||||||
@ -916,10 +914,10 @@ function setLimitSnapsByType(matchTypes)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Simple method to check if the given point is in a specified area. Local use only,
|
-- Simple method to check if the given point is in a specified area. Local use only,
|
||||||
---@param point Vector Point to check, only x and z values are relevant
|
---@param point tts__Vector Point to check, only x and z values are relevant
|
||||||
---@param bounds Table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample
|
---@param bounds table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample
|
||||||
-- bounds definition.
|
-- bounds definition.
|
||||||
---@return Boolean True if the point is in the area defined by bounds
|
---@return boolean: True if the point is in the area defined by bounds
|
||||||
function inArea(point, bounds)
|
function inArea(point, bounds)
|
||||||
return (point.x < bounds.upperLeft.x
|
return (point.x < bounds.upperLeft.x
|
||||||
and point.x > bounds.lowerRight.x
|
and point.x > bounds.lowerRight.x
|
||||||
|
@ -4,8 +4,8 @@ do
|
|||||||
local searchLib = require("util/SearchLib")
|
local searchLib = require("util/SearchLib")
|
||||||
|
|
||||||
-- 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 Color of the playmat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
---@return array Table Single-element if only single playmat is requested
|
---@return table: Single-element if only single playmat is requested
|
||||||
local function getMatForColor(matColor)
|
local function getMatForColor(matColor)
|
||||||
if matColor == "All" then
|
if matColor == "All" then
|
||||||
return guidReferenceApi.getObjectsByType("Playermat")
|
return guidReferenceApi.getObjectsByType("Playermat")
|
||||||
@ -15,7 +15,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the color of the closest playmat
|
-- Returns the color of the closest playmat
|
||||||
---@param startPos Table Starting position to get the closest mat from
|
---@param startPos table Starting position to get the closest mat from
|
||||||
PlaymatApi.getMatColorByPosition = function(startPos)
|
PlaymatApi.getMatColorByPosition = function(startPos)
|
||||||
local result, smallestDistance
|
local result, smallestDistance
|
||||||
for matColor, mat in pairs(getMatForColor("All")) do
|
for matColor, mat in pairs(getMatForColor("All")) do
|
||||||
@ -29,7 +29,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the color of the player's hand that is seated next to the playmat
|
-- 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")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.getPlayerColor = function(matColor)
|
PlaymatApi.getPlayerColor = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.getVar("playerColor")
|
return mat.getVar("playerColor")
|
||||||
@ -37,7 +37,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the color of the playmat that owns the playercolor's hand
|
-- Returns the color of the playmat that owns the playercolor's hand
|
||||||
---@param handColor String Color of the playmat
|
---@param handColor string Color of the playmat
|
||||||
PlaymatApi.getMatColor = function(handColor)
|
PlaymatApi.getMatColor = function(handColor)
|
||||||
for matColor, mat in pairs(getMatForColor("All")) do
|
for matColor, mat in pairs(getMatForColor("All")) do
|
||||||
local playerColor = mat.getVar("playerColor")
|
local playerColor = mat.getVar("playerColor")
|
||||||
@ -48,7 +48,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat
|
-- 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")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.isDES = function(matColor)
|
PlaymatApi.isDES = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.getVar("isDES")
|
return mat.getVar("isDES")
|
||||||
@ -56,7 +56,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Performs a search of the deck area of the requested playmat and returns the result as table
|
-- Performs a search of the deck area of the requested playmat and returns the result as table
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.getDeckAreaObjects = function(matColor)
|
PlaymatApi.getDeckAreaObjects = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.call("getDeckAreaObjects")
|
return mat.call("getDeckAreaObjects")
|
||||||
@ -64,7 +64,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Flips the top card of the deck (useful after deck manipulation for Norman Withers)
|
-- Flips the top card of the deck (useful after deck manipulation for Norman Withers)
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.flipTopCardFromDeck = function(matColor)
|
PlaymatApi.flipTopCardFromDeck = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.call("flipTopCardFromDeck")
|
return mat.call("flipTopCardFromDeck")
|
||||||
@ -72,7 +72,7 @@ do
|
|||||||
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 playmat - White, Orange, Green or Red (does not support "All")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.getDiscardPosition = function(matColor)
|
PlaymatApi.getDiscardPosition = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.call("returnGlobalDiscardPosition")
|
return mat.call("returnGlobalDiscardPosition")
|
||||||
@ -80,8 +80,8 @@ do
|
|||||||
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 playmat - White, Orange, Green or Red (does not support "All")
|
---@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)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.positionToWorld(localPos)
|
return mat.positionToWorld(localPos)
|
||||||
@ -89,7 +89,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the rotation of the requested playmat
|
-- Returns the rotation of the requested playmat
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.returnRotation = function(matColor)
|
PlaymatApi.returnRotation = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.getRotation()
|
return mat.getRotation()
|
||||||
@ -97,8 +97,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns a table with spawn data (position and rotation) for a helper object
|
-- Returns a table with spawn data (position and rotation) for a helper object
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
---@param helperName String Name of the helper object
|
---@param helperName string Name of the helper object
|
||||||
PlaymatApi.getHelperSpawnData = function(matColor, helperName)
|
PlaymatApi.getHelperSpawnData = function(matColor, helperName)
|
||||||
local resultTable = {}
|
local resultTable = {}
|
||||||
local localPositionTable = {
|
local localPositionTable = {
|
||||||
@ -117,8 +117,8 @@ do
|
|||||||
|
|
||||||
|
|
||||||
-- Triggers the Upkeep for the requested playmat
|
-- Triggers the Upkeep for the requested playmat
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
---@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)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("doUpkeepFromHotkey", playerColor)
|
mat.call("doUpkeepFromHotkey", playerColor)
|
||||||
@ -126,8 +126,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Handles discarding for the requested playmat for the provided list of objects
|
-- Handles discarding for the requested playmat for the provided list of objects
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
---@param objList Table List of objects to discard
|
---@param objList table List of objects to discard
|
||||||
PlaymatApi.discardListOfObjects = function(matColor, objList)
|
PlaymatApi.discardListOfObjects = function(matColor, objList)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("discardListOfObjects", objList)
|
mat.call("discardListOfObjects", objList)
|
||||||
@ -135,7 +135,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the active investigator id
|
-- Returns the active investigator id
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||||
PlaymatApi.returnInvestigatorId = function(matColor)
|
PlaymatApi.returnInvestigatorId = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.getVar("activeInvestigatorId")
|
return mat.getVar("activeInvestigatorId")
|
||||||
@ -146,8 +146,8 @@ do
|
|||||||
-- 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 types
|
---@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
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)
|
PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("setLimitSnapsByType", matchCardTypes)
|
mat.call("setLimitSnapsByType", matchCardTypes)
|
||||||
@ -155,8 +155,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Sets the requested playmat'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 Color of the playmat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)
|
PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("showDrawButton", isDrawButtonVisible)
|
mat.call("showDrawButton", isDrawButtonVisible)
|
||||||
@ -164,8 +164,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Shows or hides the clickable clue counter for the requested playmat
|
-- 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 Color of the playmat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
PlaymatApi.clickableClues = function(showCounter, matColor)
|
PlaymatApi.clickableClues = function(showCounter, matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("clickableClues", showCounter)
|
mat.call("clickableClues", showCounter)
|
||||||
@ -173,7 +173,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat
|
-- 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
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
PlaymatApi.removeClues = function(matColor)
|
PlaymatApi.removeClues = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("removeClues")
|
mat.call("removeClues")
|
||||||
@ -181,7 +181,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Reports the clue count for the requested playmat
|
-- 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 pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
@ -191,10 +191,10 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- updates the specified owned counter
|
-- updates the specified owned counter
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
---@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 pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier })
|
mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier })
|
||||||
@ -202,8 +202,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- triggers the draw function for the specified playmat
|
-- triggers the draw function for the specified playmat
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
---@param number Number Amount of cards to draw
|
---@param number number Amount of cards to draw
|
||||||
PlaymatApi.drawCardsWithReshuffle = function(matColor, number)
|
PlaymatApi.drawCardsWithReshuffle = function(matColor, number)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("drawCardsWithReshuffle", number)
|
mat.call("drawCardsWithReshuffle", number)
|
||||||
@ -211,8 +211,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- returns the resource counter amount
|
-- returns the resource counter amount
|
||||||
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
---@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)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
return mat.call("getCounterValue", type)
|
return mat.call("getCounterValue", type)
|
||||||
@ -236,7 +236,7 @@ do
|
|||||||
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 Color of the playmat - White, Orange, Green, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
PlaymatApi.resetSkillTracker = function(matColor)
|
PlaymatApi.resetSkillTracker = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("resetSkillTracker")
|
mat.call("resetSkillTracker")
|
||||||
@ -244,8 +244,8 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- finds all objects on the playmat and associated set aside zone and returns a table
|
-- 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, Red or All
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
---@param filter String Name of the filte function (see util/SearchLib)
|
---@param filter string Name of the filte function (see util/SearchLib)
|
||||||
PlaymatApi.searchAroundPlaymat = function(matColor, filter)
|
PlaymatApi.searchAroundPlaymat = function(matColor, filter)
|
||||||
local objList = {}
|
local objList = {}
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
@ -257,7 +257,7 @@ do
|
|||||||
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
|
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
|
||||||
PlaymatApi.doDiscardOne = function(matColor)
|
PlaymatApi.doDiscardOne = function(matColor)
|
||||||
for _, mat in pairs(getMatForColor(matColor)) do
|
for _, mat in pairs(getMatForColor(matColor)) do
|
||||||
mat.call("doDiscardOne")
|
mat.call("doDiscardOne")
|
||||||
|
@ -116,9 +116,9 @@ do
|
|||||||
zoneData["Green"] = zoneData["White"]
|
zoneData["Green"] = zoneData["White"]
|
||||||
|
|
||||||
-- Gets the global position for the given zone on the specified player mat.
|
-- Gets the global position for the given zone on the specified player mat.
|
||||||
---@param playerColor: Color name of the player mat to get the zone position for (e.g. "Red")
|
---@param playerColor string Color name of the player mat to get the zone position for (e.g. "Red")
|
||||||
---@param zoneName: Name of the zone to get the position for. See Zones object documentation for a list of valid zones.
|
---@param zoneName string Name of the zone to get the position for. See Zones object documentation for a list of valid zones.
|
||||||
---@return: Global position table, or nil if an invalid player color or zone is specified
|
---@return tts__Vector: Global position table, or nil if an invalid player color or zone is specified
|
||||||
Zones.getZonePosition = function(playerColor, zoneName)
|
Zones.getZonePosition = function(playerColor, zoneName)
|
||||||
if (playerColor ~= "Red"
|
if (playerColor ~= "Red"
|
||||||
and playerColor ~= "Orange"
|
and playerColor ~= "Orange"
|
||||||
@ -130,9 +130,9 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Return the global rotation for a card on the given player mat, based on its zone.
|
-- Return the global rotation for a card on the given player mat, based on its zone.
|
||||||
---@param playerColor: Color name of the player mat to get the rotation for (e.g. "Red")
|
---@param playerColor string Color name of the player mat to get the rotation for (e.g. "Red")
|
||||||
---@param zoneName: Name of the zone. See Zones object documentation for a list of valid zones.
|
---@param zoneName string Name of the zone. See Zones object documentation for a list of valid zones.
|
||||||
---@return: Global rotation vector for the given card. This will include the
|
---@return tts__Vector: Global rotation vector for the given card. This will include the
|
||||||
-- Y rotation to orient the card on the given player mat as well as a
|
-- Y rotation to orient the card on the given player mat as well as a
|
||||||
-- Z rotation to place the card face up or face down.
|
-- Z rotation to place the card face up or face down.
|
||||||
Zones.getDefaultCardRotation = function(playerColor, zoneName)
|
Zones.getDefaultCardRotation = function(playerColor, zoneName)
|
||||||
|
@ -3,9 +3,9 @@ do
|
|||||||
local searchLib = require("util/SearchLib")
|
local searchLib = require("util/SearchLib")
|
||||||
|
|
||||||
-- places a card/deck at a position or merges into an existing deck
|
-- places a card/deck at a position or merges into an existing deck
|
||||||
---@param obj TTSObject Object to move
|
---@param obj tts__GameObject Object to move
|
||||||
---@param pos Table New position for the object
|
---@param pos table New position for the object
|
||||||
---@param rot Table New rotation for the object (optional)
|
---@param rot table New rotation for the object (optional)
|
||||||
DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)
|
DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)
|
||||||
if obj == nil or pos == nil then return end
|
if obj == nil or pos == nil then return end
|
||||||
|
|
||||||
|
@ -10,14 +10,17 @@ do
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- performs the actual search and returns a filtered list of object references
|
-- performs the actual search and returns a filtered list of object references
|
||||||
---@param pos Table Global position
|
---@param pos tts__Vector Global position
|
||||||
---@param rot Table Global rotation
|
---@param rot? tts__Vector Global rotation
|
||||||
---@param size Table Size
|
---@param size table Size
|
||||||
---@param filter String Name of the filter function
|
---@param filter? string Name of the filter function
|
||||||
---@param direction Table Direction (positive is up)
|
---@param direction? table Direction (positive is up)
|
||||||
---@param maxDistance Number Distance for the cast
|
---@param maxDistance? number Distance for the cast
|
||||||
local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)
|
local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)
|
||||||
if filter then filter = filterFunctions[filter] end
|
local filterFunc
|
||||||
|
if filter then
|
||||||
|
filterFunc = filterFunctions[filter]
|
||||||
|
end
|
||||||
local searchResult = Physics.cast({
|
local searchResult = Physics.cast({
|
||||||
origin = pos,
|
origin = pos,
|
||||||
direction = direction or { 0, 1, 0 },
|
direction = direction or { 0, 1, 0 },
|
||||||
@ -30,7 +33,7 @@ do
|
|||||||
-- filtering the result
|
-- filtering the result
|
||||||
local objList = {}
|
local objList = {}
|
||||||
for _, v in ipairs(searchResult) do
|
for _, v in ipairs(searchResult) do
|
||||||
if not filter or filter(v.hit_object) then
|
if not filter or filterFunc(v.hit_object) then
|
||||||
table.insert(objList, v.hit_object)
|
table.insert(objList, v.hit_object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user