updates with redraw require file

This commit is contained in:
dscarpac 2024-06-23 12:40:43 -05:00
parent 540b6296b2
commit 2fcfda2bfe
10 changed files with 148 additions and 298 deletions

View File

@ -236,8 +236,8 @@ function releasedToken(param)
break break
end end
end end
log(param)
if not param.fromDrawn or param.fromDrawn == false then if not param.fromBag then
updateDisplayAndBroadcast(param.type) updateDisplayAndBroadcast(param.type)
end end
end end

View File

@ -24,9 +24,9 @@ do
-- updates the internal count (called by cards that seal bless/curse tokens) -- updates the internal count (called by cards that seal bless/curse tokens)
---@param type string Type of chaos token ("Bless" or "Curse") ---@param type string Type of chaos token ("Bless" or "Curse")
---@param guid string GUID of the token ---@param guid string GUID of the token
---@param fromDrawn? boolean Whether or not token was just drawn from the chaos bag ---@param fromBag? boolean Whether or not token was just drawn from the chaos bag
BlessCurseManagerApi.releasedToken = function(type, guid, fromDrawn) BlessCurseManagerApi.releasedToken = function(type, guid, fromBag)
getManager().call("releasedToken", { type = type, guid = guid, fromDrawn = fromDrawn }) getManager().call("releasedToken", { type = type, guid = guid, fromBag = fromBag })
end end
-- updates the internal count (called by cards that seal bless/curse tokens) -- updates the internal count (called by cards that seal bless/curse tokens)

View File

@ -261,6 +261,7 @@ function returnChaosTokens()
if token ~= nil then chaosBag.putObject(token) end if token ~= nil then chaosBag.putObject(token) end
end end
chaosTokens = {} chaosTokens = {}
isTokenXMLActive = false
end end
-- returns a single chaos token to the bag and calls respective functions -- returns a single chaos token to the bag and calls respective functions
@ -283,11 +284,17 @@ function getTokenIndex(token)
end end
end end
function makeButtonsToRedraw(player, tokenList, id) function activeRedrawEffect(originParams)
-- passed from Nkosi, usually, bypassing XML buttons triggeringCard = originParams.triggeringCard
if type(player) == "table" then redrawEligibilty = originParams.redrawEligibilty
tokenList = player.tokenList redrawnTokenType = originParams.redrawnTokenType
id = player.id tokenList = originParams.tokenList
end
function makeButtonsToRedraw()
if isTokenXMLActive == true then
broadcastToAll("Clear already active buttons first, then try again", "Red")
return
end end
local tokensInPlay = getChaosTokensinPlay() local tokensInPlay = getChaosTokensinPlay()
@ -295,35 +302,32 @@ function makeButtonsToRedraw(player, tokenList, id)
broadcastToAll("No tokens found in play area", "Red") broadcastToAll("No tokens found in play area", "Red")
return return
end end
local chaosbag = findChaosBag() local chaosbag = findChaosBag()
local matchingTokensInPlay = {} local matchingTokensInPlay = {}
-- determine if only some tokens are able to be returned to the bag -- determine if only some tokens are able to be returned to the bag
if id == "ineligible" then if redrawEligibilty == "ineligible" then
-- create list of tokens that should not get an XML button -- create list of tokens that should not get an XML button
for _, token in ipairs(tokensInPlay) do for _, token in ipairs(tokensInPlay) do
if string.find(tokenList, token.getName(), 1, true) == nil then if string.find(tokenList, token.getName(), 1, true) == nil then
matchingTokensInPlay[#matchingTokensInPlay + 1] = token matchingTokensInPlay[#matchingTokensInPlay + 1] = token
end end
end end
if #matchingTokensInPlay == 0 then elseif redrawEligibilty == "eligible" then
broadcastToAll("No eligible token found in play area", "Red")
return
end
elseif id == "all" then
-- for any cards that can replace any tokens
matchingTokensInPlay = tokensInPlay
else
-- cards that dictate only some tokens are eligible for replacement -- cards that dictate only some tokens are eligible for replacement
for _, token in ipairs(tokensInPlay) do for _, token in ipairs(tokensInPlay) do
if string.find(tokenList, token.getName()) then if string.find(tokenList, token.getName()) then
matchingTokensInPlay[#matchingTokensInPlay + 1] = token matchingTokensInPlay[#matchingTokensInPlay + 1] = token
end end
end end
else
-- for any cards that can replace any tokens
matchingTokensInPlay = tokensInPlay
end
if #matchingTokensInPlay == 0 then if #matchingTokensInPlay == 0 then
broadcastToAll("No eligible token found in play area", "Red") broadcastToAll("No eligible token found in play area", "Red")
return return
end
end end
if #matchingTokensInPlay > 1 then if #matchingTokensInPlay > 1 then
@ -342,7 +346,6 @@ function makeButtonsToRedraw(player, tokenList, id)
position = "0 0 -15", position = "0 0 -15",
color = "rgba(0,0,0,0.7)", color = "rgba(0,0,0,0.7)",
onClick = "Global/returnAndRedraw(" .. token.getGUID() .. ")", onClick = "Global/returnAndRedraw(" .. token.getGUID() .. ")",
id = id
}, },
children = { children = {
{ {
@ -367,19 +370,21 @@ function makeButtonsToRedraw(player, tokenList, id)
} }
}) })
end end
isTokenXMLActive = true
-- no need to make buttons if there is only one eligible token to return and redraw -- no need to make buttons if there is only one eligible token to return and redraw
else else
returnAndRedraw(_, matchingTokensInPlay[1].getGUID(), id) returnAndRedraw(_, matchingTokensInPlay[1].getGUID())
end end
end end
function returnAndRedraw(_, tokenGUID, id) function returnAndRedraw(_, tokenGUID)
local indexOfReturnedToken local indexOfReturnedToken
local takeParameters = {} local takeParameters = {}
local returnedToken = getObjectFromGUID(tokenGUID) local returnedToken = getObjectFromGUID(tokenGUID)
local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition()) local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition())
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat") local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
isTokenXMLActive = false
trackChaosToken(returnedToken.getName(), mat.getGUID(), true) trackChaosToken(returnedToken.getName(), mat.getGUID(), true)
indexOfReturnedToken = getTokenIndex(returnedToken) indexOfReturnedToken = getTokenIndex(returnedToken)
takeParameters.position = returnedToken.getPosition() takeParameters.position = returnedToken.getPosition()
@ -391,20 +396,26 @@ function returnAndRedraw(_, tokenGUID, id)
end end
returnChaosTokenToBag(returnedToken) returnChaosTokenToBag(returnedToken)
if string.find("all|eligible|ineligible|falseCovenant", id) then if redrawnTokenType == "random" then
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters}) token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters})
else else
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters, tokenType = id}) token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters, tokenType = redrawnTokenType})
end end
chaosTokens[indexOfReturnedToken] = token chaosTokens[indexOfReturnedToken] = token
if id == "falseCovenant" then if triggeringCard == "FalseCovenant" then
blessCurseManagerApi.removeToken("Curse") blessCurseManagerApi.removeToken("Curse")
end end
-- remove XML from tokens in play -- remove XML from tokens in play
for _, token in ipairs(getChaosTokensinPlay()) do for _, token in ipairs(getChaosTokensinPlay()) do
token.UI.setXml("") token.UI.setXml("")
end end
triggeringCard = nil
redrawEligibilty = nil
redrawnTokenType = nil
tokenList = nil
end end
-- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens -- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens

View File

@ -0,0 +1,61 @@
local turnOnHelper
function onSave()
return JSON.encode(turnOnHelper)
end
function onLoad(savedData)
self.addContextMenuItem("Enable Helper", makeXMLButton)
if savedData and savedData ~= "" then
turnOnHelper = JSON.decode(savedData)
if turnOnHelper == true then
makeXMLButton()
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
end
end
end
function makeXMLButton()
turnOnHelper = true
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
log(color)
local xmlTable = {{
tag = "Button",
attributes = {
height = 450,
width = 1400,
rotation = rotation or "0 0 180",
scale = "0.1 0.1 1",
position = position or "0 -55 -22",
padding = "50 50 50 50",
font = "font_teutonic-arkham",
fontSize = fontSize or 250,
onClick = "triggerXMLTokenLabelCreation()",
color = color or "#77674DE6",
textColor = "White"
},
value = value or "Redraw Token"
}}
if icon then
xmlTable[1].attributes.iconWidth = "400"
xmlTable[1].attributes.iconAlignment = "Right"
xmlTable[1].attributes.icon = icon
end
self.UI.setXmlTable(xmlTable)
end
function triggerXMLTokenLabelCreation()
Global.call("activeRedrawEffect", originParams)
Global.call("makeButtonsToRedraw")
end
-- Delete button
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnHelper = false
end

View File

@ -1,55 +1,8 @@
local turnOnCFHelper originParams = {
triggeringCard = "ClaypoolsFurs",
function onSave() redrawEligibilty = "eligible",
return JSON.encode(turnOnCFHelper) redrawnTokenType = "random",
end
function onLoad(savedData)
self.addContextMenuItem("Enable Helper", makeXMLButton)
if savedData ~= "" then
turnOnCFHelper = JSON.decode(savedData)
if turnOnCFHelper == true then
makeXMLButton()
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
end
end
end
function makeXMLButton()
turnOnCFHelper = true
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
tokenList = "Frost" tokenList = "Frost"
self.UI.setXmlTable({ }
{
tag = "Button",
attributes = {
height = 450,
width = 1400,
rotation = "0 0 180",
scale = "0.1 0.1 1",
position = "0 -55 -22",
padding = "50 50 50 50",
font = "font_teutonic-arkham",
fontSize = 250,
onClick = "Global/makeButtonsToRedraw(".. tokenList ..")",
id = "eligible",
color = "#77674DE6",
textColor = "White"
},
value = "Redraw Token"
}
}
)
end
-- Delete button require("playercards/CardsThatRedrawTokens")
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnCFHelper = false
end

View File

@ -1,55 +1,8 @@
local turnOnCMHelper originParams = {
triggeringCard = "CustomModifications",
function onSave() redrawEligibilty = "ineligible",
return JSON.encode(turnOnCMHelper) redrawnTokenType = "random",
end
function onLoad(savedData)
self.addContextMenuItem("Enable Helper", makeXMLButton)
if savedData ~= "" then
turnOnCMHelper = JSON.decode(savedData)
if turnOnCMHelper == true then
makeXMLButton()
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
end
end
end
function makeXMLButton()
turnOnCMHelper = true
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
tokenList = "Auto-fail" tokenList = "Auto-fail"
self.UI.setXmlTable({ }
{
tag = "Button",
attributes = {
height = 450,
width = 1400,
rotation = "0 0 180",
scale = "0.1 0.1 1",
position = "0 -55 -22",
padding = "50 50 50 50",
font = "font_teutonic-arkham",
fontSize = 250,
onClick = "Global/makeButtonsToRedraw(".. tokenList ..")",
id = "ineligible",
color = "#77674DE6",
textColor = "White"
},
value = "Redraw Token"
}
}
)
end
-- Delete button require("playercards/CardsThatRedrawTokens")
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnCMHelper = false
end

View File

@ -1,58 +1,13 @@
local turnOnFCHelper value = "Cancel"
icon = "token-curse"
function onSave() color = "#633A84E6"
return JSON.encode(turnOnFCHelper) fontSize = 300
end
function onLoad(savedData)
self.addContextMenuItem("Enable Helper", makeXMLButton)
if savedData ~= "" then
turnOnFCHelper = JSON.decode(savedData)
if turnOnFCHelper == true then
makeXMLButton()
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
end
end
end
function makeXMLButton()
turnOnFCHelper = true
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
originParams = {
triggeringCard = "FalseCovenant",
redrawEligibilty = "eligible",
redrawnTokenType = "random",
tokenList = "Curse" tokenList = "Curse"
self.UI.setXmlTable({ }
{
tag = "Button",
attributes = {
height = 450,
width = 1400,
rotation = "0 0 180",
scale = "0.1 0.1 1",
position = "0 -55 -22",
padding = "50 50 50 50",
font = "font_teutonic-arkham",
fontSize = 300,
onClick = "Global/makeButtonsToRedraw(".. tokenList ..")",
id = "falseCovenant",
color = "#633A84E6",
textColor = "White",
iconWidth = "400",
iconAlignment = "Right",
icon = "token-curse"
},
value = "Cancel"
}
}
)
end
-- Delete button require("playercards/CardsThatRedrawTokens")
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnFCHelper = false
end

View File

@ -1,55 +1,8 @@
local turnOnHFHelper originParams = {
triggeringCard = "HeavyFurs",
function onSave() redrawEligibilty = "eligible",
return JSON.encode(turnOnHFHelper) redrawnTokenType = "random",
end
function onLoad(savedData)
self.addContextMenuItem("Enable Helper", makeXMLButton)
if savedData ~= "" then
turnOnHFHelper = JSON.decode(savedData)
if turnOnHFHelper == true then
makeXMLButton()
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
end
end
end
function makeXMLButton()
turnOnHFHelper = true
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
tokenList = "Skull|Tablet|Elder Thing|Cultist|Frost|Custom Token|Elder Sign|Bless|Curse" tokenList = "Skull|Tablet|Elder Thing|Cultist|Frost|Custom Token|Elder Sign|Bless|Curse"
self.UI.setXmlTable({ }
{
tag = "Button",
attributes = {
height = 450,
width = 1400,
rotation = "0 0 180",
scale = "0.1 0.1 1",
position = "0 -55 -22",
padding = "50 50 50 50",
font = "font_teutonic-arkham",
fontSize = 250,
onClick = "Global/makeButtonsToRedraw(".. tokenList ..")",
id = "eligible",
color = "#77674DE6",
textColor = "White"
},
value = "Redraw Token"
}
}
)
end
-- Delete button require("playercards/CardsThatRedrawTokens")
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnHFHelper = false
end

View File

@ -107,6 +107,12 @@ function resolveSigil()
return return
end end
params = { tokenList = "Tablet|Elder Thing|Cultist", id = sigil} originParams = {
Global.call("makeButtonsToRedraw", params) triggeringCard = "Nkosi",
redrawEligibilty = "eligible",
redrawnTokenType = sigil,
tokenList = "Tablet|Elder Thing|Cultist"
}
Global.call("activeRedrawEffect", originParams)
Global.call("makeButtonsToRedraw")
end end

View File

@ -1,54 +1,12 @@
local turnOnWAHelper position = "70 -70 -22"
fontSize = 200
rotation = "0 0 90"
function onSave() originParams = {
return JSON.encode(turnOnWAHelper) triggeringCard = "Wendy",
end redrawEligibilty = "all",
redrawnTokenType = "random",
tokenList = "all"
}
function onLoad(savedData) require("playercards/CardsThatRedrawTokens")
self.addContextMenuItem("Enable Helper", makeXMLButton)
if savedData ~= "" then
turnOnWAHelper = JSON.decode(savedData)
if turnOnWAHelper == true then
makeXMLButton()
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
end
end
end
function makeXMLButton()
turnOnWAHelper = true
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButton)
self.UI.setXmlTable({
{
tag = "Button",
attributes = {
height = 320,
width = 1100,
rotation = "0 0 90",
scale = "0.1 0.1 1",
position = "70 -70 -22",
padding = "50 50 50 50",
font = "font_teutonic-arkham",
fontSize = 200,
onClick = "Global/makeButtonsToRedraw()",
id = "all",
color = "#77674DE6",
textColor = "White"
},
value = "Redraw Token"
}
}
)
end
-- Delete button
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnHFHelper = false
end