added option to include drawn tokens
This commit is contained in:
parent
769249c21f
commit
8cc5170c10
@ -1 +1 @@
|
||||
{"percentage":false,"tokenPrecedence":{"":[0,11],"Auto-fail":[-100,7],"Bless":[101,8],"Cultist":[-2,4],"Curse":[-101,9],"Elder Sign":[100,2],"Elder Thing":[-4,6],"Frost":[-99,10],"Skull":[-1,3],"Tablet":[-3,5]}}
|
||||
{"includeDrawnTokens":true,"percentage":false,"tokenPrecedence":{"":[0,11],"Auto-fail":[-100,7],"Bless":[101,8],"Cultist":[-2,4],"Curse":[-101,9],"Elder Sign":[100,2],"Elder Thing":[-4,6],"Frost":[-99,10],"Skull":[-1,3],"Tablet":[-3,5]}}
|
||||
|
@ -28,6 +28,7 @@ percentageLabel.height = 0
|
||||
-- variables with save function
|
||||
local tokenPrecedence = {}
|
||||
local percentage = false
|
||||
local includeDrawnTokens = true
|
||||
|
||||
-- variables without save function
|
||||
local updating = false
|
||||
@ -48,7 +49,8 @@ local TOKEN_NAMES = {
|
||||
function onSave()
|
||||
return JSON.encode({
|
||||
tokenPrecedence = tokenPrecedence,
|
||||
percentage = percentage
|
||||
percentage = percentage,
|
||||
includeDrawnTokens = includeDrawnTokens
|
||||
})
|
||||
end
|
||||
|
||||
@ -58,6 +60,7 @@ function onLoad(saveState)
|
||||
local loadedData = JSON.decode(saveState)
|
||||
tokenPrecedence = loadedData.tokenPrecedence
|
||||
percentage = loadedData.percentage
|
||||
includeDrawnTokens = loadedData.includeDrawnTokens
|
||||
else
|
||||
loadDefaultValues()
|
||||
|
||||
@ -74,12 +77,20 @@ function onLoad(saveState)
|
||||
layout()
|
||||
end)
|
||||
|
||||
self.addContextMenuItem("Include drawn tokens", function()
|
||||
includeDrawnTokens = not includeDrawnTokens
|
||||
local text = includeDrawnTokens and " " or " not "
|
||||
broadcastToAll("Token Arranger will" .. text .. "include currently drawn chaos tokens.", "Orange")
|
||||
layout()
|
||||
end)
|
||||
|
||||
self.addContextMenuItem("Toggle percentages", function()
|
||||
if percentage then
|
||||
percentage = false
|
||||
else
|
||||
percentage = "basic"
|
||||
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
|
||||
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).",
|
||||
"Yellow")
|
||||
end
|
||||
layout()
|
||||
end)
|
||||
@ -90,7 +101,8 @@ function onLoad(saveState)
|
||||
else
|
||||
percentage = "cumulative"
|
||||
end
|
||||
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
|
||||
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).",
|
||||
"Yellow")
|
||||
layout()
|
||||
end)
|
||||
end
|
||||
@ -286,8 +298,18 @@ function layout(_, _, isRightClick)
|
||||
end
|
||||
|
||||
-- clone tokens from chaos bag (default position above trash can)
|
||||
local rawData = chaosBag.getData().ContainedObjects
|
||||
|
||||
-- optionally get the data for tokens in play
|
||||
if includeDrawnTokens then
|
||||
for _, token in pairs(chaosBagApi.getTokensInPlay()) do
|
||||
if token ~= nil then table.insert(rawData, token.getData()) end
|
||||
end
|
||||
end
|
||||
|
||||
-- generate layout data
|
||||
local data = {}
|
||||
for i, objData in ipairs(chaosBag.getData().ContainedObjects) do
|
||||
for i, objData in ipairs(rawData) do
|
||||
objData["Tags"] = { "tempToken" }
|
||||
local value = tonumber(objData.Nickname)
|
||||
local precedence = tokenPrecedence[objData.Nickname]
|
||||
|
@ -23,6 +23,11 @@ do
|
||||
return Global.call("findChaosBag")
|
||||
end
|
||||
|
||||
-- returns a table of object references to the tokens in play (does not include sealed tokens!)
|
||||
ChaosBagApi.getTokensInPlay = function()
|
||||
return Global.getTable("chaosTokens")
|
||||
end
|
||||
|
||||
-- returns all sealed tokens on cards to the chaos bag
|
||||
ChaosBagApi.releaseAllSealedTokens = function(playerColor)
|
||||
return Global.call("releaseAllSealedTokens", playerColor)
|
||||
|
@ -32,8 +32,10 @@ local NOT_INTERACTABLE = {
|
||||
"975c39", -- vertical border right
|
||||
}
|
||||
|
||||
local chaosTokens = {}
|
||||
-- global variable for access
|
||||
chaosTokens = {}
|
||||
local chaosTokensLastMat = nil
|
||||
|
||||
local bagSearchers = {}
|
||||
local MAT_COLORS = {"White", "Orange", "Green", "Red"}
|
||||
local hideTitleSplashWaitFunctionId = nil
|
||||
|
Loading…
Reference in New Issue
Block a user