fixed annotations

This commit is contained in:
Chr1Z93 2024-02-01 22:45:46 +01:00
parent d9c89ff2fa
commit bb82e6b432
35 changed files with 379 additions and 408 deletions

View File

@ -3,8 +3,8 @@ do
local guidReferenceApi = require("core/GUIDReferenceApi")
-- local function to call the token arranger, if it is on the table
---@param functionName String Name of the function to cal
---@param argument Variant Parameter to pass
---@param functionName string Name of the function to cal
---@param argument? table Parameter to pass
local function callIfExistent(functionName, argument)
local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger")
if tokenArranger ~= nil then
@ -13,7 +13,7 @@ do
end
-- 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)
callIfExistent("onTokenDataChanged", fullData)
end

View File

@ -2,16 +2,16 @@ do
local allCardsBagApi = require("playercards/AllCardsBagApi")
local playAreaApi = require("core/PlayAreaApi")
local ArkhamDb = { }
local internal = { }
local ArkhamDb = {}
local internal = {}
local tabooList = {}
local configuration
local RANDOM_WEAKNESS_ID = "01000"
local tabooList = { }
--Forward declaration
---@type Request
---@class Request
local Request = {}
local configuration
-- Sets up the ArkhamDb interface. Should be called from the parent object on load.
ArkhamDb.initialize = function()
@ -19,7 +19,6 @@ do
Request.start({ configuration.api_uri, configuration.taboo }, function(status)
local json = JSON.decode(internal.fixUtf16String(status.text))
for _, taboo in pairs(json) do
---@type <string, boolean>
local cards = {}
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
-- 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 deckId String. ArkhamDB deck id to be loaded
---@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 loadInvestigators Boolean. Whether investigator cards should be loaded as part of this
--- deck
---@param callback Function. Callback which will be sent the results of this load. Parameters
--- to the callback will be:
--- slots Table. A map of card ID to count in the deck
---@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 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 loadInvestigators boolean Whether investigator cards should be loaded as part of this deck
---@param callback function Callback which will be sent the results of this load
--- Parameters to the callback will be:
--- slots table A map of card ID to count in the 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
---@return boolean
---@return string
ArkhamDb.getDecklist = function(
playerColor,
deckId,
@ -60,7 +60,7 @@ do
-- the deck load. The called method will handle player notification.
local checkCard = allCardsBagApi.getCardById("01001")
if (checkCard ~= nil and checkCard.data == nil) then
return
return false, "Indexing not complete"
end
local deckUri = { configuration.api_uri,
@ -69,7 +69,7 @@ do
local deck = Request.start(deckUri, function(status)
if string.find(status.text, "<!DOCTYPE html>") then
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
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
-- 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.
---@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 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
ArkhamDb.logCardNotFound = function(cardId, playerColor)
local request = Request.start({
configuration.api_uri,
@ -113,18 +113,17 @@ do
-- response then applies standard transformations to the deck such as adding
-- random weaknesses and checking for taboos. Once the deck is processed,
-- passes to loadCards to actually spawn the defined deck.
---@param deck ArkhamImportDeck
---@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 loadInvestigators Boolean Whether investigator cards should be loaded as part of this
--- deck
---@param callback Function Callback which will be sent the results of this load. Parameters
--- to the callback will be:
--- slots Table. A map of card ID to count in the deck
---@param deck table ArkhamImportDeck
---@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 loadInvestigators boolean Whether investigator cards should be loaded as part of this deck
---@param callback function Callback which will be sent the results of this load.
--- Parameters to the callback will be:
--- slots table A map of card ID to count in the 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
--- 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
internal.onDeckResult = function(deck, playerColor, loadNewest, loadInvestigators, callback)
-- 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,
-- removes it from the deck and replaces it with the ID of a random basic weakness provided by the
-- 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
---@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.
internal.maybeDrawRandomWeakness = function(slots, playerColor)
local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0
@ -183,8 +182,8 @@ do
end
-- Adds both the investigator (XXXXX) and minicard (XXXXX-m) slots with one copy each
---@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 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
--- number of those cards which will be spawned
---@return string: Contains the name of the art that should be loaded ("normal", "promo" or "revised")
internal.addInvestigatorCards = function(deck, slots)
@ -238,7 +237,7 @@ do
end
-- 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
internal.maybeAddUpgradeSheets = function(slots)
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
-- 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
internal.maybeAddSummonedServitor = function(slots)
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
-- 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
---@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)
if slots["09006"] ~= nil then
local investigatorCount = playAreaApi.getInvestigatorCount()
@ -278,7 +277,7 @@ do
end
-- 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
internal.maybeAddRealityAcidReference = function(slots)
if slots["89004"] ~= nil then
@ -287,8 +286,8 @@ do
end
-- 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 description String The deck desription from ArkhamDB
---@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
internal.maybeModifyDeckFromDescription = function(slots, description)
-- check for import instructions
local pos = string.find(description, "++SCED import instructions++")
@ -331,7 +330,7 @@ do
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.
---@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)
-- Create a list of bonded cards first so we don't modify slots while iterating
local bondedCards = { }
@ -362,8 +361,8 @@ do
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")
---@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 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
internal.checkTaboos = function(tabooId, slots, playerColor)
if tabooId then
for cardId, _ in pairs(tabooList[tabooId].cards) do
@ -391,9 +390,9 @@ do
end
-- Gets the ArkhamDB config info from the configuration object.
---@return Table. Configuration data
---@return table: configuration data
internal.getConfiguration = function()
local configuration = getObjectsWithTag("import_configuration_provider")[1]:getTable("configuration")
local configuation = getObjectsWithTag("import_configuration_provider")[1].getTable("configuration")
printPriority = configuration.priority
return configuration
end
@ -404,7 +403,6 @@ do
end)
end
---@type Request
Request = {
is_done = false,
is_successful = false
@ -425,18 +423,15 @@ do
end
this.uri = uri
WebRequest.get(uri, function(status)
configure(this, status)
end)
WebRequest.get(uri, function(status) configure(this, status) end)
return this
end
-- 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)
---@param uri string
---@param on_success fun(request: Request, status: WebRequestStatus, vararg any)
---@param uri table
---@param on_success fun(request: Request, status: WebRequestStatus, vararg: any)
---@param on_error fun(status: WebRequestStatus)|nil
---@vararg any[]
---@return Request
@ -456,10 +451,10 @@ do
end
-- 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 on_success fun(status: WebRequestStatus, vararg any): boolean, any
---@param on_error nil|fun(status: WebRequestStatus, vararg any): string
---@vararg any[]
---@param uri table
---@param on_success fun(status: WebRequestStatus, vararg: any): boolean, any
---@param on_error nil|fun(status: WebRequestStatus, vararg: any): string
---@vararg any
---@return Request
function Request.start(uri, on_success, on_error, ...)
local parameters = table.pack(...)
@ -472,17 +467,14 @@ do
end
---@param requests Request[]
---@param on_success fun(content: any[], vararg any[])
---@param on_error fun(requests: Request[], vararg any[])|nil
---@param on_success fun(content: any, vararg: any)
---@param on_error fun(requests: Request, vararg: any)|nil
---@vararg any
function Request.with_all(requests, on_success, on_error, ...)
local parameters = table.pack(...)
Wait.condition(function()
---@type any[]
local results = {}
---@type Request[]
local errors = {}
for _, request in ipairs(requests) do
@ -510,7 +502,6 @@ do
end)
end
---@param callback fun(content: any, vararg any)
function Request:with(callback, ...)
local arguments = table.pack(...)
Wait.condition(function()

View File

@ -1,4 +1,4 @@
---@type ArkhamImportConfiguration
---@type table Contains fields used by the deck importer
configuration = {
api_uri = "https://arkhamdb.com/api/public",
public_deck = "decklist",

View File

@ -25,7 +25,7 @@ do
end
-- 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:
-- redDeck: Deck ID to load for the red player
-- orangeDeck: Deck ID to load for the orange player

View File

@ -18,8 +18,8 @@ end
function onSave() return JSON.encode(getUiState()) end
-- Returns the zone name where the specified card should be placed, based on its metadata.
---@param cardMetadata Table of card metadata.
---@return Zone String Name of the zone such as "Deck", "SetAside1", etc.
---@param cardMetadata table Contains card metadata
---@return string Zone Name of the zone such as "Deck", "SetAside1", etc.
-- See Zones object documentation for a list of valid zones.
function getDefaultCardZone(cardMetadata, bondedList)
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 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
---@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
-- should be spawned, but this value is separate to check for special
-- 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.
---@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 loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
---@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 loadAltInvestigator string Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
function loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator)
function coinside()
local cardsToSpawn = {}
@ -162,8 +162,8 @@ end
-- Callback handler for the main deck spawning. Looks for cards which should start in hand, and
-- draws them for the appropriate player.
---@param deck Object Callback-provided spawned deck object
---@param playerColor String Color of the player to draw the cards to
---@param deck tts__GameObject Callback-provided spawned deck object
---@param playerColor string Color of the player to draw the cards to
function deckSpawned(deck, playerColor)
local player = Player[playmatApi.getPlayerColor(playerColor)]
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
-- 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)
function convertRavenQuillSelections(selectionString)
if (string.len(selectionString) == 5) then
@ -196,7 +196,7 @@ function convertRavenQuillSelections(selectionString)
end
-- 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)
function convertGrizzledSelections(selectionString)
return selectionString:gsub("%^", ", ")
@ -217,8 +217,8 @@ function getCardName(cardId)
end
-- Split a single list of cards into a separate table of lists, keyed by the zone
---@param cards Table Table of {cardData, cardMetadata, zone}
---@return: Table of {zoneName=card list}
---@param cards table Table of {cardData, cardMetadata, zone}
---@return table ZoneNames Table with zoneName as index: {zoneName=card list}
function buildZoneLists(cards)
local zoneList = {}
for _, card in ipairs(cards) do
@ -232,7 +232,7 @@ function buildZoneLists(cards)
end
-- 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)
local hasAncestralKnowledge = false
local skillList = {}
@ -258,8 +258,8 @@ function handleAncestralKnowledge(cardList)
end
-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside3
---@param cardList Table Deck list being created
---@param playerColor String Color this deck is being loaded for
---@param cardList table Deck list being created
---@param playerColor string Color this deck is being loaded for
function handleUnderworldMarket(cardList, playerColor)
local hasMarket = false
local illicitList = {}
@ -276,9 +276,7 @@ function handleUnderworldMarket(cardList, playerColor)
if hasMarket then
if #illicitList < 10 then
printToAll("Only " .. #illicitList ..
" Illicit cards in your deck, you can't trigger Underworld Market's ability.",
playerColor)
printToAll("Only " .. #illicitList .. " Illicit cards in your deck, you can't trigger Underworld Market's ability.", playerColor)
else
-- 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)
@ -293,9 +291,7 @@ function handleUnderworldMarket(cardList, playerColor)
end
if #illicitList > 10 then
printToAll("Moved all " .. #illicitList ..
" Illicit cards to the Market deck, reduce it to 10",
playerColor)
printToAll("Moved all " .. #illicitList .. " Illicit cards to the Market deck, reduce it to 10", playerColor)
else
printToAll("Built the Market deck", playerColor)
end
@ -303,12 +299,11 @@ function handleUnderworldMarket(cardList, playerColor)
end
end
-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch
-- Deck.
---@param investigatorId String ID for the deck's investigator card. Passed separately because the
-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch Deck
---@param investigatorId string ID for the deck's investigator card. Passed separately because the
--- investigator may not be included in the cardList
---@param cardList Table Deck list being created
---@param playerColor String Color this deck is being loaded for
---@param cardList table Deck list being created
---@param playerColor string Color this deck is being loaded for
function handleHunchDeck(investigatorId, cardList, playerColor)
if investigatorId == "05002" then -- Joe Diamond
local insightList = {}
@ -343,12 +338,11 @@ function handleHunchDeck(investigatorId, cardList, playerColor)
end
end
-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit
-- Deck.
---@param investigatorId String ID for the deck's investigator card. Passed separately because the
-- If the investigator is Parallel Jim Culver, extract all Ally assets to SetAside5 to build the Spirit Deck
---@param investigatorId string ID for the deck's investigator card. Passed separately because the
--- investigator may not be included in the cardList
---@param cardList Table Deck list being created
---@param playerColor String Color this deck is being loaded for
---@param cardList table Deck list being created
---@param playerColor string Color this deck is being loaded for
function handleSpiritDeck(investigatorId, cardList, playerColor)
if investigatorId == "02004-p" or investigatorId == "02004-pb" then -- Parallel Jim Culver
local spiritList = {}
@ -387,8 +381,8 @@ end
-- 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
---@param cardList Table Deck list being created
---@param customizations String ArkhamDB data for customizations on customizable cards
---@param cardList table Deck list being created
---@param customizations string ArkhamDB data for customizations on customizable cards
function handleCustomizableUpgrades(cardList, customizations)
for _, card in ipairs(cardList) do
if card.metadata.type == "UpgradeSheet" then
@ -457,9 +451,9 @@ function handleCustomizableUpgrades(cardList, customizations)
end
-- 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
---@param cardList Table Deck list being created
---@param cardList table Deck list being created
function handlePeteSignatureAssets(investigatorId, cardList)
if investigatorId == "02005" or investigatorId == "02005-pb" then -- regular Pete's front
for i, card in ipairs(cardList) do
@ -477,8 +471,8 @@ function handlePeteSignatureAssets(investigatorId, cardList)
end
-- 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 loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
---@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")
function loadAltArt(card, loadAltInvestigator)
-- states are set up this way:
-- 1 - normal, 2 - revised/promo, 3 - promo (if 2 is revised)

View File

@ -48,7 +48,7 @@ function getUiState()
end
-- 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:
-- redDeck: Deck ID to load for the red player
-- orangeDeck: Deck ID to load for the orange player

View File

@ -207,9 +207,10 @@ end
---------------------------------------------------------
-- 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)
if type == nil then type = mode end
if omitBrackets then
return (numInPlay[type] - #tokensTaken[type]) .. " + " .. #tokensTaken[type]
else
@ -218,7 +219,7 @@ function formatTokenCount(type, omitBrackets)
end
-- 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)
table.insert(tokensTaken[param.type], param.guid)
broadcastCount(param.type)
@ -226,7 +227,7 @@ function sealedToken(param)
end
-- 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)
for i, v in ipairs(tokensTaken[param.type]) do
if v == param.guid then
@ -238,7 +239,7 @@ function releasedToken(param)
end
-- 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)
for i, v in ipairs(tokensTaken[param.type]) do
if v == param.guid then

View File

@ -30,20 +30,20 @@ do
end
-- 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)
getManager().call("broadcastStatus", playerColor)
end
-- 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)
getManager().call("doRemove", playerColor)
end
-- adds bless / curse sealing to the hovered card
---@param playerColor String Color of the player to show the broadcast to
---@param hoveredObject TTSObject Hovered object
---@param playerColor string Color of the player to show the broadcast to
---@param hoveredObject tts__GameObject Hovered object
BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)
getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
end

View File

@ -2,7 +2,7 @@ do
local ChaosBagApi = {}
-- 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)
return Global.call("setChaosBagState", tokenList)
end
@ -39,19 +39,19 @@ do
end
-- 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)
return Global.call("removeChaosToken", id)
end
-- 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)
return Global.call("returnChaosTokenToBag", token)
end
-- 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)
return Global.call("spawnChaosToken", id)
end
@ -60,7 +60,7 @@ do
-- 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.
-- 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()
return Global.call("canTouchChaosTokens")
end

View File

@ -6,28 +6,28 @@ do
end
-- returns all matching objects as a table with references
---@param owner String Parent object for this search
---@param type String Type of object to search for
---@param owner string Parent object for this search
---@param type string Type of object to search for
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
end
-- 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)
return getGuidHandler().call("getObjectsByType", type)
end
-- 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)
return getGuidHandler().call("getObjectsByOwner", owner)
end
-- sends new information to the reference handler to edit the main index
---@param owner String Parent of the object
---@param type String Type of the object
---@param guid String GUID of the object
---@param owner string Parent of the object
---@param type string Type of the object
---@param guid string GUID of the object
GUIDReferenceApi.editIndex = function(owner, type, guid)
return getGuidHandler().call("editIndex", {
owner = owner,

View File

@ -333,8 +333,8 @@ function addBlurseSealingMenu(playerColor, hoveredObject)
end
-- 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 bounds Table Defined area to see if the point is within
---@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
function inArea(point, bounds)
return (point.x > bounds.minX
and point.x < bounds.maxX

View File

@ -268,7 +268,7 @@ end
-- 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.
-- 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()
for color, searching in pairs(bagSearchers) do
if searching then
@ -329,7 +329,7 @@ end
-- DEPRECATED. Use TokenManager instead.
-- 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)
return tokenManager.spawnToken(params[1], params[2], params[3])
end
@ -416,7 +416,7 @@ end
---------------------------------------------------------
-- 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"
-- key String Name of the scenario
function createSetupButtons(args)
@ -467,7 +467,7 @@ function createSetupButtons(args)
end
-- called for adding chaos tokens
---@param args Table Parameters for this function:
---@param args table Parameters for this function:
-- object object Usually "self"
-- key string Name of the scenario
-- mode string difficulty (e.g. "hard" or "expert")
@ -567,7 +567,7 @@ function getChaosBagState()
end
-- 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
function setChaosBagState(tokenList)
if not canTouchChaosTokens() then return end
@ -608,7 +608,7 @@ function setChaosBagState(tokenList)
end
-- 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)
if not canTouchChaosTokens() then return end
@ -636,7 +636,7 @@ function spawnChaosToken(id)
end
-- 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)
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
---@param tabId String Id of the clicked tab
---@param tabId string Id of the clicked tab
function onClick_tab(_, _, tabId)
for listId, listContent in pairs(tabIdTable) do
if listId == tabId then
@ -747,7 +747,7 @@ function onClick_download(player)
end
-- 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)
local url = SOURCE_REPO .. '/' .. params.url
requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, params) end)
@ -825,7 +825,7 @@ function coroutineDownloadAll()
broadcastToAll("Downloading " .. contentType .. "...")
local contained = ""
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()
while true do
if request.is_done then
@ -908,8 +908,8 @@ function onClick_spawnPlaceholder()
end
-- toggles the visibility of the respective UI
---@param player LuaPlayer Player that triggered this
---@param title String Name of the UI to toggle
---@param player tts__Player Player that triggered this
---@param title string Name of the UI to toggle
function onClick_toggleUi(player, title)
if title == "Navigation Overlay" then
navigationOverlayApi.cycleVisibility(player.color)
@ -1162,8 +1162,8 @@ function libraryDownloadCallback(request)
end
-- loops through an XML table and returns the specified object
---@param ui Table XmlTable (get this via getXmlTable)
---@param id String Id of the object to return
---@param ui table XmlTable (get this via getXmlTable)
---@param id string Id of the object to return
function getXmlTableElementById(ui, id)
for _, obj in ipairs(ui) do
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
-- 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)
local matObjects = guidReferenceApi.getObjectsByOwner(matColor)
if not matObjects.Playermat then return end
@ -1290,8 +1290,8 @@ function updateOptionPanelState()
end
-- 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 state Boolean State of the option (true = enabled)
---@param id string ID of the option that was selected or deselected
---@param state boolean State of the option (true = enabled)
function applyOptionPanelChange(id, state)
-- option: Snap tags
if id == "useSnapTags" then
@ -1366,7 +1366,7 @@ function applyOptionPanelChange(id, state)
-- option: Show CYOA campaign guides
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
elseif id == "showDisplacementTool" then
@ -1375,12 +1375,12 @@ function applyOptionPanelChange(id, state)
end
-- handler for spawn / remove functions of helper objects
---@param state Boolean Contains the state of the option: true = spawn it, false = remove it
---@param name String Name of the helper object
---@param position Vector Position of the object (where it will spawn)
---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0})
---@param owner String Owner of the object (defaults to "Mythos")
---@return. GUID of the spawnedObj (or nil if object was removed)
---@param state boolean Contains the state of the option: true = spawn it, false = remove it
---@param name string Name of the helper object
---@param position tts__Vector Position of the object (where it will spawn)
---@param rotation? tts__Vector Rotation of the object for spawning (default: {0, 270, 0})
---@param owner? string Owner of the object (defaults to "Mythos")
---@return string|nil GUID GUID of the spawnedObj (or nil if object was removed)
function spawnOrRemoveHelper(state, name, position, rotation, owner)
if (type(state) == "table" and #state == 0) then
return removeHelperObject(name)
@ -1396,9 +1396,9 @@ function spawnOrRemoveHelper(state, name, position, rotation, owner)
end
-- copies the specified tool (by name) from the option panel source bag
---@param name String Name of the object that should be copied
---@param position Table Desired position of the object
---@param rotation Table Desired rotation of the object (defaults to object's rotation)
---@param name string Name of the object that should be copied
---@param position table Desired position of the object
---@param rotation table Desired rotation of the object (defaults to object's rotation)
function spawnHelperObject(name, position, rotation)
local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos","OptionPanelSource")
@ -1427,7 +1427,7 @@ function spawnHelperObject(name, position, rotation)
end
-- 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)
-- links objects name to the respective option name (to grab the GUID for removal)
local referenceTable = {
@ -1553,7 +1553,7 @@ function compareVersion(request)
end
-- 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)
local major, minor, patch = string.match(version, "(%d+)%.(%d+)%.(%d+)")
return major * 100 + minor * 10 + patch

View File

@ -212,9 +212,9 @@ end
---------------------------------------------------------
-- 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 bounds Table Defined area to see if the point is within
---@return Boolean: True if the point is in the area defined by bounds
---@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
---@return boolean: True if the point is in the area defined by bounds
function inArea(point, bounds)
return (point.x < bounds.upperLeft.x
and point.x > bounds.lowerRight.x

View File

@ -7,8 +7,8 @@ do
end
-- Copies the visibility for the Navigation overlay
---@param startColor String Color of the player to copy from
---@param targetColor String Color of the targeted player
---@param startColor string Color of the player to copy from
---@param targetColor string Color of the targeted player
NavigationOverlayApi.copyVisibility = function(startColor, targetColor)
getNOHandler().call("copyVisibility", {
startColor = startColor,
@ -17,14 +17,14 @@ do
end
-- 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)
getNOHandler().call("cycleVisibility", playerColor)
end
-- loads the specified camera for a player
---@param player TTSPlayerInstance 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 player tts__Player Player whose camera should be moved
---@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)
getNOHandler().call("loadCameraFromApi", {
player = player,

View File

@ -296,8 +296,8 @@ function loadCameraFromApi(params)
end
-- loads the specified camera for a player
---@param player TTSPlayerInstance 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 player tts__Player Player whose camera should be moved
---@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)
local lookHere, index, matColor
local matColorList = { "White", "Orange", "Green", "Red" }

View File

@ -2,7 +2,7 @@ do
local OptionPanelApi = {}
-- loads saved options
---@param options Table New options table
---@param options table New options table
OptionPanelApi.loadSettings = function(options)
return Global.call("loadSettings", options)
end

View File

@ -71,7 +71,7 @@ end
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
-- 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)
customDataHelper = getObjectFromGUID(args[1])
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.
-- 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)
-- 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
@ -243,7 +243,7 @@ end
-- 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
-- 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)
-- 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.
@ -299,9 +299,9 @@ function rebuildConnectionList()
end
-- 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 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 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 locData table A table containing the metadata for the card (for the correct side)
function buildLocListByIcon(cardId, iconCardList, locData)
if locData ~= nil and locData.icons ~= nil then
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
-- Playarea's locationConnections table.
---@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 locData Table A table containing the metadata for the card (for the correct side)
---@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 locData table A table containing the metadata for the card (for the correct side)
function buildConnection(cardId, iconCardList, locData)
if locData ~= nil and locData.connections ~= nil then
locationConnections[cardId] = {}
@ -412,11 +412,11 @@ end
-- Draws a bidirectional location connection between the two cards, adding the lines to do so to the
-- given lines list.
---@param card1 Object One of the card objects to connect
---@param card2 Object The other card object to connect
---@param vectorOwner Object The object which these lines will be set to. Used for relative
---@param card1 tts__GameObject One of the card objects to connect
---@param card2 tts__GameObject The other card object to connect
---@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
---@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)
local cardPos1 = card1.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
-- given lines list. Arrows will point towards the target card.
---@param origin Object Origin card in the connection
---@param target Object Target card object to connect
---@param vectorOwner Object The object which these lines will be set to. Used for relative
---@param origin tts__GameObject Origin card in the connection
---@param target tts__GameObject Target card object to connect
---@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
---@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)
-- Start with the BiDi then add the arrow lines to it
addBidirectionalVector(origin, target, vectorOwner, lines)
@ -470,11 +470,11 @@ function addOneWayVector(origin, target, vectorOwner, lines)
end
-- Draws an arrowhead at the given position.
---@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 vectorOwner Object The object which these lines will be set to. Used for relative
---@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 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
---@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)
local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y",
-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
-- 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
function shiftContentsUp(playerColor)
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
-- Z coordinates, ignoring height
---@param object Object Object to check
---@return. True if the object is inside the play area
---@param object tts__GameObject Object to check
---@return boolean: True if the object is inside the play area
function isInPlayArea(object)
local bounds = self.getBounds()
local position = object.getPosition()
@ -558,7 +558,7 @@ end
-- 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.
---@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)
local snaps = self.getSnapPoints()
for i, snap in ipairs(snaps) do
@ -591,7 +591,7 @@ function setConnectionColor(color)
end
-- 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
function countVP(highlightOff)
local totalVP = 0
@ -617,14 +617,14 @@ function countVP(highlightOff)
end
-- 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)
local searchResult = searchLib.onObject(card, "isClue")
return #searchResult > 0
end
-- 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)
for i, obj in pairs(missingData) do
if obj ~= nil then

View File

@ -11,20 +11,20 @@ do
end
-- 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()
return getInvestigatorCounter().getVar("val")
end
-- 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)
getInvestigatorCounter().call("updateVal", count)
end
-- 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'
---@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)
return getPlayArea().call("shiftContentsUp", playerColor)
end
@ -57,14 +57,14 @@ do
end
-- 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)
getPlayArea().call("onScenarioChanged", scenarioName)
end
-- 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.
---@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)
getPlayArea().call("setLimitSnapsByType", matchCardTypes)
end
@ -81,13 +81,13 @@ do
end
-- 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)
return getPlayArea().call("highlightMissingData", state)
end
-- 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)
return getPlayArea().call("countVP", state)
end
@ -107,7 +107,7 @@ do
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
-- 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)
getPlayArea().call("updateLocations", args)
end

View File

@ -131,8 +131,8 @@ function highlightTabAndItem()
end
-- loops through an XML table and returns the specified object
---@param ui Table XmlTable (get this via getXmlTable)
---@param id String Id of the object to return
---@param ui table XmlTable (get this via getXmlTable)
---@param id string Id of the object to return
function getXmlTableElementById(ui, id)
for _, obj in ipairs(ui) do
if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end

View File

@ -15,7 +15,7 @@ do
end
-- 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)
playTriggerEffect(soundIndices[soundName])
end

View File

@ -7,13 +7,13 @@ do
end
-- 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)
getVictoryDisplay().call("startUpdate", delay)
end
-- 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)
if object ~= nil and object.tag == "Card" then
getVictoryDisplay().call("placeCard", object)

View File

@ -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 card has already spawned, find appropriate data from either the uses metadata or the Data
-- Helper, and spawn the tokens.
---@param card Object Card to maybe spawn tokens for
---@param extraUses Table A table of <use type>=<count> which will modify the number of tokens
---@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
--- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1
TokenManager.spawnForCard = function(card, extraUses)
if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then
@ -151,13 +151,12 @@ do
end
-- Spawns a set of tokens on the given card.
---@param card Object Card to spawn tokens on
---@param tokenType String Type of token to spawn, valid values are "damage", "horror",
-- "resource", "doom", or "clue"
---@param tokenCount Number How many tokens to spawn. For damage or horror this value will be set to the
---@param card tts__GameObject Card to spawn tokens on
---@param tokenType string Type of token to spawn, for example "damage", "horror" or "resource"
---@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
---@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 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
TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)
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
-- tokens.
---@param card Object Card to spawn tokens on
---@param tokenType String type of token to spawn, valid values are "damage" and "horror". Other
---@param card tts__GameObject Card to spawn tokens on
---@param tokenType string type of token to spawn, valid values are "damage" and "horror". Other
-- 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)
if tokenValue < 1 or tokenValue > 50 then return end
@ -195,11 +194,11 @@ do
end
-- 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()
---@param tokenCount Number How many tokens to spawn
---@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 tokenCount number How many tokens to spawn
---@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
TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)
-- not checking the max at this point since clue offsets are calculated dynamically
if tokenCount < 1 then return end
@ -253,12 +252,12 @@ do
end
-- 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 tokenType String type of token to spawn, valid values are "damage", "horror",
---@param position tts__Vector Global position to spawn the token
---@param tokenType string type of token to spawn, valid values are "damage", "horror",
-- "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
---@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)
internal.initTokenTemplates()
local loadTokenType = tokenType
@ -292,9 +291,9 @@ do
end
-- Checks a card for metadata to maybe replenish it
---@param card Object Card object to be replenished
---@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 card tts__GameObject Card object to be replenished
---@param uses table The already decoded metadata.uses (to avoid decoding again)
---@param mat tts__GameObject The playmat the card is placed on (for rotation and casting)
TokenManager.maybeReplenishCard = function(card, uses, mat)
-- 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
@ -304,13 +303,13 @@ do
-- Delegate function to the token spawn tracker. Exists to avoid circular dependencies in some
-- 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)
tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())
end
-- 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)
internal.initDataHelperData()
for k, v in pairs(dataTable) do
@ -319,7 +318,7 @@ do
end
-- 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)
internal.initDataHelperData()
for k, v in pairs(dataTable) do
@ -328,8 +327,8 @@ do
end
-- Checks to see if the given card has location data in the DataHelper
---@param card Object Card to check for data
---@return Boolean True if this card has data in the helper, false otherwise
---@param card tts__GameObject Card to check for data
---@return boolean: True if this card has data in the helper, false otherwise
TokenManager.hasLocationData = function(card)
internal.initDataHelperData()
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
-- of the card for both locations and standard cards.
---@param card Object Card to maybe spawn tokens for
---@param extraUses Table A table of <use type>=<count> which will modify the number of tokens
---@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
--- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1
internal.spawnTokensFromUses = function(card, extraUses)
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
-- 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.initDataHelperData()
local playerData = internal.getPlayerCardData(card)
@ -396,8 +395,8 @@ do
end
-- Spawn tokens for a player card using data retrieved from the Data Helper.
---@param card Object Card to maybe spawn tokens for
---@param playerData Table Player card data structure retrieved from the DataHelper. Should be
---@param card tts__GameObject Card to maybe spawn tokens for
---@param playerData table Player card data structure retrieved from the DataHelper. Should be
-- the right data for this card.
internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData)
local token = playerData.tokenType
@ -407,8 +406,8 @@ do
end
-- Spawn tokens for a location using data retrieved from the Data Helper.
---@param card Object Card to maybe spawn tokens for
---@param locationData Table Location data structure retrieved from the DataHelper. Should be
---@param card tts__GameObject Card to maybe spawn tokens for
---@param locationData table Location data structure retrieved from the DataHelper. Should be
-- the right data for this card.
internal.spawnLocationTokensFromDataHelper = function(card, locationData)
local clueCount = internal.getClueCountFromData(card, locationData)
@ -447,7 +446,7 @@ do
end
-- 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)
local metadata = JSON.decode(card.getGMNotes()) or { }
if metadata.type == "Location" then
@ -464,9 +463,9 @@ do
end
-- Dynamically create positions for clues on a card.
---@param card Object Card the clues will be placed on
---@param count Integer How many clues?
---@return Table Array of global positions to spawn the clues at
---@param card tts__GameObject Card the clues will be placed on
---@param count number How many clues?
---@return table: Array of global positions to spawn the clues at
internal.buildClueOffsets = function(card, count)
local pos = card.getPosition()
local cluePositions = { }
@ -478,9 +477,9 @@ do
return cluePositions
end
---@param card Object Card object to be replenished
---@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 card tts__GameObject Card object to be replenished
---@param uses table The already decoded metadata.uses (to avoid decoding again)
---@param mat tts__GameObject The playmat the card is placed on (for rotation and casting)
internal.replenishTokens = function(card, uses, mat)
local cardPos = card.getPosition()

View File

@ -56,7 +56,7 @@ do
-- Kicks off the tour by initializing the card and camera hook. A callback on the hook creation
-- 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)
tourState[playerColor] = {
currentCardIndex = 1
@ -83,7 +83,7 @@ do
-- 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.
---@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)
internal.hideCard(player.color)
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
-- 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)
internal.hideCard(player.color)
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
-- 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.updateCardDisplay(playerColor)
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
-- 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)
Global.UI.hide(internal.getUiId(CARD_ID, playerColor))
end
@ -151,7 +151,7 @@ do
-- 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
-- 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)
local cameraHook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)
cameraHook.destruct()
@ -163,7 +163,7 @@ do
end
-- 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)
local index = tourState[playerColor].currentCardIndex
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
-- creation is complete the user's camera will be attached to the hook and the first card will be
-- 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)
local hookData = {
Name = "BlockSquare",
@ -225,7 +225,7 @@ do
-- Callback for creation of the camera hook object. Will attach the camera and show the current
-- (presumably first) card.
---@param hook Created object
---@param hook tts__GameObject Created object
internal.onHookCreated = function(hook)
local playerColor = hook.getGMNotes()
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
-- 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)
-- 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
@ -261,8 +261,8 @@ do
-- 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.
---@param xmlUi Table. Lua table describing the XML
---@param playerColor String. String color of the player to make this visible for
---@param xmlUi table Lua table describing the XML
---@param playerColor string String color of the player to make this visible for
internal.setDeepVisibility = function(xmlUi, playerColor)
xmlUi.attributes.visibility = "" .. playerColor
if xmlUi.children ~= nil then

View File

@ -5,7 +5,6 @@ local uniqueWeaknessList = { }
local cycleIndex = { }
local indexingDone = false
local allowRemoval = false
function onLoad()
self.addContextMenuItem("Rebuild Index", startIndexBuild)
@ -47,25 +46,17 @@ function clearIndexes()
end
-- Clears the bag indexes and starts the coroutine to rebuild the indexes
function startIndexBuild(playerColor)
function startIndexBuild()
clearIndexes()
startLuaCoroutine(self, "buildIndex")
end
function onObjectLeaveContainer(container, object)
if (container == self and not allowRemoval) then
broadcastToAll(
"Removing cards from the All Player Cards bag may break some functions. Please replace the card.",
{0.9, 0.2, 0.2}
)
function onObjectLeaveContainer(container, _)
if container == self then
broadcastToAll("Removing cards from the All Player Cards bag may break some functions.", "Red")
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
-- metadata, and creating the keyed lookup tables for the cards. This is a
-- coroutine which will spread the workload by processing 20 cards before
@ -124,8 +115,8 @@ function buildIndex()
end
-- 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 cardMetadata: SCED metadata for the card
---@param cardData table TTS object data for the card
---@param cardMetadata table SCED metadata for the card
function addCardToIndex(cardData, cardMetadata)
-- use the ZoopGuid as fallback if no id present
if cardMetadata.id == nil and cardMetadata.TtsZoopGuid then

View File

@ -21,7 +21,7 @@ do
-- 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
-- weaknesses.
---@return id String ID of the selected weakness.
---@return string: ID of the selected weakness.
AllCardsBagApi.getRandomWeaknessId = function()
return getAllCardsBag().call("getRandomWeaknessId")
end
@ -41,8 +41,8 @@ do
-- 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.
---@param name String or string fragment to search for names
---@param exact Boolean Whether the name match should be exact
---@param name string or string fragment to search for names
---@param exact boolean Whether the name match should be exact
AllCardsBagApi.getCardsByName = function(name, exact)
return getAllCardsBag().call("getCardsByName", {name = name, exact = exact})
end
@ -52,9 +52,9 @@ do
end
-- 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 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.
---@param class string class to retrieve ("Guardian", "Seeker", etc)
---@param upgraded boolean true for upgraded cards (Level 1-5), false for Level 0
---@return table: If the indexes are still being constructed, returns an empty table.
-- Otherwise, a list of tables, each with the following fields
-- cardData: TTS object data, suitable for spawning the card
-- cardMetadata: Table of parsed metadata

View File

@ -386,8 +386,7 @@ function updateStarterModeButtons()
createInvestigatorModeButtons()
end
-- Clears the table and updates positions based on scale. Should be called before ANY card
-- placement
-- Clears the table and updates positions based on scale (should be called before ANY card placement)
function prepareToPlaceCards()
deleteAll()
scalePositions()
@ -422,7 +421,7 @@ end
-- Spawn an investigator group, based on the current UI setting for either investigators or starter
-- 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)
local starterMode = starterDeckMode == STARTER_DECK_MODE_STARTERS
prepareToPlaceCards()
@ -437,7 +436,7 @@ end
-- 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.
---@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)
if INVESTIGATOR_GROUPS[groupName] == nil then
printToAll("No " .. groupName .. " data yet")
@ -480,11 +479,9 @@ function getInvestigatorRowStartPos(investigatorCount, row)
end
-- Creates the spawn spec for the investigator's signature cards.
---@param investigatorName String. Name of the investigator, matching a key in
--- InvestigatorPanelData
---@param investigatorData Table. Spawn definition for the investigator, retrieved from
--- INVESTIGATORS
---@param position Vector. Where to spawn the minicard; investigagor cards will be placed below
---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData
---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS
---@param position tts__Vector Where to spawn the minicard; investigagor cards will be placed below
function buildInvestigatorSpawnSpec(investigatorName, investigatorData, position)
local sigPos = Vector(position):add(investigatorSignatureOffset)
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
-- shared, and will only differ in whether they spawn the full stack of possible investigator and
-- minicards, or only the first of each.
---@param investigatorName String. Name of the investigator, matching a key in
--- InvestigatorPanelData
---@param investigatorData Table. Spawn definition for the investigator, retrieved from
--- INVESTIGATORS
---@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
---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData
---@param investigatorData table Spawn definition for the investigator, retrieved from INVESTIGATORS
---@param position tts__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
function buildCommonSpawnSpec(investigatorName, investigatorData, position, oneCardOnly)
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
-- 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)
local col = 1
local row = 1
@ -547,8 +542,7 @@ function spawnStarters(groupName)
end
-- Spawns the defined starter deck for the given investigator's.
---@param investigatorName String. Name of the investigator, matching a key in
--- InvestigatorPanelData
---@param investigatorName string Name of the investigator, matching a key in InvestigatorPanelData
function spawnStarterDeck(investigatorName, investigatorData, position)
for _, spawnSpec in ipairs(
buildCommonSpawnSpec(investigatorName, INVESTIGATORS[investigatorName], position, true)) do
@ -571,16 +565,16 @@ function spawnStarterDeck(investigatorName, investigatorData, position)
end)
end
-- 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 isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0.
---@param cardClass string Class to place ("Guardian", "Seeker", etc)
---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.
function spawnClassCards(cardClass, isUpgraded)
prepareToPlaceCards()
Wait.frames(function() placeClassCards(cardClass, isUpgraded) end, 2)
end
-- Spawn the class cards.
---@param cardClass String. Class to place ("Guardian", "Seeker", etc)
---@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0.
---@param cardClass string Class to place ("Guardian", "Seeker", etc)
---@param isUpgraded boolean If true, spawn the Level 1-5 cards. Otherwise, Level 0.
function placeClassCards(cardClass, isUpgraded)
local indexReady = allCardsBagApi.isIndexReady()
if (not indexReady) then
@ -638,7 +632,7 @@ function placeClassCards(cardClass, isUpgraded)
end
-- 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)
prepareToPlaceCards()
spawnInvestigators(cycle)

View File

@ -77,7 +77,7 @@ end
-- Spawn a specific list of cards. This method is for internal use and should not be called
-- 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 rot table Rotation for the orientation of the spawned cards (global)
---@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
-- "CustomDeck" field is a list of all CustomDecks used by cards within the
-- deck, keyed by the DeckID and referencing the custom deck table
---@param deck: TTS deck data structure to add to
---@param cardData: Data for the card to be inserted
---@param deck table TTS deck data structure to add to
---@param cardData table Data for the card to be inserted
Spawner.addCardToDeck = function(deck, cardData)
for customDeckId, customDeckData in pairs(cardData.CustomDeck) do
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
-- 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
---@return: Table containing the minimal TTS deck data structure
---@return table deck Table containing the minimal TTS deck data structure
Spawner.buildDeckDataTemplate = function()
local deck = {}
deck.Name = "Deck"
@ -200,7 +200,7 @@ Spawner.findNextAvailableId = function(objectTable, startId)
end
-- 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.
Spawner.getpbcn = function(metadata)
if metadata.permanent then

View File

@ -54,7 +54,7 @@ do
Locked = true,
Grid = true,
Snap = false,
Tooltip = false,
Tooltip = false
}
-- Tracks what has been placed by this "bag" so they can be recalled
@ -113,7 +113,7 @@ do
end
-- 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)
if fast then
internal.deleteSpawned()
@ -197,26 +197,26 @@ do
points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} },
color = {1,0,0},
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} },
color = {1,0,0},
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} },
color = {1,0,0},
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} },
color = {1,0,0},
thickness = thick,
rotation = {0,0,0},
},
rotation = {0,0,0}
}
})
end
end

View File

@ -50,7 +50,7 @@ function onLoad(savedData)
end
-- 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)
local lastindex = #hypothesisList - 1
for i = 0, lastindex do

View File

@ -44,7 +44,7 @@ function updateButtonLabel(index)
end
-- 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)
if newStats and #newStats == 4 then
stats = newStats

View File

@ -190,8 +190,8 @@ function doNotReady(card)
end
-- rounds a number to the specified amount of decimal places
---@param num Number Initial value
---@param numDecimalPlaces Number Amount of decimal places
---@param num number Initial value
---@param numDecimalPlaces number Amount of decimal places
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
@ -202,7 +202,7 @@ end
---------------------------------------------------------
-- 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)
for _, obj in ipairs(objList) do
if obj.type == "Card" or obj.type == "Deck" then
@ -447,7 +447,6 @@ function flipTopCardFromDeck()
Wait.time(function()
local deckAreaObjects = getDeckAreaObjects()
if deckAreaObjects.topCard then
return
elseif deckAreaObjects.draw then
if deckAreaObjects.draw.type == "Card" then
deckAreaObjects.draw.flip()
@ -756,7 +755,7 @@ end
---------------------------------------------------------
-- 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
--- newValue: Number Value to set the counter to
--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier
@ -770,7 +769,7 @@ function updateCounter(param)
end
-- returns the resource counter amount
---@param type String Counter to target
---@param type string Counter to target
function getCounterValue(type)
return ownedObjects[type].getVar("val")
end
@ -802,7 +801,7 @@ function returnGlobalDiscardPosition()
end
-- 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)
isDrawButtonVisible = visible
@ -831,7 +830,7 @@ function showDrawButton(visible)
end
-- 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)
local clickerPos = ownedObjects.ClickableClueCounter.getPosition()
local clueCount = 0
@ -869,7 +868,7 @@ function removeClues()
end
-- 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)
if useClickableCounters then
return ownedObjects.ClickableClueCounter.getVar("val")
@ -880,9 +879,8 @@ end
-- 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
-- will only snap Investigators. 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.
-- will only snap Investigators. 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.
function setLimitSnapsByType(matchTypes)
local snaps = self.getSnapPoints()
for i, snap in ipairs(snaps) do
@ -916,10 +914,10 @@ function setLimitSnapsByType(matchTypes)
end
-- 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 bounds Table Defined area to see if the point is within. See MAIN_PLAY_AREA for sample
---@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
-- 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)
return (point.x < bounds.upperLeft.x
and point.x > bounds.lowerRight.x

View File

@ -4,8 +4,8 @@ do
local searchLib = require("util/SearchLib")
-- 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
---@return array Table Single-element if only single playmat is requested
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
---@return table: Single-element if only single playmat is requested
local function getMatForColor(matColor)
if matColor == "All" then
return guidReferenceApi.getObjectsByType("Playermat")
@ -15,7 +15,7 @@ do
end
-- 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)
local result, smallestDistance
for matColor, mat in pairs(getMatForColor("All")) do
@ -29,7 +29,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.getVar("playerColor")
@ -37,7 +37,7 @@ do
end
-- 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)
for matColor, mat in pairs(getMatForColor("All")) do
local playerColor = mat.getVar("playerColor")
@ -48,7 +48,7 @@ do
end
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.isDES = function(matColor)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.getVar("isDES")
@ -56,7 +56,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.call("getDeckAreaObjects")
@ -64,7 +64,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.call("flipTopCardFromDeck")
@ -72,7 +72,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.call("returnGlobalDiscardPosition")
@ -80,8 +80,8 @@ do
end
-- Transforms a local position into a global position
---@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 localPos table Local position to be transformed
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.transformLocalPosition = function(localPos, matColor)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.positionToWorld(localPos)
@ -89,7 +89,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.getRotation()
@ -97,8 +97,8 @@ do
end
-- 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 helperName String Name of the helper object
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
---@param helperName string Name of the helper object
PlaymatApi.getHelperSpawnData = function(matColor, helperName)
local resultTable = {}
local localPositionTable = {
@ -117,8 +117,8 @@ do
-- Triggers the Upkeep for the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param playerColor String Color of the calling player (for messages)
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
---@param playerColor string Color of the calling player (for messages)
PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("doUpkeepFromHotkey", playerColor)
@ -126,8 +126,8 @@ do
end
-- 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 objList Table List of objects to discard
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
---@param objList table List of objects to discard
PlaymatApi.discardListOfObjects = function(matColor, objList)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("discardListOfObjects", objList)
@ -135,7 +135,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.getVar("activeInvestigatorId")
@ -146,8 +146,8 @@ do
-- 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
-- be reset to snap all cards.
---@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 matchCardTypes boolean Whether snap points should only snap for the matching card types
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("setLimitSnapsByType", matchCardTypes)
@ -155,8 +155,8 @@ do
end
-- Sets the requested playmat's draw 1 button to visible
---@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 isDrawButtonVisible boolean Whether the draw 1 button should be visible or not
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("showDrawButton", isDrawButtonVisible)
@ -164,8 +164,8 @@ do
end
-- Shows or hides the clickable clue counter for the requested playmat
---@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 showCounter boolean Whether the clickable counter should be present or not
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
PlaymatApi.clickableClues = function(showCounter, matColor)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("clickableClues", showCounter)
@ -173,7 +173,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("removeClues")
@ -181,7 +181,7 @@ do
end
-- 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)
local count = 0
for _, mat in pairs(getMatForColor(matColor)) do
@ -191,10 +191,10 @@ do
end
-- updates the specified owned counter
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param type String Counter to target
---@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 matColor string Color of the playmat - White, Orange, Green, Red or All
---@param type string Counter to target
---@param newValue number Value to set the counter to
---@param modifier number If newValue is not provided, the existing value will be adjusted by this modifier
PlaymatApi.updateCounter = function(matColor, type, newValue, modifier)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier })
@ -202,8 +202,8 @@ do
end
-- triggers the draw function for the specified playmat
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param number Number Amount of cards to draw
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
---@param number number Amount of cards to draw
PlaymatApi.drawCardsWithReshuffle = function(matColor, number)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("drawCardsWithReshuffle", number)
@ -211,8 +211,8 @@ do
end
-- returns the resource counter amount
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
---@param type String Counter to target
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
---@param type string Counter to target
PlaymatApi.getCounterValue = function(matColor, type)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.call("getCounterValue", type)
@ -236,7 +236,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("resetSkillTracker")
@ -244,8 +244,8 @@ do
end
-- finds all objects on the playmat and associated set aside zone and returns a table
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param filter String Name of the filte function (see util/SearchLib)
---@param matColor string Color of the playmat - White, Orange, Green, Red or All
---@param filter string Name of the filte function (see util/SearchLib)
PlaymatApi.searchAroundPlaymat = function(matColor, filter)
local objList = {}
for _, mat in pairs(getMatForColor(matColor)) do
@ -257,7 +257,7 @@ do
end
-- 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)
for _, mat in pairs(getMatForColor(matColor)) do
mat.call("doDiscardOne")

View File

@ -116,9 +116,9 @@ do
zoneData["Green"] = zoneData["White"]
-- 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 zoneName: 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
---@param playerColor string Color name of the player mat to get the zone position for (e.g. "Red")
---@param zoneName string Name of the zone to get the position for. See Zones object documentation for a list of valid zones.
---@return tts__Vector: Global position table, or nil if an invalid player color or zone is specified
Zones.getZonePosition = function(playerColor, zoneName)
if (playerColor ~= "Red"
and playerColor ~= "Orange"
@ -130,9 +130,9 @@ do
end
-- 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 zoneName: 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
---@param playerColor string Color name of the player mat to get the rotation for (e.g. "Red")
---@param zoneName string Name of the zone. See Zones object documentation for a list of valid zones.
---@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
-- Z rotation to place the card face up or face down.
Zones.getDefaultCardRotation = function(playerColor, zoneName)

View File

@ -3,9 +3,9 @@ do
local searchLib = require("util/SearchLib")
-- places a card/deck at a position or merges into an existing deck
---@param obj TTSObject Object to move
---@param pos Table New position for the object
---@param rot Table New rotation for the object (optional)
---@param obj tts__GameObject Object to move
---@param pos table New position for the object
---@param rot table New rotation for the object (optional)
DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)
if obj == nil or pos == nil then return end

View File

@ -10,14 +10,17 @@ do
}
-- performs the actual search and returns a filtered list of object references
---@param pos Table Global position
---@param rot Table Global rotation
---@param size Table Size
---@param filter String Name of the filter function
---@param direction Table Direction (positive is up)
---@param maxDistance Number Distance for the cast
---@param pos tts__Vector Global position
---@param rot? tts__Vector Global rotation
---@param size table Size
---@param filter? string Name of the filter function
---@param direction? table Direction (positive is up)
---@param maxDistance? number Distance for the cast
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({
origin = pos,
direction = direction or { 0, 1, 0 },
@ -30,7 +33,7 @@ do
-- filtering the result
local objList = {}
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)
end
end