From 34a3cbd1d0af805e2d60d87a83802affbea7fc0e Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 26 Jun 2024 01:55:34 +0200 Subject: [PATCH] merge corrections --- src/arkhamdb/DeckImporter.ttslua | 10 +++--- src/chaosbag/ChaosBagApi.ttslua | 12 +++++-- src/core/Global.ttslua | 60 +++++++++++++++++--------------- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/arkhamdb/DeckImporter.ttslua b/src/arkhamdb/DeckImporter.ttslua index 0c5d4089..8619eec4 100644 --- a/src/arkhamdb/DeckImporter.ttslua +++ b/src/arkhamdb/DeckImporter.ttslua @@ -3,7 +3,7 @@ require("playercards/PlayerCardSpawner") local allCardsBagApi = require("playercards/AllCardsBagApi") local arkhamDb = require("arkhamdb/ArkhamDb") local guidReferenceApi = require("core/GUIDReferenceApi") -local playmatApi = require("playermat/PlaymatApi") +local playermatApi = require("playermat/PlayermatApi") local zones = require("playermat/Zones") local matsWithInvestigator = {} @@ -189,7 +189,7 @@ end function loadDecks() if not allCardsBagApi.isIndexReady() then return end - matsWithInvestigator = playmatApi.getUsedMatColors() + matsWithInvestigator = playermatApi.getUsedMatColors() if redDeckId ~= nil and redDeckId ~= "" then buildDeck("Red", redDeckId) end @@ -354,7 +354,7 @@ end ---@param deck tts__Object 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 player = Player[playermatApi.getPlayerColor(playerColor)] local handPos = player.getHandTransform(1).position -- Only one hand zone per player local deckCards = deck.getData().ContainedObjects @@ -453,7 +453,7 @@ function removeBusyZones(playerColor, zoneDecks) -- check for existing deck local cardsInDeckArea = 0 - for _, obj in pairs(playmatApi.getDeckAreaObjects(playerColor)) do + for _, obj in pairs(playermatApi.getDeckAreaObjects(playerColor)) do cardsInDeckArea = cardsInDeckArea + #obj.getObjects() end @@ -732,7 +732,7 @@ end ---@param resourceModifier number Modifier for the starting resources function updateStartingResources(playerColor, resourceModifier) if resourceModifier ~= 0 then - playmatApi.updateCounter(playerColor, "ResourceCounter", _, resourceModifier) + playermatApi.updateCounter(playerColor, "ResourceCounter", _, resourceModifier) printToAll("Modified starting resources", playerColor) end end diff --git a/src/chaosbag/ChaosBagApi.ttslua b/src/chaosbag/ChaosBagApi.ttslua index 4e4eba0e..f9dbc8c1 100644 --- a/src/chaosbag/ChaosBagApi.ttslua +++ b/src/chaosbag/ChaosBagApi.ttslua @@ -72,8 +72,14 @@ do ---@param tokenType? string Name of token (e.g. "Bless") to be drawn from the bag ---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag ---@param takeParameters? table Position and rotation of the location where the new token should be drawn to, usually to replace a returned token - ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved) - return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, takeParameters = takeParameters}) + ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, takeParameters) + return Global.call("drawChaosToken", { + mat = mat, + drawAdditional = drawAdditional, + tokenType = tokenType, + guidToBeResolved = guidToBeResolved, + takeParameters = takeParameters + }) end -- returns a Table List of chaos token ids in the current chaos bag @@ -83,4 +89,4 @@ do end return ChaosBagApi -end \ No newline at end of file +end diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 44f7abe5..a273a25a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -309,11 +309,10 @@ function makeButtonsToRedraw() -- determine if only some tokens are able to be returned to the bag for _, token in ipairs(chaosTokens) do local tokenName = getReadableTokenName(token.getName()) - - + -- allow valid tokens or not invalid tokens, also allow any token if both lists empty if (redrawData.VALID_TOKENS[tokenName] ~= nil and isTableEmpty(redrawData.INVALID_TOKENS)) or (isTableEmpty(redrawData.VALID_TOKENS) and not redrawData.INVALID_TOKENS[tokenName]) or - (isTableEmpty(redrawData.VALID_TOKENS) and isTableEmpty(redrawData.INVALID_TOKENS)) then + (isTableEmpty(redrawData.VALID_TOKENS) and isTableEmpty(redrawData.INVALID_TOKENS)) then table.insert(matchingTokensInPlay, token) end end @@ -364,19 +363,19 @@ function makeButtonsToRedraw() }) end isTokenXMLActive = true - -- no need to make buttons if there is only one eligible token to return and redraw + -- no need to make buttons if there is only one eligible token to return and redraw else returnAndRedraw(_, matchingTokensInPlay[1].getGUID()) end end --- returns a chaos token to the chaos bag and redraws another, always called by an XML button through makeButtonsToRedraw() above +-- returns a chaos token to the chaos bag and redraws another, always called by an XML button through makeButtonsToRedraw() above function returnAndRedraw(_, tokenGUID) local takeParameters = {} local returnedToken = getObjectFromGUID(tokenGUID) - local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition()) + local matColor = playermatApi.getMatColorByPosition(returnedToken.getPosition()) local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat") - + isTokenXMLActive = false trackChaosToken(returnedToken.getName(), mat.getGUID(), true) local indexOfReturnedToken = getTokenIndex(returnedToken) @@ -389,7 +388,7 @@ function returnAndRedraw(_, tokenGUID) end returnChaosTokenToBag(returnedToken) - local params = { mat = mat, drawAdditional = true, takeParameters = takeParameters } + local params = { mat = mat, drawAdditional = true, takeParameters = takeParameters } if redrawData.redrawnTokenType ~= "random" then params.tokenType = redrawData.redrawnTokenType end @@ -400,7 +399,7 @@ function returnAndRedraw(_, tokenGUID) end -- remove XML from tokens in play for _, token in ipairs(getChaosTokensinPlay()) do - token.UI.setXml("") + token.UI.setXml("") end redrawData = {} @@ -452,7 +451,7 @@ function drawChaosToken(params) end chaosTokensLastMatGUID = matGUID - + -- if we have left clicked and have no tokens OR if we have right clicked if params.drawAdditional or #chaosTokens == 0 then local chaosBag = findChaosBag() @@ -472,7 +471,7 @@ function drawChaosToken(params) end local token - + if params.guidToBeResolved then -- resolve a sealed token from a card token = getObjectFromGUID(params.guidToBeResolved) @@ -494,7 +493,7 @@ function drawChaosToken(params) end token = chaosBag.takeObject(takeParameters) end - + -- get data for token description local name = token.getName() local tokenData = mythosAreaApi.returnTokenData().tokenData or {} @@ -533,9 +532,9 @@ function trackChaosToken(tokenName, matGUID, subtract) if not tokenDrawingStats[matGUID] then tokenDrawingStats[matGUID] = {} end -- increase stats by 1 (or decrease if token is returned) - local modifier = (subtract and -1 or 1) + local modifier = (subtract and -1 or 1) - local tokenName = getReadableTokenName(tokenName) + local tokenName = getReadableTokenName(tokenName) tokenDrawingStats["Overall"][tokenName] = (tokenDrawingStats["Overall"][tokenName] or 0) + modifier tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + modifier end @@ -1340,7 +1339,8 @@ function contentDownloadCallback(request, params) if pos then spawnTable.position = pos else - broadcastToAll("Please make space in the area below the tentacle stand in the upper middle of the table and try again.", "Red") + broadcastToAll( + "Please make space in the area below the tentacle stand in the upper middle of the table and try again.", "Red") return end end @@ -1491,7 +1491,9 @@ function playermatRemovalSelected(player, selectedIndex, id) if mat then -- confirmation dialog about deletion player.pingTable(mat.getPosition()) - player.showConfirmDialog("Do you really want to remove " .. matColor .. "'s playermat and related objects? This can't be reversed.", function() removePlayermat(matColor) end) + player.showConfirmDialog( + "Do you really want to remove " .. matColor .. "'s playermat and related objects? This can't be reversed.", + function() removePlayermat(matColor) end) else -- info dialog that it is already deleted player.showInfoDialog(matColor .. "'s playermat has already been removed.") @@ -1550,15 +1552,15 @@ function applyOptionPanelChange(id, state) if id == "useSnapTags" then playermatApi.setLimitSnapsByType(state, "All") - -- option: Draw 1 button + -- option: Draw 1 button elseif id == "showDrawButton" then playermatApi.showDrawButton(state, "All") - -- option: Use class texture + -- option: Use class texture elseif id == "useClassTexture" then playermatApi.useClassTexture(state, "All") - -- option: Clickable clue counters + -- option: Clickable clue counters elseif id == "useClueClickers" then playermatApi.clickableClues(state, "All") @@ -1566,40 +1568,40 @@ function applyOptionPanelChange(id, state) local counter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "MasterClueCounter") counter.setVar("useClickableCounters", state) - -- option: Play area connection drawing + -- option: Play area connection drawing elseif id == "playAreaConnections" then playAreaApi.setConnectionDrawState(state) - -- option: Play area connection color + -- option: Play area connection color elseif id == "playAreaConnectionColor" then playAreaApi.setConnectionColor(state) UI.setAttribute(id, "color", "#" .. Color.new(state):toHex()) - -- option: Play area snap tags + -- option: Play area snap tags elseif id == "playAreaSnapTags" then playAreaApi.setLimitSnapsByType(state) - -- option: Show clean up helper + -- option: Show clean up helper elseif id == "showCleanUpHelper" then - spawnOrRemoveHelper(state, "Clean Up Helper", { -66, 1.53, 46 }) + spawnOrRemoveHelper(state, "Clean Up Helper", { -66, 1.53, 46 }) - -- option: Show hand helper for each player + -- option: Show hand helper for each player elseif id == "showHandHelper" then spawnOrRemoveHelperForPlayermats("Hand Helper", state) - -- option: Show search assistant for each player + -- option: Show search assistant for each player elseif id == "showSearchAssistant" then spawnOrRemoveHelperForPlayermats("Search Assistant", state) - -- option: Show attachment helper + -- option: Show attachment helper elseif id == "showAttachmentHelper" then spawnOrRemoveHelper(state, "Attachment Helper", { -62, 1.4, 0 }) - -- option: Show CYOA campaign guides + -- option: Show CYOA campaign guides elseif id == "showCYOA" then spawnOrRemoveHelper(state, "CYOA Campaign Guides", { 39, 1.3, -20 }) - -- option: Show displacement tool + -- option: Show displacement tool elseif id == "showDisplacementTool" then spawnOrRemoveHelper(state, "Displacement Tool", { -57, 1.53, 46 }) end