From d1d25ce4f3b5c66d7ae4f5f7dac85f3d0eb9f178 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 20 Oct 2023 00:01:46 +0200 Subject: [PATCH 1/3] reset highlighted locations --- src/core/PlayArea.ttslua | 1 + src/core/VictoryDisplay.ttslua | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 453de993..e35e5243 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -581,6 +581,7 @@ end -- count victory points on locations in play area ---@return. Returns the total amount of VP found in the play area function countVP() + countedVP = {} local totalVP = 0 for cardId, metadata in pairs(locations) do diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index c4c95a0e..404f8cdd 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -212,8 +212,7 @@ end function highlightMissingData() self.editButton({ index = 3, - tooltip = (highlightMissing and "Enable" or "Disable") .. - " highlighting of cards without metadata (VP on these is not counted)." + tooltip = (highlightMissing and "Enable" or "Disable") .. " highlighting of cards without metadata (VP on these is not counted)." }) for _, obj in pairs(missingData) do if obj ~= nil then From 0193ebccc2b21bdd97ee20ea98f48abe1591f198 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 20 Oct 2023 16:14:00 +0200 Subject: [PATCH 2/3] fixed false highlights --- src/core/PlayArea.ttslua | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index e35e5243..52439c2d 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -643,6 +643,7 @@ end -- highlights all locations in the play area with VP ---@param state Boolean True if highlighting should be enabled function highlightCountedVP(state) + countVP() for i, obj in pairs(countedVP) do if obj ~= nil then if state then From d9150400d5b2e1bcc05ca1ca79b5ede09ed558f0 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 21 Oct 2023 10:40:57 +0200 Subject: [PATCH 3/3] updated playarea code --- src/core/PlayArea.ttslua | 47 ++++++++++++------------------------- src/core/PlayAreaApi.ttslua | 2 +- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 52439c2d..5b03de49 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -44,19 +44,15 @@ local LOC_LINK_EXCLUDE_SCENARIOS = { ["The Heart of Madness"] = true } -local guidReferenceApi = require("core/GUIDReferenceApi") +local guidReferenceApi = require("core/GUIDReferenceApi") local tokenManager = require("core/token/TokenManager") - local clueData = {} local spawnedLocationGUIDs = {} local locations = {} local locationConnections = {} local draggingGuids = {} -local locationData -local currentScenario - local missingData = {} -local countedVP = {} +local locationData, currentScenario --------------------------------------------------------- -- general code @@ -579,18 +575,23 @@ function setLimitSnapsByType(matchTypes) end -- 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 -function countVP() - countedVP = {} +function countVP(highlightOff) local totalVP = 0 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 - if cardVP ~= 0 and not cardHasClues(cardId) then + if cardVP ~= 0 and not cardHasClues(card) then totalVP = totalVP + cardVP - if cardVP > 0 then - table.insert(countedVP, getObjectFromGUID(cardId)) + if highlightOff == false then + card.highlightOn("Green") end end end @@ -600,9 +601,8 @@ function countVP() end -- 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 -function cardHasClues(cardId) - local card = getObjectFromGUID(cardId) +---@param card TTSObject Card to check for clues +function cardHasClues(card) for _, v in ipairs(searchOnObj(card)) do local obj = v.hit_object if obj.memo == "clueDoom" and obj.is_face_down == false then @@ -640,23 +640,6 @@ function highlightMissingData(state) end end --- highlights all locations in the play area with VP ----@param state Boolean True if highlighting should be enabled -function highlightCountedVP(state) - countVP() - 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) function buildSnaps() local upperleft = { x = 1.53, z = -1.09 } diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index f1281b40..db0ef564 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -79,7 +79,7 @@ do -- highlights all locations in the play area with VP ---@param state Boolean True if highlighting should be enabled PlayAreaApi.highlightCountedVP = function(state) - return getPlayArea().call("highlightCountedVP", state) + return getPlayArea().call("countVP", state) end -- Checks if an object is in the play area (returns true or false)