fixed name, adding retuning
This commit is contained in:
parent
b7664906f9
commit
7d7eceb3a8
@ -211,7 +211,7 @@ function formatTokenCount(type, omitBrackets)
|
||||
end
|
||||
end
|
||||
|
||||
-- called by cards that seal bless/curse tokens
|
||||
-- seals a token on a card (called by cards that seal bless/curse tokens)
|
||||
---@param param Table This contains the type and guid of the sealed token
|
||||
function sealedToken(param)
|
||||
table.insert(tokensTaken[param.type], param.guid)
|
||||
@ -219,7 +219,7 @@ function sealedToken(param)
|
||||
updateButtonLabels()
|
||||
end
|
||||
|
||||
-- called by cards that seal bless/curse tokens
|
||||
-- returns a token to the bag (called by cards that seal bless/curse tokens)
|
||||
---@param param Table This contains the type and guid of the released token
|
||||
function releasedToken(param)
|
||||
for i, v in ipairs(tokensTaken[param.type]) do
|
||||
@ -238,6 +238,26 @@ function releasedToken(param)
|
||||
end
|
||||
end
|
||||
|
||||
-- removes a token (called by cards that seal bless/curse tokens)
|
||||
---@param param Table This contains the type and guid of the released token
|
||||
function returnedToken(param)
|
||||
for i, v in ipairs(tokensTaken[param.type]) do
|
||||
if v == param.guid then
|
||||
table.remove(tokensTaken[param.type], i)
|
||||
numInPlay[param.type] = numInPlay[param.type] - 1
|
||||
break
|
||||
end
|
||||
end
|
||||
if not updating then
|
||||
updating = true
|
||||
Wait.frames(function()
|
||||
broadcastCount(param.type)
|
||||
updateButtonLabels()
|
||||
updating = false
|
||||
end, 1)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- main functions: add and remove
|
||||
---------------------------------------------------------
|
||||
@ -300,9 +320,7 @@ end
|
||||
function addMenuOptions(parameters)
|
||||
local playerColor = parameters.playerColor
|
||||
local hoveredObject = parameters.hoveredObject
|
||||
if hoveredObject == nil then
|
||||
return
|
||||
elseif hoveredObject.type ~= "Card" then
|
||||
if hoveredObject == nil or hoveredObject.type ~= "Card" then
|
||||
broadcastToColor("Right-click seal options can only be added to cards.", playerColor)
|
||||
return
|
||||
elseif hoveredObject.hasTag("CardThatSeals") or hoveredObject.getVar("MENU_ADDED") == true then
|
||||
|
@ -24,6 +24,11 @@ do
|
||||
getManager().call("releasedToken", { type = type, guid = guid })
|
||||
end
|
||||
|
||||
-- updates the internal count (called by cards that seal bless/curse tokens)
|
||||
BlessCurseManagerApi.returnedToken = function(type, guid)
|
||||
getManager().call("returnedToken", { type = type, guid = guid })
|
||||
end
|
||||
|
||||
-- broadcasts the current status for bless/curse tokens
|
||||
---@param playerColor String Color of the player to show the broadcast to
|
||||
BlessCurseManagerApi.broadcastStatus = function(playerColor)
|
||||
|
@ -8,7 +8,7 @@ local victoryDisplayApi = require("core/VictoryDisplayApi")
|
||||
|
||||
function onLoad()
|
||||
addHotkey("Add doom to agenda", addDoomToAgenda)
|
||||
addHotkey("Add Bless/Curse context menu to card", addBlurseSealingMenu)
|
||||
addHotkey("Add Bless/Curse context menu", addBlurseSealingMenu)
|
||||
addHotkey("Discard object", discardObject)
|
||||
addHotkey("Discard top card", discardTopDeck)
|
||||
addHotkey("Display Bless/Curse status", showBlessCurseStatus)
|
||||
|
@ -22,6 +22,11 @@ SHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)
|
||||
- this entry allows releasing of multiple tokens at once
|
||||
- example usage: "Nephthys" (to release 3 bless tokens at once)
|
||||
|
||||
SHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once)
|
||||
- enables an entry in the context menu
|
||||
- this entry allows returning tokens to the token pool
|
||||
- example usage: "Nephthys" (to return 3 bless tokens at once)
|
||||
|
||||
SHOW_MULTI_SEAL --@type: number (amount of tokens to seal at once)
|
||||
- enables an entry in the context menu
|
||||
- this entry allows sealing of multiple tokens at once
|
||||
@ -96,6 +101,11 @@ function generateContextMenu()
|
||||
self.addContextMenuItem("Release token(s)", releaseAllTokens)
|
||||
end
|
||||
|
||||
-- conditional release option
|
||||
if SHOW_MULTI_RETURN then
|
||||
self.addContextMenuItem("Return " .. SHOW_MULTI_RETURN .. " token(s)", returnMultipleTokens)
|
||||
end
|
||||
|
||||
-- main context menu options to seal tokens
|
||||
for _, map in pairs(ID_URL_MAP) do
|
||||
if (VALID_TOKENS[map.name] ~= nil) or (UPDATE_ON_HOVER and tokensInBag[map.name] and not INVALID_TOKENS[map.name]) then
|
||||
@ -211,6 +221,18 @@ function releaseAllTokens(playerColor)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns multiple tokens at once to the token pool
|
||||
function returnMultipleTokens(playerColor)
|
||||
if SHOW_MULTI_RETURN <= #sealedTokens then
|
||||
for i = 1, SHOW_MULTI_RETURN do
|
||||
returnToken(table.remove(sealedTokens))
|
||||
end
|
||||
printToColor("Returning " .. SHOW_MULTI_RETURN .. " tokens", playerColor)
|
||||
else
|
||||
printToColor("Not enough tokens sealed.", playerColor)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns the token (referenced by GUID) to the chaos bag
|
||||
function putTokenAway(guid)
|
||||
local token = getObjectFromGUID(guid)
|
||||
@ -224,3 +246,15 @@ function putTokenAway(guid)
|
||||
blessCurseManagerApi.releasedToken(name, guid)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns the token to the pool (== removes it)
|
||||
function returnToken(guid)
|
||||
local token = getObjectFromGUID(guid)
|
||||
if not token then return end
|
||||
|
||||
local name = token.getName()
|
||||
token.destruct()
|
||||
if name == "Bless" or name == "Curse" then
|
||||
blessCurseManagerApi.returnedToken(name, guid)
|
||||
end
|
||||
end
|
||||
|
@ -3,5 +3,6 @@ VALID_TOKENS = {
|
||||
}
|
||||
|
||||
SHOW_MULTI_RELEASE = 3
|
||||
SHOW_MULTI_RETURN = 3
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
Loading…
Reference in New Issue
Block a user