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 blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||||
local playmatApi = require("playermat/PlaymatApi")
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
|
local victoryDisplayApi = require("core/VictoryDisplayApi")
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
addHotkey("Add Doom to Agenda", addDoomToAgenda)
|
addHotkey("Add Doom to Agenda", addDoomToAgenda)
|
||||||
@ -43,10 +44,8 @@ function addDoomToAgenda()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- moves the hovered card to the victory display
|
-- moves the hovered card to the victory display
|
||||||
function moveCardToVictoryDisplay(playerColor, hoveredObject)
|
function moveCardToVictoryDisplay(_, hoveredObject)
|
||||||
-- check if the provided object is a card
|
victoryDisplayApi.placeCard(hoveredObject)
|
||||||
if hoveredObject == nil or hoveredObject.tag ~= "Card" then return end
|
|
||||||
getObjectFromGUID("6ccd6d").call("placeCard", hoveredObject)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- takes a clue from a location, player needs to hover the clue directly or the location
|
-- 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
|
else
|
||||||
broadcastToAll(playerName .. " took one clue.", "Green")
|
broadcastToAll(playerName .. " took one clue.", "Green")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
victoryDisplayApi.update()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- broadcasts the bless/curse status to the calling player
|
-- broadcasts the bless/curse status to the calling player
|
||||||
|
@ -74,18 +74,12 @@ end
|
|||||||
|
|
||||||
-- dropping an object on the victory display
|
-- dropping an object on the victory display
|
||||||
function onCollisionEnter()
|
function onCollisionEnter()
|
||||||
-- stop if there is already an update call running
|
startUpdate()
|
||||||
if pendingCall then return end
|
|
||||||
pendingCall = true
|
|
||||||
Wait.time(updateCount, 0.2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- removing an object from the victory display
|
-- removing an object from the victory display
|
||||||
function onCollisionExit()
|
function onCollisionExit()
|
||||||
-- stop if there is already an update call running
|
startUpdate()
|
||||||
if pendingCall then return end
|
|
||||||
pendingCall = true
|
|
||||||
Wait.time(updateCount, 0.2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- picking a clue or location up
|
-- 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
|
-- only continue if the obj in in the play area
|
||||||
if not playAreaApi.isInPlayArea(obj) then return end
|
if not playAreaApi.isInPlayArea(obj) then return end
|
||||||
|
|
||||||
-- set this flag to limit function calls (will be reset by "updateCount")
|
startUpdate(delay)
|
||||||
pendingCall = true
|
end
|
||||||
|
|
||||||
-- update the count with delay (or 0 if no delay is provided)
|
-- starts an update
|
||||||
-- this is needed to let tokens drop on the card
|
function startUpdate(delay)
|
||||||
|
-- stop if there is already an update call running
|
||||||
|
if pendingCall then return end
|
||||||
|
pendingCall = true
|
||||||
delay = tonumber(delay) or 0
|
delay = tonumber(delay) or 0
|
||||||
Wait.time(updateCount, delay + 0.2)
|
Wait.time(updateCount, delay + 0.2)
|
||||||
end
|
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