Merge pull request #310 from argonui/victory-updating
Victory Display: trigger update from clue hotkey
This commit is contained in:
commit
3539820fed
@ -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)
|
||||
@ -43,10 +44,8 @@ function addDoomToAgenda()
|
||||
end
|
||||
|
||||
-- moves the hovered card to the victory display
|
||||
function moveCardToVictoryDisplay(playerColor, hoveredObject)
|
||||
-- check if the provided object is a card
|
||||
if hoveredObject == nil or hoveredObject.tag ~= "Card" then return end
|
||||
getObjectFromGUID("6ccd6d").call("placeCard", hoveredObject)
|
||||
function moveCardToVictoryDisplay(_, hoveredObject)
|
||||
victoryDisplayApi.placeCard(hoveredObject)
|
||||
end
|
||||
|
||||
-- takes a clue from a location, player needs to hover the clue directly or the location
|
||||
@ -121,6 +120,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
|
||||
|
@ -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
|
||||
|
20
src/core/VictoryDisplayApi.ttslua
Normal file
20
src/core/VictoryDisplayApi.ttslua
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
|
||||
-- moves a card to the victory display (in the first empty spot)
|
||||
---@param object Object Object that should be checked and potentially moved
|
||||
VictoryDisplayApi.placeCard = function(object)
|
||||
if object ~= nil and object.tag == "Card" then
|
||||
getObjectFromGUID(VD_GUID).call("placeCard", object)
|
||||
end
|
||||
end
|
||||
|
||||
return VictoryDisplayApi
|
||||
end
|
Loading…
Reference in New Issue
Block a user