Merge pull request #550 from argonui/misc

Misc. code fixes
This commit is contained in:
Entrox-Licher 2024-01-16 11:23:20 -05:00 committed by GitHub
commit d41f452f86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 37 additions and 36 deletions

View File

@ -160,7 +160,7 @@ function endSearch(_, _, isRightClick)
end
-- draw set aside cards (from the ground!)
for _, obj in ipairs(searchLib.atPosition(setAsidePosition), "isCardOrDeck") do
for _, obj in ipairs(searchLib.atPosition(setAsidePosition, "isCardOrDeck")) do
if obj.type == "Deck" then
Wait.time(function() obj.deal(#obj.getObjects(), handColor) end, 1)
elseif obj.type == "Card" then

View File

@ -13,7 +13,7 @@ do
end
-- updates the token modifiers with the provided data
---@param tokenData Table Contains the chaos token metadata
---@param fullData Table Contains the chaos token metadata
TokenArrangerApi.onTokenDataChanged = function(fullData)
callIfExistent("onTokenDataChanged", fullData)
end

View File

@ -1,6 +1,6 @@
local searchLib = require("util/SearchLib")
function onload(saved_data)
function onload(savedData)
revealCardPositions = {
Vector(3.5, 0.25, 0),
Vector(-3.5, 0.25, 0)
@ -30,8 +30,8 @@ function onload(saved_data)
self.addContextMenuItem('Reset helper', resetHelper)
if saved_data != '' then
local loaded_data = JSON.decode(saved_data)
if savedData ~= '' then
local loaded_data = JSON.decode(savedData)
hiddenCards = loaded_data.saved_hiddenCards
isSetup = true

View File

@ -83,7 +83,6 @@ end
---@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 yPos = {}
local cardsToSpawn = {}
-- reset the startsInPlayCount
@ -218,7 +217,7 @@ function getCardName(cardId)
end
-- Split a single list of cards into a separate table of lists, keyed by the zone
---@param cards: Table of {cardData, cardMetadata, zone}
---@param cards Table Table of {cardData, cardMetadata, zone}
---@return: Table of {zoneName=card list}
function buildZoneLists(cards)
local zoneList = {}
@ -389,7 +388,7 @@ 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 Table Deck's meta table, extracted from ArkhamDB's deck structure
---@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

View File

@ -42,7 +42,8 @@ do
end
-- adds bless / curse sealing to the hovered card
---@param color String Color of the player to show the broadcast to
---@param playerColor String Color of the player to show the broadcast to
---@param hoveredObject TTSObject Hovered object
BlessCurseManagerApi.addBlurseSealingMenu = function(playerColor, hoveredObject)
getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
end

View File

@ -416,8 +416,9 @@ end
---------------------------------------------------------
-- called for button creation on the difficulty selectors
---@param object object Usually "self"
---@param key string Name of the scenario
---@param args Table Parameters for this function:
-- object TTSObject Usually "self"
-- key String Name of the scenario
function createSetupButtons(args)
local data = getDataValue('modeData', args.key)
if data ~= nil then
@ -466,9 +467,10 @@ function createSetupButtons(args)
end
-- called for adding chaos tokens
---@param object object Usually "self"
---@param key string Name of the scenario
---@param mode string difficulty (e.g. "hard" or "expert")
---@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")
function fillContainer(args)
local data = getDataValue('modeData', args.key)
if data == nil then return end
@ -745,7 +747,7 @@ function onClick_download(player)
end
-- the download button on the placeholder objects calls this to directly initiate a download
---@param param 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)

View File

@ -299,7 +299,7 @@ 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 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)
@ -357,10 +357,10 @@ function drawBaseConnections()
-- Objects should reliably exist at this point, but since this can be called during onUpdate the
-- object checks are conservative just to make sure.
local origin = getObjectFromGUID(originGuid)
if draggingGuids[originGuid] == nil and origin != nil then
if draggingGuids[originGuid] == nil and origin ~= nil then
for targetGuid, direction in pairs(targetGuids) do
local target = getObjectFromGUID(targetGuid)
if draggingGuids[targetGuid] == nil and target != nil then
if draggingGuids[targetGuid] == nil and target ~= nil then
-- Since we process the full list, we're guaranteed to hit any ONE_WAY connections later
-- so we can ignore INCOMING_ONE_WAY
if direction == BIDIRECTIONAL then
@ -392,7 +392,7 @@ function drawDraggingConnections()
ownedVectors[originGuid] = {}
for targetGuid, direction in pairs(targetGuids) do
local target = getObjectFromGUID(targetGuid)
if target != nil then
if target ~= nil then
if direction == BIDIRECTIONAL then
addBidirectionalVector(origin, target, origin, ownedVectors[originGuid])
elseif direction == ONE_WAY then
@ -470,7 +470,7 @@ function addOneWayVector(origin, target, vectorOwner, lines)
end
-- Draws an arrowhead at the given position.
---@param arrowheadPosition Table Centerpoint of the arrowhead to draw (NOT the tip of the arrow)
---@param arrowheadPos Table Centerpoint of the arrowhead to draw (NOT the tip of the arrow)
---@param originPos Table Origin point of the connection, used to position the arrow arms
---@param vectorOwner Object The object which these lines will be set to. Used for relative
--- positioning and scaling, as well as highlighting connections during a drag operation

View File

@ -64,7 +64,7 @@ do
-- 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 matchCardTypes Boolean Whether snap points should only snap for the matching card types.
PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)
getPlayArea().call("setLimitSnapsByType", matchCardTypes)
end

View File

@ -136,7 +136,7 @@ function updateCount()
victoryPoints.playArea = playAreaApi.countVP()
-- count cards in victory display
for _, obj in ipairs(searchLib.onObject(self), "isCardOrDeck") do
for _, obj in ipairs(searchLib.onObject(self, "isCardOrDeck")) do
-- check metadata for VP
if obj.type == "Card" then
local VP = getCardVP(obj, JSON.decode(obj.getGMNotes()))

View File

@ -157,7 +157,7 @@ do
---@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 Number Subtype of token to spawn. This will only differ from the tokenName for resource tokens
---@param subType String Subtype of token to spawn. This will only differ from the tokenName for resource tokens
TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)
local optionPanel = optionPanelApi.getOptions()
@ -199,7 +199,7 @@ do
-- 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 Number Subtype of token to spawn. This will only differ from the tokenName for resource tokens
---@param subType String Subtype of token to spawn. This will only differ from the tokenName for resource tokens
TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)
-- not checking the max at this point since clue offsets are calculated dynamically
if tokenCount < 1 then return end
@ -408,7 +408,7 @@ do
-- Spawn tokens for a location using data retrieved from the Data Helper.
---@param card Object Card to maybe spawn tokens for
---@param playerData Table Location data structure retrieved from the DataHelper. Should be
---@param locationData Table Location data structure retrieved from the DataHelper. Should be
-- the right data for this card.
internal.spawnLocationTokensFromDataHelper = function(card, locationData)
local clueCount = internal.getClueCountFromData(card, locationData)
@ -491,7 +491,7 @@ do
local clickableResourceCounter = nil
local foundTokens = 0
for _, obj in ipairs(searchLib.onObject(card), "isTileOrToken") do
for _, obj in ipairs(searchLib.onObject(card, "isTileOrToken")) do
local memo = obj.getMemo()
if (stateTable[memo] or 0) > 0 then

View File

@ -450,8 +450,7 @@ function spawnInvestigators(groupName)
local position = getInvestigatorRowStartPos(investigatorCount, row)
for i, investigatorName in ipairs(INVESTIGATOR_GROUPS[groupName]) do
for _, spawnSpec in ipairs(buildInvestigatorSpawnSpec(
investigatorName, INVESTIGATORS[investigatorName], position, false)) do
for _, spawnSpec in ipairs(buildInvestigatorSpawnSpec(investigatorName, INVESTIGATORS[investigatorName], position)) do
spawnBag.spawn(spawnSpec)
end
position:add(investigatorPositionShiftCol)

View File

@ -131,7 +131,7 @@ end
-- "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 card: Data for the card to be inserted
---@param cardData: 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

View File

@ -104,7 +104,7 @@ do
else
-- TTS decks come out in reverse order of the cards, reverse the list so the input order stays
-- This only applies for decks; spreads are spawned by us in the order given
if spawnSpec.rotation.z != 180 then
if spawnSpec.rotation.z ~= 180 then
cardsToSpawn = internal.reverseList(cardsToSpawn)
end
Spawner.spawnCards(cardsToSpawn, spawnSpec.globalPos, spawnSpec.rotation, false, internal.recordPlacedObject)

View File

@ -15,7 +15,7 @@ function searchSelf()
clickableResourceCounter = nil
foundTokens = 0
for _, obj in ipairs(searchLib.onObject(self), "isTileOrToken") do
for _, obj in ipairs(searchLib.onObject(self, "isTileOrToken")) do
local image = obj.getCustomObject().image
if image == "http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/" then
foundTokens = foundTokens + math.abs(obj.getQuantity())

View File

@ -129,15 +129,15 @@ do
return playmatApi.transformLocalPosition(zoneData[playerColor][zoneName], playerColor)
end
-- Return the global rotation for a card on the given player mat, based on its metadata.
-- 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 cardMetadata: Table of card metadata. Metadata fields type and permanent are required; all others are optional.
---@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
-- 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, zone)
Zones.getDefaultCardRotation = function(playerColor, zoneName)
local cardRotation = playmatApi.returnRotation(playerColor)
if zone == "Deck" then
if zoneName == "Deck" then
cardRotation = cardRotation + Vector(0, 0, 180)
end
return cardRotation

View File

@ -32,7 +32,7 @@ function onScriptingButtonDown(index, playerColor)
-- check for subtype of resource based on card below
if tokenType == "resource" then
for _, obj in ipairs(searchLib.belowPosition(position), "isCard") do
for _, obj in ipairs(searchLib.belowPosition(position, "isCard")) do
if not obj.is_face_down then
local metadata = JSON.decode(obj.getGMNotes()) or {}
local uses = metadata.uses or {}