Merge pull request #993 from Entrox-Licher/main

Bug Fixes to the Victory Display
This commit is contained in:
Chr1Z 2024-11-17 19:34:02 +01:00 committed by GitHub
commit 2fce37b5b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -98,7 +98,11 @@ end
-- destroying a clue or location
function onObjectDestroy(obj)
maybeUpdate(obj)
if countedVP[obj] then
startUpdate()
else
maybeUpdate(obj)
end
end
---------------------------------------------------------
@ -138,6 +142,17 @@ end
-- counts the VP in the victory display and request the VP count from the play area
function updateCount()
-- Turn off highlighting in case any cards are going to stop being tracked
local tempHighlightingGreen = false
local tempHighlightingRed = false
if highlightCounted then
highlightCountedVP()
tempHighlightingGreen = true
end
if highlightMissing then
highlightMissingData()
tempHighlightingRed = true
end
missingData = {}
countedVP = {}
local victoryPoints = {}
@ -151,7 +166,7 @@ function updateCount()
local VP = getCardVP(obj, JSON.decode(obj.getGMNotes()))
victoryPoints.display = victoryPoints.display + VP
if VP > 0 then
table.insert(countedVP, obj)
countedVP[obj] = true
end
-- handling for stacked cards
@ -165,7 +180,7 @@ function updateCount()
end
end
if VP > 0 then
table.insert(countedVP, obj)
countedVP[obj] = true
end
end
end
@ -175,6 +190,14 @@ function updateCount()
self.editButton({ index = 1, label = victoryPoints.playArea })
self.editButton({ index = 2, label = victoryPoints.display + victoryPoints.playArea })
-- if highlighting was on, turn it back on, including any new cards now being tracked
if tempHighlightingGreen then
highlightCountedVP()
end
if tempHighlightingRed then
highlightMissingData()
end
-- allow new update calls
pendingCall = false
end
@ -196,7 +219,7 @@ function getCardVP(obj, notes)
end
end
if (cardVP or 0) > 0 then
table.insert(countedVP, obj)
countedVP[obj] = true
end
else
table.insert(missingData, obj)
@ -229,7 +252,7 @@ function highlightCountedVP()
index = 4,
tooltip = (highlightCounted and "Enable" or "Disable") .. " highlighting of cards with VP."
})
for _, obj in pairs(countedVP) do
for obj, _ in pairs(countedVP) do
if obj ~= nil then
if highlightCounted then
obj.highlightOff("Green")