From 327893e214ba4c30b52ae64ccba9fc64b53fd0ae Mon Sep 17 00:00:00 2001 From: dscarpac Date: Sun, 22 Sep 2024 22:10:37 -0500 Subject: [PATCH] added option --- src/playercards/CardsThatSealTokens.ttslua | 24 +++++++++++++++++++--- src/playercards/cards/RadiantSmite1.ttslua | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/playercards/CardsThatSealTokens.ttslua b/src/playercards/CardsThatSealTokens.ttslua index a07e2891..3e01d56a 100644 --- a/src/playercards/CardsThatSealTokens.ttslua +++ b/src/playercards/CardsThatSealTokens.ttslua @@ -33,6 +33,11 @@ SHOW_MULTI_RETURN --@type: number (amount of tokens to return to pool at once) - fails if not enough tokens are sealed - example usage: "Nephthys" (to return 3 bless tokens at once) +SHOW_RETURN_ALL --@boolean: + - enables an entry in the context menu + - this entry allows returning all sealed tokens to the token pool + - example usage: "Radiant Smite" (to return whatever number of bless tokens that are sealed 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 @@ -137,11 +142,14 @@ function generateContextMenu() self.addContextMenuItem("Resolve " .. firstTokenType, resolveSealed) end - -- conditional release option if SHOW_MULTI_RETURN then self.addContextMenuItem("Return " .. SHOW_MULTI_RETURN .. " token(s)", returnMultipleTokens) end + if SHOW_RETURN_ALL then + self.addContextMenuItem("Return all tokens", returnAllTokens) + 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 @@ -289,20 +297,30 @@ function releaseAllTokens(playerColor) Player[playerColor].clearSelectedObjects() end --- returns multiple tokens at once to the token pool +-- returns multiple tokens at once to the token pool (with minimum) function returnMultipleTokens(playerColor) if SHOW_MULTI_RETURN <= #sealedTokens then for i = 1, SHOW_MULTI_RETURN do returnToken(table.remove(sealedTokens)) end updateSave() - printToColor("Returning " .. SHOW_MULTI_RETURN .. " tokens", playerColor) + printToColor("Returning " .. SHOW_MULTI_RETURN .. " tokens to the token pool", playerColor) else printToColor("Not enough tokens sealed.", playerColor) end Player[playerColor].clearSelectedObjects() end +-- returns all sealed tokens to the token pool +function returnAllTokens(playerColor) + printToColor("Returning " .. #sealedTokens .. " tokens to the token pool", playerColor) + for i = 1, #sealedTokens do + returnToken(table.remove(sealedTokens)) + end + updateSave() + Player[playerColor].clearSelectedObjects() +end + -- returns the token (referenced by GUID) to the chaos bag function putTokenAway(guid) local token = getObjectFromGUID(guid) diff --git a/src/playercards/cards/RadiantSmite1.ttslua b/src/playercards/cards/RadiantSmite1.ttslua index 956c79fe..2d9cdce2 100644 --- a/src/playercards/cards/RadiantSmite1.ttslua +++ b/src/playercards/cards/RadiantSmite1.ttslua @@ -4,5 +4,6 @@ VALID_TOKENS = { KEEP_OPEN = true MAX_SEALED = 3 +SHOW_RETURN_ALL = true require("playercards/CardsThatSealTokens")