first draft

This commit is contained in:
dscarpac 2024-06-14 16:14:55 -05:00
parent 918d73a0e6
commit 540b6296b2
17 changed files with 444 additions and 106 deletions

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/ClaypoolsFurs\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/CustomModifications\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/FalseCovenant\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/HeavyFurs\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/WendyAdams\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/WendyAdams\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/WendyAdams\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -236,7 +236,10 @@ function releasedToken(param)
break
end
end
updateDisplayAndBroadcast(param.type)
log(param)
if not param.fromDrawn or param.fromDrawn == false then
updateDisplayAndBroadcast(param.type)
end
end
-- removes a token (called by cards that seal bless/curse tokens)

View File

@ -24,8 +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
BlessCurseManagerApi.releasedToken = function(type, guid)
getManager().call("releasedToken", { type = type, guid = guid })
---@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 })
end
-- updates the internal count (called by cards that seal bless/curse tokens)
@ -54,5 +55,17 @@ do
getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
end
-- adds bless / curse to the chaos bag
-- @param type string Type of chaos token ("Bless" or "Curse")
BlessCurseManagerApi.addToken = function(type)
getManager().call("addToken", type)
end
-- removes bless / curse from the chaos bag
-- @param type string Type of chaos token ("Bless" or "Curse")
BlessCurseManagerApi.removeToken = function(type)
getManager().call("removeToken", type)
end
return BlessCurseManagerApi
end

View File

@ -71,9 +71,9 @@ do
---@param drawAdditional boolean Controls whether additional tokens should be drawn
---@param tokenType? string Name of token (e.g. "Bless") to be drawn from the bag
---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag
---@param returnedToken? tts__Object Token to be replaced with newly drawn token
---@param takeParameters? table Position and rotation of the location where the new token should be drawn to, usually to replace a returned token
ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, takeParameters = takeParameters})
end
-- returns a Table List of chaos token ids in the current chaos bag

View File

@ -271,7 +271,7 @@ function returnChaosTokenToBag(token)
chaosBag.putObject(token)
tokenArrangerApi.layout()
if name == "Bless" or name == "Curse" then
blessCurseManagerApi.releasedToken(name, guid)
blessCurseManagerApi.releasedToken(name, guid, true)
end
end
@ -283,6 +283,130 @@ 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
end
local tokensInPlay = getChaosTokensinPlay()
if #tokensInPlay == 0 then
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
-- 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
-- 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
if #matchingTokensInPlay == 0 then
broadcastToAll("No eligible token found in play area", "Red")
return
end
end
if #matchingTokensInPlay > 1 then
for _, token in ipairs(matchingTokensInPlay) do
-- draw XML to return token to bag
token.UI.setXmlTable({
{
tag = "VerticalLayout",
attributes = {
height = 275,
width = 275,
spacing = 0,
padding = "0 0 20 25",
scale = "0.4 0.4 1",
rotation = "0 0 180",
position = "0 0 -15",
color = "rgba(0,0,0,0.7)",
onClick = "Global/returnAndRedraw(" .. token.getGUID() .. ")",
id = id
},
children = {
{
tag = "Text",
attributes = {
fontSize = "100",
font = "font_teutonic-arkham",
color = "#ffffff",
text = "Redraw"
}
},
{
tag = "Text",
attributes = {
fontSize = "125",
font = "font_arkhamicons",
color = "#ffffff",
text = "u"
}
}
}
}
})
end
-- no need to make buttons if there is only one eligible token to return and redraw
else
returnAndRedraw(_, matchingTokensInPlay[1].getGUID(), id)
end
end
function returnAndRedraw(_, tokenGUID, id)
local indexOfReturnedToken
local takeParameters = {}
local returnedToken = getObjectFromGUID(tokenGUID)
local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition())
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
trackChaosToken(returnedToken.getName(), mat.getGUID(), true)
indexOfReturnedToken = getTokenIndex(returnedToken)
takeParameters.position = returnedToken.getPosition()
if #chaosTokens > indexOfReturnedToken then
takeParameters.rotation = mat.getRotation() + Vector(0, 0, -8)
else
takeParameters.rotation = returnedToken.getRotation()
end
returnChaosTokenToBag(returnedToken)
if string.find("all|eligible|ineligible|falseCovenant", id) then
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters})
else
token = drawChaosToken({mat = mat, drawAdditional = true, takeParameters = takeParameters, tokenType = id})
end
chaosTokens[indexOfReturnedToken] = token
if id == "falseCovenant" then
blessCurseManagerApi.removeToken("Curse")
end
-- remove XML from tokens in play
for _, token in ipairs(getChaosTokensinPlay()) do
token.UI.setXml("")
end
end
-- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
-- contents of the bag should check this method before doing so.
@ -334,29 +458,23 @@ function drawChaosToken(params)
if params.drawAdditional or #chaosTokens == 0 then
local chaosBag = findChaosBag()
if #chaosBag.getObjects() == 0 then return end
chaosBag.shuffle()
local indexOfReturnedToken
local takeParameters = {}
-- add the token to the list, compute new position based on list length
if params.returnedToken then
trackChaosToken(params.returnedToken.getName(), matGUID, true)
indexOfReturnedToken = getTokenIndex(params.returnedToken)
takeParameters.position = params.returnedToken.getPosition()
if #chaosTokens > indexOfReturnedToken then
takeParameters.rotation = params.mat.getRotation() + Vector(0, 0, -8)
else
takeParameters.rotation = params.returnedToken.getRotation()
end
returnChaosTokenToBag(params.returnedToken)
if params.takeParameters then
takeParameters.position = params.takeParameters.position
takeParameters.rotation = params.takeParameters.rotation
else
tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)
takeParameters.position = params.mat.positionToWorld(tokenOffset)
takeParameters.rotation = params.mat.getRotation()
end
chaosBag.shuffle()
local token
if params.guidToBeResolved then
-- resolve a sealed token from a card
token = getObjectFromGUID(params.guidToBeResolved)
@ -386,8 +504,8 @@ function drawChaosToken(params)
token.setDescription(specificData.description or "")
trackChaosToken(name, matGUID)
if params.returnedToken then
chaosTokens[indexOfReturnedToken] = token
if params.takeParameters then
return token
else
chaosTokens[#chaosTokens + 1] = token
end

View File

@ -0,0 +1,55 @@
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)
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

View File

@ -0,0 +1,55 @@
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)
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

View File

@ -0,0 +1,58 @@
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)
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

View File

@ -0,0 +1,55 @@
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)
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

View File

@ -15,8 +15,6 @@ local tokenColor = {
[""] = "#77674DE6"
}
local sigil
function onSave()
return JSON.encode(sigil)
end
@ -52,7 +50,7 @@ function makeXMLButton()
iconWidth = "400",
iconAlignment = "Right",
onClick = "resolveSigil",
id = sigil,
id = eligible,
icon = iconName,
color = tokenColor[sigil],
textColor = "White"
@ -109,77 +107,6 @@ function resolveSigil()
return
end
local matchingSymbolsInPlay = {}
for _, token in ipairs(tokensInPlay) do
if (token.getName() == "Cultist"
or token.getName() == "Tablet"
or token.getName() == "Elder Thing")
and token.getName() ~= sigil then
matchingSymbolsInPlay[#matchingSymbolsInPlay + 1] = token
end
end
if #matchingSymbolsInPlay == 0 then
broadcastToAll("No eligible symbol token found in play area", "Red")
return
elseif #matchingSymbolsInPlay > 1 then
for _, token in ipairs(matchingSymbolsInPlay) do
-- draw XML to return token to bag
token.UI.setXmlTable({
{
tag = "VerticalLayout",
attributes = {
height = 275,
width = 275,
spacing = 0,
padding = "0 0 20 25",
scale = "0.4 0.4 1",
rotation = "0 0 180",
position = "0 0 -15",
color = "rgba(0,0,0,0.7)",
onClick = self.getGUID() .. "/drawSigil(" .. token.getGUID() .. ")"
},
children = {
{
tag = "Text",
attributes = {
fontSize = "100",
font = "font_teutonic-arkham",
color = "#ffffff",
text = "Nkosi"
}
},
{
tag = "Text",
attributes = {
fontSize = "125",
font = "font_arkhamicons",
color = "#ffffff",
text = "u"
}
}
}
}
})
end
else
drawSigil(_, matchingSymbolsInPlay[1].getGUID())
end
end
function drawSigil(player, tokenGUID)
local returnedToken = getObjectFromGUID(tokenGUID)
local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition())
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
chaosBagApi.drawChaosToken(mat, true, sigil, _, returnedToken)
-- remove XML from tokens in play
for _, token in ipairs(chaosBagApi.getTokensInPlay()) do
if token.getName() == "Cultist"
or token.getName() == "Tablet"
or token.getName() == "Elder Thing" then
token.UI.setXml("")
end
end
params = { tokenList = "Tablet|Elder Thing|Cultist", id = sigil}
Global.call("makeButtonsToRedraw", params)
end

View File

@ -0,0 +1,54 @@
local turnOnWAHelper
function onSave()
return JSON.encode(turnOnWAHelper)
end
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