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
end
end
log(param)
if not param.fromDrawn or param.fromDrawn == false then
if not param.fromBag then
updateDisplayAndBroadcast(param.type)
end
end

View File

@ -24,9 +24,9 @@ do
-- updates the internal count (called by cards that seal bless/curse tokens)
---@param type string Type of chaos token ("Bless" or "Curse")
---@param guid string GUID of the token
---@param fromDrawn? boolean Whether or not token was just drawn from the chaos bag
BlessCurseManagerApi.releasedToken = function(type, guid, fromDrawn)
getManager().call("releasedToken", { type = type, guid = guid, fromDrawn = fromDrawn })
---@param fromBag? boolean Whether or not token was just drawn from the chaos bag
BlessCurseManagerApi.releasedToken = function(type, guid, fromBag)
getManager().call("releasedToken", { type = type, guid = guid, fromBag = fromBag })
end
-- 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
end
chaosTokens = {}
isTokenXMLActive = false
end
-- returns a single chaos token to the bag and calls respective functions
@ -283,11 +284,17 @@ function getTokenIndex(token)
end
end
function makeButtonsToRedraw(player, tokenList, id)
-- passed from Nkosi, usually, bypassing XML buttons
if type(player) == "table" then
tokenList = player.tokenList
id = player.id
function activeRedrawEffect(originParams)
triggeringCard = originParams.triggeringCard
redrawEligibilty = originParams.redrawEligibilty
redrawnTokenType = originParams.redrawnTokenType
tokenList = originParams.tokenList
end
function makeButtonsToRedraw()
if isTokenXMLActive == true then
broadcastToAll("Clear already active buttons first, then try again", "Red")
return
end
local tokensInPlay = getChaosTokensinPlay()
@ -295,35 +302,32 @@ function makeButtonsToRedraw(player, tokenList, id)
broadcastToAll("No tokens found in play area", "Red")
return
end
local chaosbag = findChaosBag()
local matchingTokensInPlay = {}
-- 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
for _, token in ipairs(tokensInPlay) do
if string.find(tokenList, token.getName(), 1, true) == nil then
matchingTokensInPlay[#matchingTokensInPlay + 1] = token
end
end
if #matchingTokensInPlay == 0 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
elseif redrawEligibilty == "eligible" then
-- cards that dictate only some tokens are eligible for replacement
for _, token in ipairs(tokensInPlay) do
if string.find(tokenList, token.getName()) then
matchingTokensInPlay[#matchingTokensInPlay + 1] = token
end
end
else
-- for any cards that can replace any tokens
matchingTokensInPlay = tokensInPlay
end
if #matchingTokensInPlay == 0 then
broadcastToAll("No eligible token found in play area", "Red")
return
end
if #matchingTokensInPlay == 0 then
broadcastToAll("No eligible token found in play area", "Red")
return
end
if #matchingTokensInPlay > 1 then
@ -342,7 +346,6 @@ function makeButtonsToRedraw(player, tokenList, id)
position = "0 0 -15",
color = "rgba(0,0,0,0.7)",
onClick = "Global/returnAndRedraw(" .. token.getGUID() .. ")",
id = id
},
children = {
{
@ -367,19 +370,21 @@ function makeButtonsToRedraw(player, tokenList, id)
}
})
end
isTokenXMLActive = true
-- no need to make buttons if there is only one eligible token to return and redraw
else
returnAndRedraw(_, matchingTokensInPlay[1].getGUID(), id)
returnAndRedraw(_, matchingTokensInPlay[1].getGUID())
end
end
function returnAndRedraw(_, tokenGUID, id)
function returnAndRedraw(_, tokenGUID)
local indexOfReturnedToken
local takeParameters = {}
local returnedToken = getObjectFromGUID(tokenGUID)
local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition())
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
isTokenXMLActive = false
trackChaosToken(returnedToken.getName(), mat.getGUID(), true)
indexOfReturnedToken = getTokenIndex(returnedToken)
takeParameters.position = returnedToken.getPosition()
@ -391,20 +396,26 @@ function returnAndRedraw(_, tokenGUID, id)
end
returnChaosTokenToBag(returnedToken)
if string.find("all|eligible|ineligible|falseCovenant", id) then
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters})
if redrawnTokenType == "random" then
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters})
else
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters, tokenType = id})
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters, tokenType = redrawnTokenType})
end
chaosTokens[indexOfReturnedToken] = token
if id == "falseCovenant" then
if triggeringCard == "FalseCovenant" then
blessCurseManagerApi.removeToken("Curse")
end
-- remove XML from tokens in play
for _, token in ipairs(getChaosTokensinPlay()) do
token.UI.setXml("")
end
triggeringCard = nil
redrawEligibilty = nil
redrawnTokenType = nil
tokenList = nil
end
-- 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
function onSave()
return JSON.encode(turnOnCFHelper)
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)
originParams = {
triggeringCard = "ClaypoolsFurs",
redrawEligibilty = "eligible",
redrawnTokenType = "random",
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
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnCFHelper = false
end
require("playercards/CardsThatRedrawTokens")

View File

@ -1,55 +1,8 @@
local turnOnCMHelper
function onSave()
return JSON.encode(turnOnCMHelper)
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)
originParams = {
triggeringCard = "CustomModifications",
redrawEligibilty = "ineligible",
redrawnTokenType = "random",
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
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnCMHelper = false
end
require("playercards/CardsThatRedrawTokens")

View File

@ -1,58 +1,13 @@
local turnOnFCHelper
function onSave()
return JSON.encode(turnOnFCHelper)
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)
value = "Cancel"
icon = "token-curse"
color = "#633A84E6"
fontSize = 300
originParams = {
triggeringCard = "FalseCovenant",
redrawEligibilty = "eligible",
redrawnTokenType = "random",
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
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnFCHelper = false
end
require("playercards/CardsThatRedrawTokens")

View File

@ -1,55 +1,8 @@
local turnOnHFHelper
function onSave()
return JSON.encode(turnOnHFHelper)
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)
originParams = {
triggeringCard = "HeavyFurs",
redrawEligibilty = "eligible",
redrawnTokenType = "random",
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
function deleteButton()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", makeXMLButton)
self.UI.setXml("")
turnOnHFHelper = false
end
require("playercards/CardsThatRedrawTokens")

View File

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

View File

@ -1,54 +1,12 @@
local turnOnWAHelper
position = "70 -70 -22"
fontSize = 200
rotation = "0 0 90"
function onSave()
return JSON.encode(turnOnWAHelper)
end
originParams = {
triggeringCard = "Wendy",
redrawEligibilty = "all",
redrawnTokenType = "random",
tokenList = "all"
}
function onLoad(savedData)
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
require("playercards/CardsThatRedrawTokens")