updated playarea code

This commit is contained in:
Chr1Z93 2023-10-21 10:40:57 +02:00
parent 0193ebccc2
commit d9150400d5
2 changed files with 16 additions and 33 deletions

View File

@ -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,18 +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)
countedVP = {}
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
@ -600,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
@ -640,23 +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)
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) -- 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 }

View File

@ -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)