Merge pull request #663 from argonui/token-stat-order
Print chaos token stats in order
This commit is contained in:
commit
1f3308b5d1
@ -403,16 +403,13 @@ end
|
|||||||
function trackChaosToken(tokenName, matGUID, subtract)
|
function trackChaosToken(tokenName, matGUID, subtract)
|
||||||
-- initialize tables
|
-- initialize tables
|
||||||
if not tokenDrawingStats[matGUID] then tokenDrawingStats[matGUID] = {} end
|
if not tokenDrawingStats[matGUID] then tokenDrawingStats[matGUID] = {} end
|
||||||
local tokenName = getReadableTokenName(tokenName)
|
|
||||||
|
|
||||||
-- increase stats by 1 or decreause if token is returned
|
-- increase stats by 1 (or decrease if token is returned)
|
||||||
if subtract == false or subtract == nil then
|
local modifier = (subtract and -1 or 1)
|
||||||
tokenDrawingStats["Overall"][tokenName] = (tokenDrawingStats["Overall"][tokenName] or 0) + 1
|
|
||||||
tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + 1
|
local tokenName = getReadableTokenName(tokenName)
|
||||||
else
|
tokenDrawingStats["Overall"][tokenName] = (tokenDrawingStats["Overall"][tokenName] or 0) + modifier
|
||||||
tokenDrawingStats["Overall"][tokenName] = (tokenDrawingStats["Overall"][tokenName] or 0) - 1
|
tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) + modifier
|
||||||
tokenDrawingStats[matGUID][tokenName] = (tokenDrawingStats[matGUID][tokenName] or 0) - 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Left-click: print stats, Right-click: reset stats
|
-- Left-click: print stats, Right-click: reset stats
|
||||||
@ -445,7 +442,7 @@ function handleStatTrackerClick(_, _, isRightClick)
|
|||||||
|
|
||||||
-- get the total count of drawn tokens for the player
|
-- get the total count of drawn tokens for the player
|
||||||
local totalCount = 0
|
local totalCount = 0
|
||||||
for tokenName, value in pairs(personalStats) do
|
for _, value in pairs(personalStats) do
|
||||||
totalCount = totalCount + value
|
totalCount = totalCount + value
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -455,11 +452,22 @@ function handleStatTrackerClick(_, _, isRightClick)
|
|||||||
printToAll("------------------------------")
|
printToAll("------------------------------")
|
||||||
printToAll(playerName .. " Stats", playerColor)
|
printToAll(playerName .. " Stats", playerColor)
|
||||||
|
|
||||||
for tokenName, value in pairs(personalStats) do
|
-- print stats in order of the "ID_URL_MAP"
|
||||||
if value ~= 0 then
|
for _, subtable in pairs(ID_URL_MAP) do
|
||||||
|
local tokenName = subtable.name
|
||||||
|
local value = personalStats[tokenName]
|
||||||
|
if value and value ~= 0 then
|
||||||
printToAll(tokenName .. ': ' .. tostring(value))
|
printToAll(tokenName .. ': ' .. tostring(value))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- also print stats for custom tokens
|
||||||
|
local customTokenName = getReadableTokenName("")
|
||||||
|
local customTokenCount = personalStats[customTokenName]
|
||||||
|
if customTokenCount and customTokenCount ~= 0 then
|
||||||
|
printToAll(customTokenName .. ': ' .. tostring(customTokenCount))
|
||||||
|
end
|
||||||
|
|
||||||
printToAll('Total: ' .. tostring(totalCount))
|
printToAll('Total: ' .. tostring(totalCount))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user