Merge pull request #431 from argonui/vp-display
Victory Display: reset highlighted locations
This commit is contained in:
commit
ae44039f87
@ -44,19 +44,15 @@ local LOC_LINK_EXCLUDE_SCENARIOS = {
|
|||||||
["The Heart of Madness"] = true
|
["The Heart of Madness"] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||||
local tokenManager = require("core/token/TokenManager")
|
local tokenManager = require("core/token/TokenManager")
|
||||||
|
|
||||||
local clueData = {}
|
local clueData = {}
|
||||||
local spawnedLocationGUIDs = {}
|
local spawnedLocationGUIDs = {}
|
||||||
local locations = {}
|
local locations = {}
|
||||||
local locationConnections = {}
|
local locationConnections = {}
|
||||||
local draggingGuids = {}
|
local draggingGuids = {}
|
||||||
local locationData
|
|
||||||
local currentScenario
|
|
||||||
|
|
||||||
local missingData = {}
|
local missingData = {}
|
||||||
local countedVP = {}
|
local locationData, currentScenario
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- general code
|
-- general code
|
||||||
@ -579,17 +575,23 @@ function setLimitSnapsByType(matchTypes)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- count victory points on locations in play area
|
-- count victory points on locations in play area
|
||||||
|
---@param highlightOff Boolean True if highlighting should be enabled
|
||||||
---@return. Returns the total amount of VP found in the play area
|
---@return. Returns the total amount of VP found in the play area
|
||||||
function countVP()
|
function countVP(highlightOff)
|
||||||
local totalVP = 0
|
local totalVP = 0
|
||||||
|
|
||||||
for cardId, metadata in pairs(locations) do
|
for cardId, metadata in pairs(locations) do
|
||||||
if metadata ~= nil then
|
local card = getObjectFromGUID(cardId)
|
||||||
|
if metadata ~= nil and card ~= nil then
|
||||||
|
if highlightOff == true then
|
||||||
|
card.highlightOff("Green")
|
||||||
|
end
|
||||||
|
|
||||||
local cardVP = tonumber(metadata.victory) or 0
|
local cardVP = tonumber(metadata.victory) or 0
|
||||||
if cardVP ~= 0 and not cardHasClues(cardId) then
|
if cardVP ~= 0 and not cardHasClues(card) then
|
||||||
totalVP = totalVP + cardVP
|
totalVP = totalVP + cardVP
|
||||||
if cardVP > 0 then
|
if highlightOff == false then
|
||||||
table.insert(countedVP, getObjectFromGUID(cardId))
|
card.highlightOn("Green")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -599,9 +601,8 @@ function countVP()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- checks if a card has clues on it, returns true if clues are on it
|
-- checks if a card has clues on it, returns true if clues are on it
|
||||||
---@param cardId String GUID of the card to check for clues
|
---@param card TTSObject Card to check for clues
|
||||||
function cardHasClues(cardId)
|
function cardHasClues(card)
|
||||||
local card = getObjectFromGUID(cardId)
|
|
||||||
for _, v in ipairs(searchOnObj(card)) do
|
for _, v in ipairs(searchOnObj(card)) do
|
||||||
local obj = v.hit_object
|
local obj = v.hit_object
|
||||||
if obj.memo == "clueDoom" and obj.is_face_down == false then
|
if obj.memo == "clueDoom" and obj.is_face_down == false then
|
||||||
@ -639,22 +640,6 @@ function highlightMissingData(state)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- highlights all locations in the play area with VP
|
|
||||||
---@param state Boolean True if highlighting should be enabled
|
|
||||||
function highlightCountedVP(state)
|
|
||||||
for i, obj in pairs(countedVP) do
|
|
||||||
if obj ~= nil then
|
|
||||||
if state then
|
|
||||||
obj.highlightOff("Green")
|
|
||||||
else
|
|
||||||
obj.highlightOn("Green")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
countedVP[i] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- rebuilds local snap points (could be useful in the future again)
|
-- rebuilds local snap points (could be useful in the future again)
|
||||||
function buildSnaps()
|
function buildSnaps()
|
||||||
local upperleft = { x = 1.53, z = -1.09 }
|
local upperleft = { x = 1.53, z = -1.09 }
|
||||||
|
@ -79,7 +79,7 @@ do
|
|||||||
-- highlights all locations in the play area with VP
|
-- highlights all locations in the play area with VP
|
||||||
---@param state Boolean True if highlighting should be enabled
|
---@param state Boolean True if highlighting should be enabled
|
||||||
PlayAreaApi.highlightCountedVP = function(state)
|
PlayAreaApi.highlightCountedVP = function(state)
|
||||||
return getPlayArea().call("highlightCountedVP", state)
|
return getPlayArea().call("countVP", state)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks if an object is in the play area (returns true or false)
|
-- Checks if an object is in the play area (returns true or false)
|
||||||
|
@ -212,8 +212,7 @@ end
|
|||||||
function highlightMissingData()
|
function highlightMissingData()
|
||||||
self.editButton({
|
self.editButton({
|
||||||
index = 3,
|
index = 3,
|
||||||
tooltip = (highlightMissing and "Enable" or "Disable") ..
|
tooltip = (highlightMissing and "Enable" or "Disable") .. " highlighting of cards without metadata (VP on these is not counted)."
|
||||||
" highlighting of cards without metadata (VP on these is not counted)."
|
|
||||||
})
|
})
|
||||||
for _, obj in pairs(missingData) do
|
for _, obj in pairs(missingData) do
|
||||||
if obj ~= nil then
|
if obj ~= nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user