many updates
This commit is contained in:
parent
289f786eb2
commit
55654a288a
@ -47,8 +47,9 @@ do
|
||||
|
||||
-- returns a chaos token to the bag and calls all relevant functions
|
||||
---@param token tts__Object Chaos token to return
|
||||
ChaosBagApi.returnChaosTokenToBag = function(token)
|
||||
return Global.call("returnChaosTokenToBag", token)
|
||||
---@param fromBag boolean whether or not the token to return was in the middle of being drawn (true) or elsewhere (false)
|
||||
ChaosBagApi.returnChaosTokenToBag = function(token, fromBag)
|
||||
return Global.call("returnChaosTokenToBag", { token = token, fromBag = fromBag })
|
||||
end
|
||||
|
||||
-- spawns the specified chaos token and puts it into the chaos bag
|
||||
|
@ -207,6 +207,12 @@ function onObjectEnterZone(zone, object)
|
||||
object.clearContextMenu()
|
||||
object.call("shutOff")
|
||||
end
|
||||
if object.hasTag("CardThatSeals") then
|
||||
local func = object.getVar("resetSealedTokens") -- check if function exists (it won't for older custom content)
|
||||
if func ~= nil then
|
||||
object.call("resetSealedTokens")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -301,13 +307,13 @@ function returnChaosTokens()
|
||||
end
|
||||
|
||||
-- returns a single chaos token to the bag and calls respective functions
|
||||
function returnChaosTokenToBag(token)
|
||||
local name = token.getName()
|
||||
function returnChaosTokenToBag(params)
|
||||
local name = params.token.getName()
|
||||
local chaosBag = findChaosBag()
|
||||
chaosBag.putObject(token)
|
||||
chaosBag.putObject(params.token)
|
||||
tokenArrangerApi.layout()
|
||||
if name == "Bless" or name == "Curse" then
|
||||
blessCurseManagerApi.releasedToken(name, token.getGUID(), true)
|
||||
blessCurseManagerApi.releasedToken(name, params.token.getGUID(), params.fromBag)
|
||||
end
|
||||
end
|
||||
|
||||
@ -418,7 +424,8 @@ function returnAndRedraw(_, tokenGUID)
|
||||
|
||||
-- perform the actual token replacing
|
||||
trackChaosToken(tokenName, mat.getGUID(), true)
|
||||
returnChaosTokenToBag(returnedToken)
|
||||
params = {token = returnedToken, fromBag = true}
|
||||
returnChaosTokenToBag(params)
|
||||
|
||||
chaosTokens[indexOfReturnedToken] = drawChaosToken({
|
||||
mat = mat,
|
||||
|
@ -1,7 +1,16 @@
|
||||
--[[ Library for cards that seal tokens
|
||||
This file is used to add sealing option to cards' context menu.
|
||||
NOTE: all cards are allowed to release a single token to enable Hallow and A Watchful Peace,
|
||||
and to release all sealed tokens to allow for cards that might leave play with sealed tokens on them.
|
||||
Valid options (set before requiring this file):
|
||||
|
||||
MAX_SEALED --@type: number (maximum number of tokens allowable by the card to be sealed)
|
||||
- required for all cards
|
||||
- if MAX_SEALED is more than 1, then an XML label is created for the topmost token indicating the number of sealed tokens
|
||||
- gives an error if user tries to seal additional tokens on the card
|
||||
- example usage: "The Chthonian Stone"
|
||||
> MAX_SEALED = 1
|
||||
|
||||
UPDATE_ON_HOVER --@type: boolean
|
||||
- automatically updates the context menu options when the card is hovered
|
||||
- the "Read Bag" function reads the content of the chaos bag to update the context menu
|
||||
@ -12,23 +21,12 @@ KEEP_OPEN --@type: boolean
|
||||
- makes the context menu stay open after selecting an option
|
||||
- example usage: "Unrelenting"
|
||||
|
||||
SHOW_SINGLE_RELEASE --@type: boolean
|
||||
- enables an entry in the context menu
|
||||
- this entry allows releasing a single token
|
||||
- example usage: "Holy Spear" (to keep the other tokens and just release one)
|
||||
|
||||
SHOW_UP_TO_MULTI_RELEASE --@type: number (maximum amount of tokens to release at once)
|
||||
SHOW_MULTI_RELEASE --@type: number (maximum amount of tokens to release at once)
|
||||
- enables an entry in the context menu
|
||||
- this entry allows releasing of multiple tokens at once, to the maximum number
|
||||
- does not fail if there are fewer than the maximum sealed
|
||||
- example usage: "Nephthys" (to release up to 3 bless tokens at once)
|
||||
|
||||
SHOW_MULTI_RELEASE --@type: number (amount of tokens to release at once)
|
||||
- enables an entry in the context menu
|
||||
- this entry allows releasing of multiple tokens at once
|
||||
- fails if not enough tokens are sealed
|
||||
- example usage: Maybe a Custom Card?
|
||||
|
||||
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
|
||||
@ -66,6 +64,7 @@ Thus it should be implemented like this:
|
||||
> ["+1"] = true,
|
||||
> ["Elder Sign"] = true
|
||||
> }
|
||||
> MAX_SEALED = 1
|
||||
> require...
|
||||
----------------------------------------------------------
|
||||
Example 2: Holy Spear
|
||||
@ -76,8 +75,8 @@ Thus it should be implemented like this:
|
||||
> VALID_TOKENS = {
|
||||
> ["Bless"] = true
|
||||
> }
|
||||
> SHOW_SINGLE_RELEASE = true
|
||||
> SHOW_MULTI_SEAL = 2
|
||||
> MAX_SEALED = 10
|
||||
> require...
|
||||
----------------------------------------------------------]]
|
||||
|
||||
@ -117,18 +116,18 @@ end
|
||||
|
||||
-- builds the context menu
|
||||
function generateContextMenu()
|
||||
-- conditional single or multi release options
|
||||
|
||||
self.addContextMenuItem("Release one token", releaseOneToken)
|
||||
|
||||
-- conditional release options
|
||||
if MAX_SEALED > 1 then
|
||||
self.addContextMenuItem("Release one token", releaseOneToken)
|
||||
end
|
||||
if SHOW_UP_TO_MULTI_RELEASE then
|
||||
self.addContextMenuItem("Release max " .. SHOW_UP_TO_MULTI_RELEASE .. " tokens", releaseUpToMultipleTokens)
|
||||
elseif SHOW_MULTI_RELEASE then
|
||||
self.addContextMenuItem("Release " .. SHOW_MULTI_RELEASE .. " token(s)", releaseMultipleTokens)
|
||||
else
|
||||
self.addContextMenuItem("Release all tokens", releaseAllTokens)
|
||||
end
|
||||
|
||||
if SHOW_MULTI_RELEASE then
|
||||
self.addContextMenuItem("Release " .. SHOW_MULTI_RELEASE .. " token(s)", releaseMultipleTokens)
|
||||
end
|
||||
|
||||
if RESOLVE_TOKEN then
|
||||
local firstTokenType
|
||||
for tokenType, val in pairs(VALID_TOKENS) do
|
||||
@ -246,35 +245,23 @@ function releaseOneToken(playerColor)
|
||||
end
|
||||
end
|
||||
|
||||
-- release multiple tokens at once
|
||||
function releaseMultipleTokens(playerColor)
|
||||
if SHOW_MULTI_RELEASE <= #sealedTokens then
|
||||
for i = 1, SHOW_MULTI_RELEASE do
|
||||
putTokenAway(table.remove(sealedTokens))
|
||||
end
|
||||
printToColor("Releasing " .. SHOW_MULTI_RELEASE .. " tokens", playerColor)
|
||||
else
|
||||
printToColor("Not enough tokens sealed.", playerColor)
|
||||
end
|
||||
end
|
||||
|
||||
-- release up to multiple tokens at once with no minimum
|
||||
function releaseUpToMultipleTokens(playerColor)
|
||||
function releaseMultipleTokens(playerColor)
|
||||
if #sealedTokens == 0 then
|
||||
printToColor("Not enough tokens sealed.", playerColor)
|
||||
return
|
||||
end
|
||||
if #sealedTokens < SHOW_UP_TO_MULTI_RELEASE then
|
||||
if #sealedTokens < SHOW_MULTI_RELEASE then
|
||||
local numRemoved = #sealedTokens
|
||||
for i = 1, #sealedTokens do
|
||||
for i = 1, numRemoved do
|
||||
putTokenAway(table.remove(sealedTokens))
|
||||
end
|
||||
printToColor("Releasing " .. numRemoved .. " tokens", playerColor)
|
||||
else
|
||||
for i = 1, SHOW_UP_TO_MULTI_RELEASE do
|
||||
for i = 1, SHOW_MULTI_RELEASE do
|
||||
putTokenAway(table.remove(sealedTokens))
|
||||
end
|
||||
printToColor("Releasing " .. SHOW_UP_TO_MULTI_RELEASE .. " tokens", playerColor)
|
||||
printToColor("Releasing " .. SHOW_MULTI_RELEASE .. " tokens", playerColor)
|
||||
end
|
||||
end
|
||||
|
||||
@ -341,19 +328,20 @@ function resolveSealed()
|
||||
local closestMatColor = playermatApi.getMatColorByPosition(self.getPosition())
|
||||
local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, "Playermat")
|
||||
local guidToBeResolved = table.remove(sealedTokens)
|
||||
local token = getObjectFromGUID(guidToBeResolved)
|
||||
token.UI.setXml("")
|
||||
local resolvedToken = getObjectFromGUID(guidToBeResolved)
|
||||
resolvedToken.UI.setXml("")
|
||||
updateStackSize()
|
||||
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
|
||||
end
|
||||
|
||||
function updateStackSize()
|
||||
if MAX_SEALED == 1 then return end
|
||||
if #sealedTokens == 0 then return end
|
||||
-- get topmost sealed token
|
||||
local token = getObjectFromGUID(sealedTokens[#sealedTokens])
|
||||
local name = token.getName()
|
||||
local topToken = getObjectFromGUID(sealedTokens[#sealedTokens])
|
||||
local name = topToken.getName()
|
||||
|
||||
token.UI.setXmlTable({
|
||||
topToken.UI.setXmlTable({
|
||||
{
|
||||
tag = "Panel",
|
||||
attributes = {
|
||||
|
@ -2,7 +2,6 @@ VALID_TOKENS = {
|
||||
["Curse"] = true
|
||||
}
|
||||
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
KEEP_OPEN = true
|
||||
MAX_SEALED = 3
|
||||
RESOLVE_TOKEN = true
|
||||
|
@ -2,7 +2,6 @@ VALID_TOKENS = {
|
||||
["Bless"] = true
|
||||
}
|
||||
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
KEEP_OPEN = true
|
||||
MAX_SEALED = 3
|
||||
RESOLVE_TOKEN = true
|
||||
|
@ -2,7 +2,6 @@ VALID_TOKENS = {
|
||||
["Curse"] = true
|
||||
}
|
||||
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
MAX_SEALED = 10
|
||||
KEEP_OPEN = true
|
||||
|
||||
|
@ -2,7 +2,6 @@ VALID_TOKENS = {
|
||||
["Bless"] = true
|
||||
}
|
||||
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
SHOW_MULTI_SEAL = 2
|
||||
MAX_SEALED = 10
|
||||
|
||||
|
@ -3,8 +3,7 @@ VALID_TOKENS = {
|
||||
}
|
||||
|
||||
KEEP_OPEN = true
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
SHOW_UP_TO_MULTI_RELEASE = 3
|
||||
SHOW_MULTI_RELEASE = 3
|
||||
SHOW_MULTI_RETURN = 3
|
||||
MAX_SEALED = 10
|
||||
|
||||
|
@ -3,7 +3,6 @@ VALID_TOKENS = {
|
||||
}
|
||||
|
||||
KEEP_OPEN = true
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
MAX_SEALED = 5
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -2,7 +2,6 @@ VALID_TOKENS = {
|
||||
["0"] = true
|
||||
}
|
||||
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
MAX_SEALED = 4 -- Core Set is component-limited to 4 '0' tokens
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -3,7 +3,6 @@ VALID_TOKENS = {
|
||||
}
|
||||
|
||||
KEEP_OPEN = true
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
MAX_SEALED = 5
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -260,7 +260,7 @@ function discardListOfObjects(objList)
|
||||
end
|
||||
elseif tokenChecker.isChaosToken(obj) then
|
||||
-- put chaos tokens back into bag (e.g. Unrelenting)
|
||||
chaosBagApi.returnChaosTokenToBag(obj)
|
||||
chaosBagApi.returnChaosTokenToBag(obj, false)
|
||||
elseif not obj.getLock() and not obj.hasTag("DontDiscard") then
|
||||
-- don't touch locked objects (like the table etc.) or specific objects (like key tokens)
|
||||
ownedObjects.Trash.putObject(obj)
|
||||
@ -878,7 +878,7 @@ function removeTokensFromObject(object)
|
||||
|
||||
for _, obj in ipairs(searchLib.onObject(object)) do
|
||||
if tokenChecker.isChaosToken(obj) then
|
||||
chaosBagApi.returnChaosTokenToBag(obj)
|
||||
chaosBagApi.returnChaosTokenToBag(obj, false)
|
||||
elseif obj.getGUID() ~= "4ee1f2" and -- table
|
||||
obj ~= self and
|
||||
obj.type ~= "Deck" and
|
||||
|
Loading…
Reference in New Issue
Block a user