more updates

This commit is contained in:
dscarpac 2024-04-11 20:38:33 -05:00
parent 7c5c98f278
commit b28c9c08cd
6 changed files with 214 additions and 161 deletions

View File

@ -54,6 +54,11 @@
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2026086584372569912/5CB461AEAE2E59D3064D90A776EB86C46081EC78/"
},
{
"Name": "font_arkhamslim",
"Type": 1,
"URL": "http://cloud-3.steamusercontent.com/ugc/2510267299454546112/8CDF773519FEC8C488569072280AC848BCC293D5/"
},
{
"Name": "font_birmingham",
"Type": 1,
@ -253,5 +258,35 @@
"Name": "token-curse",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547135/2360372CBE9452CB7B4D135BE13BBA6D46B7D427/"
},
{
"Name": "token-cultist",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650461/10D8037632900AA86045BDD42A564716D5855B1B/"
},
{
"Name": "token-tablet",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650857/29DAE514E5C838C24C90ABBFFF92B1359B9A2F76/"
},
{
"Name": "token-elder-thing",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650683/1C046B6335317CA1AEBFC80645EEC18852D83D80/"
},
{
"Name": "token-frost",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650766/73E07A50BE6FD9BED266F3421B472C4BF913DE81/"
},
{
"Name": "token-auto-fail",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2510267932886739653/CB7AA2D73777EF5938A6E6CD664B2ABA52B6E20A/"
},
{
"Name": "token-custom",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374792650571/E4C2B2B69282A4EE15FE290FF6B08BEFC8FCA65C/"
}
]

View File

@ -58,5 +58,5 @@
"scaleZ": 1
},
"Value": 0,
"XmlUI": "\u003cInclude src=\"playercards/NkosiMabati3.xml\"/\u003e"
"XmlUI": ""
}

View File

@ -71,8 +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
ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})
---@param returnedToken tts__Object Token to be replaced with newly drawn token
ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved, returnedToken)
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved, returnedToken = returnedToken})
end
-- returns a Table List of chaos token ids in the current chaos bag

View File

@ -257,6 +257,14 @@ function returnChaosTokenToBag(token)
end
end
function getTokenIndex(token)
for i, obj in ipairs(chaosTokens) do
if obj == token then
return i
end
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.
@ -295,13 +303,24 @@ function drawChaosToken(params)
chaosBag.shuffle()
-- add the token to the list, compute new position based on list length
if params.returnedToken then
indexOfReturnedToken = getTokenIndex(params.returnedToken)
tokenPosition = params.returnedToken.getPosition()
if #chaosTokens > indexOfReturnedToken then
tokenRotation = params.mat.getRotation() + Vector(0, 0, -8)
end
returnChaosTokenToBag(params.returnedToken)
else
tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)
tokenPosition = params.mat.positionToWorld(tokenOffset)
tokenRotation = params.mat.getRotation()
end
local token
if params.guidToBeResolved then -- resolve a sealed token from a card
token = getObjectFromGUID(params.guidToBeResolved)
token.setPositionSmooth(params.mat.positionToWorld(tokenOffset))
token.setPositionSmooth(tokenPosition)
local guid = token.getGUID()
local tokenType = token.getName()
if tokenType == "Bless" or tokenType == "Curse" then
@ -310,13 +329,13 @@ function drawChaosToken(params)
tokenArrangerApi.layout()
else -- take a token from the bag, either specified or random
local takeParameters = {
position = params.mat.positionToWorld(tokenOffset),
rotation = params.mat.getRotation()
position = tokenPosition,
rotation = tokenRotation
}
if params.tokenType then
for i, lookedForToken in ipairs(chaosBag.getObjects()) do
if lookedForToken.name == params.tokenType then
if lookedForToken.nickname == params.tokenType then
takeParameters.index = i - 1
end
end

View File

@ -1,110 +1,180 @@
local playmatApi = require("playermat/PlaymatApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local playmatApi = require("playermat/PlaymatApi")
local tokenNames = {
"Skull",
"Cultist",
"Tablet",
"Elder Thing",
"Auto-fail",
"Bless",
"Curse",
"Frost",
"Custom Token"
}
local dataForToken = {
["Skull"] = { color = "#4A0400E6", icon = "token-skull"},
["Cultist"] = { color = "#173B0BE6", icon = "token-cultist"},
["Tablet"] = { color = "#1D2238E6", icon = "token-tablet"},
["Elder Thing"] = { color = "#4D2331E6", icon = "token-elder-thing"},
["Auto-fail"] = { color = "#9B0004E6", icon = "token-auto-fail"},
["Bless"] = { color = "#9D702CE6", icon = "token-bless"},
["Curse"] = { color = "#633A84E6", icon = "token-curse"},
["Frost"] = { color = "#404450E6", icon = "token-frost"},
[""] = { color = "#77674DE6", icon = "token-custom"}
}
local sigil
function onSave()
return JSON.encode()
return JSON.encode(sigil)
end
function onLoad(savedData)
self.addContextMenuItem("Enable Helper", createButtons)
sigil= JSON.decode(savedData)
if sigil and sigil ~= nil then
makeXMLButton(sigil)
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButtons)
end
end
function makeXMLButton(chosenToken)
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,
iconWidth=400,
iconAlignment="Right",
onClick="resolveSigil",
id=sigil,
icon=dataForToken[sigil].icon,
color=dataForToken[sigil].color,
textColor="White",
},
value="Resolve",
}
}
)
end
-- Create buttons to choose sigil
function createButtons()
function createButtons(playerColor)
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButtons)
self.UI.show("choose")
self.UI.show("sigils")
Player[playerColor].showOptionsDialog("Choose Sigil", tokenNames, 1,
function(chosenToken)
if chosenToken == "Custom Token" then
sigil = ""
else
sigil = chosenToken
end
makeXMLButton(sigil)
end
)
end
-- Delete button and remove sigil
function deleteButtons()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", createButtons)
self.UI.hide("resolve_skull")
end
function chooseSigil(_,_,id)
if id == "Bless" then
sigil = "Bless"
self.UI.hide("sigils")
self.UI.hide("choose")
self.UI.show("resolve_bless")
elseif id == "Curse" then
sigil = "Curse"
self.UI.hide("sigils")
self.UI.hide("choose")
self.UI.show("resolve_curse")
else
sigil = "Skull"
self.UI.hide("sigils")
self.UI.hide("choose")
self.UI.show("resolve_skull")
end
log("Sigil is " .. sigil)
self.UI.setXml("")
sigil = nil
end
function resolveSigil()
local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())
local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, "Playermat")
tokenType = sigil
local tokensInPlay = chaosBagApi.getTokensInPlay()
local chaosbag = chaosBagApi.findChaosBag()
local match = false
for i, obj in ipairs(chaosbag.getObjects()) do
-- if there are any sigils in the bag
log(obj.name)
if obj.name == tokenType then
log(tokensInPlay)
if tokensInPlay ~= nil then
for j, token in ipairs(tokensInPlay) do
if token.getName() == "Cultist" then
-- draw XML to return token to bag
if obj.nickname == sigil then
match = true
break
end
end
if not match then
if sigil == "" then
broadcastToAll("Custom token not found in chaos bag", "Red")
else
broadcastToAll(sigil .. " token not found in chaos bag", "Red")
end
return
end
local symbolMatch = false
for j, token in ipairs(tokensInPlay) do
if (token.getName() == "Cultist" or token.getName() == "Elder Thing" or token.getName() == "Tablet") and token.getName() ~= sigil then
symbolMatch = true
-- draw XML to return token to bag
token.UI.setXmlTable({
{
tag="HorizontalLayout",
tag="VerticalLayout",
attributes={
height=200,
width=600,
scale="0.3 0.3 1",
height=275,
width=275,
spacing=0,
padding="0 0 20 25",
scale="0.4 0.4 1",
rotation="0 0 180",
position="0 120 -22",
position="0 0 -15",
color="rgba(0,0,0,0.7)",
onClick=self.getGUID() .. "/drawSigil(" .. token.getGUID() .. ")",
},
children={
{
tag="Button",
tag="Text",
attributes={
fontSize=100,
color="White",
fontSize="100",
font="font_teutonic-arkham",
color="#ffffff",
text="Nkosi",
},
},
{
tag="Text",
attributes={
fontSize="125",
font="font_arkhamslim",
color="#ffffff",
text="U",
},
id="hi",
value="Nkosi React",
onClick="drawSigil",
},
}
}
})
end
end
if not symbolMatch then
broadcastToAll("No eligible symbol token found in play area", "Red")
return
end
end
broadcastToAll("Cultist token not found in play area", "Red")
return
end
end
function drawSigil(player, tokenGUID)
end
broadcastToAll(tokenType .. " token not found in chaos bag", "Red")
returnedToken = getObjectFromGUID(tokenGUID)
local matColor = playmatApi.getMatColorByPosition(returnedToken.getPosition())
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
chaosBagApi.drawChaosToken(mat, true, sigil, _, returnedToken)
local tokensInPlay = chaosBagApi.getTokensInPlay()
for j, returnedToken in ipairs(tokensInPlay) do
if returnedToken.getName() == "Cultist" or returnedToken.getName() == "Elder Thing" or returnedToken.getName() == "Tablet" then
returnedToken.UI.setXml("")
end
end
function drawSigil(_,_,id)
log(id)
--chaosBagApi.returnChaosTokenToBag(token)
tokenType = "Skull"
chaosBagApi.drawChaosToken(mat, true, tokenType, _)
end

View File

@ -1,72 +0,0 @@
<Panel id="choose" position="0 -90 -22"
rotation="0 0 180"
height="200" width="500"
scale="0.3 0.3 1"
showAnimation="FadeIn" hideAnimation="FadeOut" active="false">
<Text font="font_teutonic-arkham" fontSize="100" color="White" outline="Black" outlineSize="2, -2">Choose sigil:</Text>
</Panel>
<Panel id="sigils" position="0 -50 -22"
rotation="0 0 180"
height="200" width="500"
scale="0.3 0.3 1"
showAnimation="FadeIn" hideAnimation="FadeOut" active="false">
<TableLayout cellSpacing="20" cellBackgroundColor="rgba(1,1,1,0)">
<Row>
<Cell><Button id="Bless" color="rgba(1,1,1,0)" icon="token-bless" onClick="chooseSigil"></Button></Cell>
<Cell><Button id="Curse" color="rgba(1,1,1,0)" icon="token-curse" onClick="chooseSigil"></Button></Cell>
<Cell><Button id="Skull" color="rgba(1,1,1,0)" icon="token-skull" onClick="chooseSigil"></Button></Cell>
</Row>
</TableLayout>
</Panel>
<Panel id="resolve_bless"
position="0 -30 -22"
rotation="0 0 180"
height="500" width="1000"
scale="0.1 0.1 1" active="false" showAnimation="FadeIn" hideAnimation="FadeOut"
><Button icon="token-bless" font="font_teutonic-arkham" fontSize="200" textColor="Red"
onClick="resolveSigil" color="rgba(1,1,1,0)" iconAlignment="Right">Resolve </Button></Panel>
<Panel id="resolve_skull"
position="0 -30 -22"
rotation="0 0 180"
height="500" width="1000"
scale="0.1 0.1 1" active="false" showAnimation="FadeIn" hideAnimation="FadeOut"
><Button icon="token-skull" font="font_teutonic-arkham" fontSize="200" textColor="Red"
onClick="resolveSigil" color="rgba(1,1,1,0)" iconAlignment="Right">Resolve </Button></Panel>
<Panel id="resolve_curse"
position="0 -40 -22"
rotation="0 0 180"
height="500" width="1400"
scale="0.1 0.1 1" active="false" showAnimation="FadeIn" hideAnimation="FadeOut"
><Button icon="token-curse" font="font_teutonic-arkham" fontSize="260" textColor="White"
onClick="resolveSigil" color="rgba(1,1,1,0)" iconAlignment="Right" padding="40 40 0 0">Resolve</Button></Panel>
<Defaults>
<Button padding="50 50 50 50"
font="font_teutonic-arkham"
fontSize="300"
iconWidth="400"
iconAlignment="Right"/>
<Panel position="0 -55 -22"
rotation="0 0 180"
height="450" width="1400"
scale="0.1 0.1 1"/>
<TableLayout active="false"
cellSpacing="80"
cellBackgroundColor="rgba(1,1,1,0)"/>
</Defaults>
<Panel>
<TableLayout id="resolve_skull">
<Row>
<Cell>
<Button id="Bless" icon="token-skull" textColor="White"
onClick="resolveSigil" color="#4A0400E6" iconAlignment="Right">Resolve</Button>
</Cell>
</Row>
</TableLayout>
</Panel>