trigger update from clue hotkey

This commit is contained in:
Chr1Z93 2023-06-14 22:17:55 +02:00
parent 656764e174
commit e564a1f1fe
3 changed files with 24 additions and 12 deletions

View File

@ -1,5 +1,6 @@
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local playmatApi = require("playermat/PlaymatApi")
local victoryDisplayApi = require("core/VictoryDisplayApi")
function onLoad()
addHotkey("Add Doom to Agenda", addDoomToAgenda)
@ -121,6 +122,8 @@ function takeClueFromLocation(playerColor, hoveredObject)
else
broadcastToAll(playerName .. " took one clue.", "Green")
end
victoryDisplayApi.update()
end
-- broadcasts the bless/curse status to the calling player

View File

@ -74,18 +74,12 @@ end
-- dropping an object on the victory display
function onCollisionEnter()
-- stop if there is already an update call running
if pendingCall then return end
pendingCall = true
Wait.time(updateCount, 0.2)
startUpdate()
end
-- removing an object from the victory display
function onCollisionExit()
-- stop if there is already an update call running
if pendingCall then return end
pendingCall = true
Wait.time(updateCount, 0.2)
startUpdate()
end
-- picking a clue or location up
@ -132,11 +126,14 @@ function maybeUpdate(obj, delay, flipped)
-- only continue if the obj in in the play area
if not playAreaApi.isInPlayArea(obj) then return end
-- set this flag to limit function calls (will be reset by "updateCount")
pendingCall = true
startUpdate(delay)
end
-- update the count with delay (or 0 if no delay is provided)
-- this is needed to let tokens drop on the card
-- starts an update
function startUpdate(delay)
-- stop if there is already an update call running
if pendingCall then return end
pendingCall = true
delay = tonumber(delay) or 0
Wait.time(updateCount, delay + 0.2)
end

View File

@ -0,0 +1,12 @@
do
local VictoryDisplayApi = {}
local VD_GUID = "6ccd6d"
-- triggers an update of the Victory count
---@param delay Number Delay in seconds after which the update call is executed
VictoryDisplayApi.update = function(delay)
getObjectFromGUID(VD_GUID).call("startUpdate", delay)
end
return VictoryDisplayApi
end