merge corrections

This commit is contained in:
Chr1Z93 2024-06-26 01:55:34 +02:00
parent 850b57bde2
commit 34a3cbd1d0
3 changed files with 45 additions and 37 deletions

View File

@ -3,7 +3,7 @@ require("playercards/PlayerCardSpawner")
local allCardsBagApi = require("playercards/AllCardsBagApi") local allCardsBagApi = require("playercards/AllCardsBagApi")
local arkhamDb = require("arkhamdb/ArkhamDb") local arkhamDb = require("arkhamdb/ArkhamDb")
local guidReferenceApi = require("core/GUIDReferenceApi") local guidReferenceApi = require("core/GUIDReferenceApi")
local playmatApi = require("playermat/PlaymatApi") local playermatApi = require("playermat/PlayermatApi")
local zones = require("playermat/Zones") local zones = require("playermat/Zones")
local matsWithInvestigator = {} local matsWithInvestigator = {}
@ -189,7 +189,7 @@ end
function loadDecks() function loadDecks()
if not allCardsBagApi.isIndexReady() then return end if not allCardsBagApi.isIndexReady() then return end
matsWithInvestigator = playmatApi.getUsedMatColors() matsWithInvestigator = playermatApi.getUsedMatColors()
if redDeckId ~= nil and redDeckId ~= "" then if redDeckId ~= nil and redDeckId ~= "" then
buildDeck("Red", redDeckId) buildDeck("Red", redDeckId)
end end
@ -354,7 +354,7 @@ end
---@param deck tts__Object Callback-provided spawned deck object ---@param deck tts__Object Callback-provided spawned deck object
---@param playerColor string Color of the player to draw the cards to ---@param playerColor string Color of the player to draw the cards to
function deckSpawned(deck, playerColor) function deckSpawned(deck, playerColor)
local player = Player[playmatApi.getPlayerColor(playerColor)] local player = Player[playermatApi.getPlayerColor(playerColor)]
local handPos = player.getHandTransform(1).position -- Only one hand zone per player local handPos = player.getHandTransform(1).position -- Only one hand zone per player
local deckCards = deck.getData().ContainedObjects local deckCards = deck.getData().ContainedObjects
@ -453,7 +453,7 @@ function removeBusyZones(playerColor, zoneDecks)
-- check for existing deck -- check for existing deck
local cardsInDeckArea = 0 local cardsInDeckArea = 0
for _, obj in pairs(playmatApi.getDeckAreaObjects(playerColor)) do for _, obj in pairs(playermatApi.getDeckAreaObjects(playerColor)) do
cardsInDeckArea = cardsInDeckArea + #obj.getObjects() cardsInDeckArea = cardsInDeckArea + #obj.getObjects()
end end
@ -732,7 +732,7 @@ end
---@param resourceModifier number Modifier for the starting resources ---@param resourceModifier number Modifier for the starting resources
function updateStartingResources(playerColor, resourceModifier) function updateStartingResources(playerColor, resourceModifier)
if resourceModifier ~= 0 then if resourceModifier ~= 0 then
playmatApi.updateCounter(playerColor, "ResourceCounter", _, resourceModifier) playermatApi.updateCounter(playerColor, "ResourceCounter", _, resourceModifier)
printToAll("Modified starting resources", playerColor) printToAll("Modified starting resources", playerColor)
end end
end end

View File

@ -72,8 +72,14 @@ do
---@param tokenType? string Name of token (e.g. "Bless") to be drawn from the bag ---@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 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 ---@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) ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, takeParameters)
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, takeParameters = takeParameters}) return Global.call("drawChaosToken", {
mat = mat,
drawAdditional = drawAdditional,
tokenType = tokenType,
guidToBeResolved = guidToBeResolved,
takeParameters = takeParameters
})
end end
-- returns a Table List of chaos token ids in the current chaos bag -- returns a Table List of chaos token ids in the current chaos bag
@ -83,4 +89,4 @@ do
end end
return ChaosBagApi return ChaosBagApi
end end

View File

@ -309,11 +309,10 @@ function makeButtonsToRedraw()
-- determine if only some tokens are able to be returned to the bag -- determine if only some tokens are able to be returned to the bag
for _, token in ipairs(chaosTokens) do for _, token in ipairs(chaosTokens) do
local tokenName = getReadableTokenName(token.getName()) local tokenName = getReadableTokenName(token.getName())
-- allow valid tokens or not invalid tokens, also allow any token if both lists empty -- 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 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) table.insert(matchingTokensInPlay, token)
end end
end end
@ -364,19 +363,19 @@ function makeButtonsToRedraw()
}) })
end end
isTokenXMLActive = true 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 else
returnAndRedraw(_, matchingTokensInPlay[1].getGUID()) returnAndRedraw(_, matchingTokensInPlay[1].getGUID())
end end
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) function returnAndRedraw(_, tokenGUID)
local takeParameters = {} local takeParameters = {}
local returnedToken = getObjectFromGUID(tokenGUID) local returnedToken = getObjectFromGUID(tokenGUID)
local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition()) local matColor = playermatApi.getMatColorByPosition(returnedToken.getPosition())
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat") local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
isTokenXMLActive = false isTokenXMLActive = false
trackChaosToken(returnedToken.getName(), mat.getGUID(), true) trackChaosToken(returnedToken.getName(), mat.getGUID(), true)
local indexOfReturnedToken = getTokenIndex(returnedToken) local indexOfReturnedToken = getTokenIndex(returnedToken)
@ -389,7 +388,7 @@ function returnAndRedraw(_, tokenGUID)
end end
returnChaosTokenToBag(returnedToken) returnChaosTokenToBag(returnedToken)
local params = { mat = mat, drawAdditional = true, takeParameters = takeParameters } local params = { mat = mat, drawAdditional = true, takeParameters = takeParameters }
if redrawData.redrawnTokenType ~= "random" then if redrawData.redrawnTokenType ~= "random" then
params.tokenType = redrawData.redrawnTokenType params.tokenType = redrawData.redrawnTokenType
end end
@ -400,7 +399,7 @@ function returnAndRedraw(_, tokenGUID)
end end
-- remove XML from tokens in play -- remove XML from tokens in play
for _, token in ipairs(getChaosTokensinPlay()) do for _, token in ipairs(getChaosTokensinPlay()) do
token.UI.setXml("") token.UI.setXml("")
end end
redrawData = {} redrawData = {}
@ -452,7 +451,7 @@ function drawChaosToken(params)
end end
chaosTokensLastMatGUID = matGUID chaosTokensLastMatGUID = matGUID
-- if we have left clicked and have no tokens OR if we have right clicked -- if we have left clicked and have no tokens OR if we have right clicked
if params.drawAdditional or #chaosTokens == 0 then if params.drawAdditional or #chaosTokens == 0 then
local chaosBag = findChaosBag() local chaosBag = findChaosBag()
@ -472,7 +471,7 @@ function drawChaosToken(params)
end end
local token local token
if params.guidToBeResolved then if params.guidToBeResolved then
-- resolve a sealed token from a card -- resolve a sealed token from a card
token = getObjectFromGUID(params.guidToBeResolved) token = getObjectFromGUID(params.guidToBeResolved)
@ -494,7 +493,7 @@ function drawChaosToken(params)
end end
token = chaosBag.takeObject(takeParameters) token = chaosBag.takeObject(takeParameters)
end end
-- get data for token description -- get data for token description
local name = token.getName() local name = token.getName()
local tokenData = mythosAreaApi.returnTokenData().tokenData or {} local tokenData = mythosAreaApi.returnTokenData().tokenData or {}
@ -533,9 +532,9 @@ function trackChaosToken(tokenName, matGUID, subtract)
if not tokenDrawingStats[matGUID] then tokenDrawingStats[matGUID] = {} end if not tokenDrawingStats[matGUID] then tokenDrawingStats[matGUID] = {} end
-- increase stats by 1 (or decrease if token is returned) -- 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["Overall"][tokenName] = (tokenDrawingStats["Overall"][tokenName] or 0) + modifier
tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + modifier tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + modifier
end end
@ -1340,7 +1339,8 @@ function contentDownloadCallback(request, params)
if pos then if pos then
spawnTable.position = pos spawnTable.position = pos
else 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 return
end end
end end
@ -1491,7 +1491,9 @@ function playermatRemovalSelected(player, selectedIndex, id)
if mat then if mat then
-- confirmation dialog about deletion -- confirmation dialog about deletion
player.pingTable(mat.getPosition()) 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 else
-- info dialog that it is already deleted -- info dialog that it is already deleted
player.showInfoDialog(matColor .. "'s playermat has already been removed.") player.showInfoDialog(matColor .. "'s playermat has already been removed.")
@ -1550,15 +1552,15 @@ function applyOptionPanelChange(id, state)
if id == "useSnapTags" then if id == "useSnapTags" then
playermatApi.setLimitSnapsByType(state, "All") playermatApi.setLimitSnapsByType(state, "All")
-- option: Draw 1 button -- option: Draw 1 button
elseif id == "showDrawButton" then elseif id == "showDrawButton" then
playermatApi.showDrawButton(state, "All") playermatApi.showDrawButton(state, "All")
-- option: Use class texture -- option: Use class texture
elseif id == "useClassTexture" then elseif id == "useClassTexture" then
playermatApi.useClassTexture(state, "All") playermatApi.useClassTexture(state, "All")
-- option: Clickable clue counters -- option: Clickable clue counters
elseif id == "useClueClickers" then elseif id == "useClueClickers" then
playermatApi.clickableClues(state, "All") playermatApi.clickableClues(state, "All")
@ -1566,40 +1568,40 @@ function applyOptionPanelChange(id, state)
local counter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "MasterClueCounter") local counter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "MasterClueCounter")
counter.setVar("useClickableCounters", state) counter.setVar("useClickableCounters", state)
-- option: Play area connection drawing -- option: Play area connection drawing
elseif id == "playAreaConnections" then elseif id == "playAreaConnections" then
playAreaApi.setConnectionDrawState(state) playAreaApi.setConnectionDrawState(state)
-- option: Play area connection color -- option: Play area connection color
elseif id == "playAreaConnectionColor" then elseif id == "playAreaConnectionColor" then
playAreaApi.setConnectionColor(state) playAreaApi.setConnectionColor(state)
UI.setAttribute(id, "color", "#" .. Color.new(state):toHex()) UI.setAttribute(id, "color", "#" .. Color.new(state):toHex())
-- option: Play area snap tags -- option: Play area snap tags
elseif id == "playAreaSnapTags" then elseif id == "playAreaSnapTags" then
playAreaApi.setLimitSnapsByType(state) playAreaApi.setLimitSnapsByType(state)
-- option: Show clean up helper -- option: Show clean up helper
elseif id == "showCleanUpHelper" then 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 elseif id == "showHandHelper" then
spawnOrRemoveHelperForPlayermats("Hand Helper", state) spawnOrRemoveHelperForPlayermats("Hand Helper", state)
-- option: Show search assistant for each player -- option: Show search assistant for each player
elseif id == "showSearchAssistant" then elseif id == "showSearchAssistant" then
spawnOrRemoveHelperForPlayermats("Search Assistant", state) spawnOrRemoveHelperForPlayermats("Search Assistant", state)
-- option: Show attachment helper -- option: Show attachment helper
elseif id == "showAttachmentHelper" then elseif id == "showAttachmentHelper" then
spawnOrRemoveHelper(state, "Attachment Helper", { -62, 1.4, 0 }) spawnOrRemoveHelper(state, "Attachment Helper", { -62, 1.4, 0 })
-- option: Show CYOA campaign guides -- option: Show CYOA campaign guides
elseif id == "showCYOA" then elseif id == "showCYOA" then
spawnOrRemoveHelper(state, "CYOA Campaign Guides", { 39, 1.3, -20 }) spawnOrRemoveHelper(state, "CYOA Campaign Guides", { 39, 1.3, -20 })
-- option: Show displacement tool -- option: Show displacement tool
elseif id == "showDisplacementTool" then elseif id == "showDisplacementTool" then
spawnOrRemoveHelper(state, "Displacement Tool", { -57, 1.53, 46 }) spawnOrRemoveHelper(state, "Displacement Tool", { -57, 1.53, 46 })
end end