Merge pull request #317 from argonui/return-sealed-tokens
Clean Up Helper: return sealed tokens to chaos bag
This commit is contained in:
commit
86720c94d7
@ -6,6 +6,7 @@ Cleans up the table for the next scenario in a campaign:
|
|||||||
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
|
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
|
||||||
local soundCubeApi = require("core/SoundCubeApi")
|
local soundCubeApi = require("core/SoundCubeApi")
|
||||||
local playmatApi = require("playermat/PlaymatApi")
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
|
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||||
|
|
||||||
-- these objects will be ignored
|
-- these objects will be ignored
|
||||||
local IGNORE_GUIDS = {
|
local IGNORE_GUIDS = {
|
||||||
@ -168,10 +169,11 @@ function cleanUp(_, color)
|
|||||||
updateCounters(CLUE_CLICKER_GUIDS, 0, "Clue clickers")
|
updateCounters(CLUE_CLICKER_GUIDS, 0, "Clue clickers")
|
||||||
resetSkillTrackers()
|
resetSkillTrackers()
|
||||||
resetDoomCounter()
|
resetDoomCounter()
|
||||||
removeBlessCurse(color)
|
blessCurseManagerApi.removeAll(color)
|
||||||
removeLines()
|
removeLines()
|
||||||
discardHands()
|
discardHands()
|
||||||
tokenSpawnTrackerApi.resetAll()
|
tokenSpawnTrackerApi.resetAll()
|
||||||
|
Global.call("releaseAllSealedTokens", color)
|
||||||
|
|
||||||
printToAll("Tidying main play area...", "White")
|
printToAll("Tidying main play area...", "White")
|
||||||
startLuaCoroutine(self, "tidyPlayareaCoroutine")
|
startLuaCoroutine(self, "tidyPlayareaCoroutine")
|
||||||
@ -180,6 +182,7 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- modular functions, called by other functions
|
-- modular functions, called by other functions
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
function updateCounters(tableOfGUIDs, tableOfNewValues, info)
|
function updateCounters(tableOfGUIDs, tableOfNewValues, info)
|
||||||
if tonumber(tableOfNewValues) then
|
if tonumber(tableOfNewValues) then
|
||||||
local value = tableOfNewValues
|
local value = tableOfNewValues
|
||||||
@ -266,17 +269,6 @@ function getTrauma()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get rid of bless/curse tokens via bless/curse manager
|
|
||||||
function removeBlessCurse(color)
|
|
||||||
local BlessCurseManager = getObjectFromGUID("5933fb")
|
|
||||||
|
|
||||||
if BlessCurseManager ~= nil then
|
|
||||||
BlessCurseManager.call("doRemove", color)
|
|
||||||
else
|
|
||||||
printToAll("Bless / Curse manager could not be found and thus bless/curse tokens were skipped.", "Yellow")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- remove drawn lines
|
-- remove drawn lines
|
||||||
function removeLines()
|
function removeLines()
|
||||||
if options["removeDrawnLines"] then
|
if options["removeDrawnLines"] then
|
||||||
|
@ -64,13 +64,20 @@ function onLoad(saved_state)
|
|||||||
self.addContextMenuItem("Reset", doReset)
|
self.addContextMenuItem("Reset", doReset)
|
||||||
|
|
||||||
-- initializing tables
|
-- initializing tables
|
||||||
|
initializeState()
|
||||||
|
broadcastCount("Curse")
|
||||||
|
broadcastCount("Bless")
|
||||||
|
end
|
||||||
|
|
||||||
|
function resetTables()
|
||||||
numInPlay = { Bless = 0, Curse = 0 }
|
numInPlay = { Bless = 0, Curse = 0 }
|
||||||
tokensTaken = { Bless = {}, Curse = {} }
|
tokensTaken = { Bless = {}, Curse = {} }
|
||||||
sealedTokens = {}
|
sealedTokens = {}
|
||||||
Wait.time(initializeState, 1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function initializeState()
|
function initializeState()
|
||||||
|
resetTables()
|
||||||
|
|
||||||
-- count tokens in the bag
|
-- count tokens in the bag
|
||||||
local chaosbag = Global.call("findChaosBag")
|
local chaosbag = Global.call("findChaosBag")
|
||||||
local tokens = {}
|
local tokens = {}
|
||||||
@ -95,9 +102,6 @@ function initializeState()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
broadcastCount("Curse")
|
|
||||||
broadcastCount("Bless")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function broadcastCount(token)
|
function broadcastCount(token)
|
||||||
@ -133,15 +137,15 @@ function doRemove(color)
|
|||||||
broadcastToColor("Removed " .. removeTakenTokens("Bless") .. " Bless and " ..
|
broadcastToColor("Removed " .. removeTakenTokens("Bless") .. " Bless and " ..
|
||||||
removeTakenTokens("Curse") .. " Curse tokens from play.", color, "White")
|
removeTakenTokens("Curse") .. " Curse tokens from play.", color, "White")
|
||||||
|
|
||||||
doReset(color)
|
resetTables()
|
||||||
|
tokenArrangerApi.layout()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- context menu function 2
|
-- context menu function 2
|
||||||
function doReset(color)
|
function doReset(color)
|
||||||
playerColor = color
|
|
||||||
numInPlay = { Bless = 0, Curse = 0 }
|
|
||||||
tokensTaken = { Bless = {}, Curse = {} }
|
|
||||||
initializeState()
|
initializeState()
|
||||||
|
broadcastCount("Curse")
|
||||||
|
broadcastCount("Bless")
|
||||||
tokenArrangerApi.layout()
|
tokenArrangerApi.layout()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,6 +26,12 @@ do
|
|||||||
getObjectFromGUID(MANAGER_GUID).call("broadcastStatus", playerColor)
|
getObjectFromGUID(MANAGER_GUID).call("broadcastStatus", playerColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- removes all bless / curse tokens from the chaos bag and play
|
||||||
|
---@param playerColor String Color of the player to show the broadcast to
|
||||||
|
BlessCurseManagerApi.removeAll = function(playerColor)
|
||||||
|
getObjectFromGUID(MANAGER_GUID).call("doRemove", playerColor)
|
||||||
|
end
|
||||||
|
|
||||||
-- adds Wendy's menu to the hovered card (allows sealing of tokens)
|
-- adds Wendy's menu to the hovered card (allows sealing of tokens)
|
||||||
---@param color String Color of the player to show the broadcast to
|
---@param color String Color of the player to show the broadcast to
|
||||||
BlessCurseManagerApi.addWendysMenu = function(playerColor, hoveredObject)
|
BlessCurseManagerApi.addWendysMenu = function(playerColor, hoveredObject)
|
||||||
|
@ -39,6 +39,7 @@ local mythosAreaApi = require("core/MythosAreaApi")
|
|||||||
local tokenArrangerApi = require("accessories/TokenArrangerApi")
|
local tokenArrangerApi = require("accessories/TokenArrangerApi")
|
||||||
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||||
local navigationOverlayApi = require("core/NavigationOverlayApi")
|
local navigationOverlayApi = require("core/NavigationOverlayApi")
|
||||||
|
local tokenChecker = require("core/token/TokenChecker")
|
||||||
|
|
||||||
-- online functionality related variables
|
-- online functionality related variables
|
||||||
local MOD_VERSION = "3.1.0"
|
local MOD_VERSION = "3.1.0"
|
||||||
@ -645,6 +646,14 @@ function emptyChaosBag()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- returns all sealed tokens on cards to the chaos bag
|
||||||
|
function releaseAllSealedTokens(playerColor)
|
||||||
|
local chaosbag = findChaosBag()
|
||||||
|
for _, obj in ipairs(getObjectsWithTag("CardThatSeals")) do
|
||||||
|
obj.call("releaseAllTokens", playerColor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- Content Importing and XML functions
|
-- Content Importing and XML functions
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
@ -80,6 +80,7 @@ function onLoad(savedData)
|
|||||||
sealedTokens = JSON.decode(savedData) or {}
|
sealedTokens = JSON.decode(savedData) or {}
|
||||||
ID_URL_MAP = Global.getTable("ID_URL_MAP")
|
ID_URL_MAP = Global.getTable("ID_URL_MAP")
|
||||||
generateContextMenu()
|
generateContextMenu()
|
||||||
|
self.addTag("CardThatSeals")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- builds the context menu
|
-- builds the context menu
|
||||||
|
Loading…
x
Reference in New Issue
Block a user