diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json
index 7853f75d..69bb9dee 100644
--- a/modsettings/CustomUIAssets.json
+++ b/modsettings/CustomUIAssets.json
@@ -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/"
}
]
diff --git a/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json b/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json
index 0a08a89d..add19374 100644
--- a/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json
+++ b/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json
@@ -58,5 +58,5 @@
"scaleZ": 1
},
"Value": 0,
- "XmlUI": "\u003cInclude src=\"playercards/NkosiMabati3.xml\"/\u003e"
+ "XmlUI": ""
}
diff --git a/src/chaosbag/ChaosBagApi.ttslua b/src/chaosbag/ChaosBagApi.ttslua
index 9f4db6ad..03a84693 100644
--- a/src/chaosbag/ChaosBagApi.ttslua
+++ b/src/chaosbag/ChaosBagApi.ttslua
@@ -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
diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua
index e154deb9..3f28d194 100644
--- a/src/core/Global.ttslua
+++ b/src/core/Global.ttslua
@@ -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
- tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)
+ 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
diff --git a/src/playercards/cards/NkosiMabati3.ttslua b/src/playercards/cards/NkosiMabati3.ttslua
index d8e416a0..e8643ec4 100644
--- a/src/playercards/cards/NkosiMabati3.ttslua
+++ b/src/playercards/cards/NkosiMabati3.ttslua
@@ -1,110 +1,180 @@
-local playmatApi = require("playermat/PlaymatApi")
-local guidReferenceApi = require("core/GUIDReferenceApi")
-local chaosBagApi = require("chaosbag/ChaosBagApi")
+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)
- self.addContextMenuItem("Clear Helper", deleteButtons)
+ 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
-
- token.UI.setXmlTable({
- {
- tag="HorizontalLayout",
- attributes={
- height=200,
- width=600,
- scale="0.3 0.3 1",
- rotation="0 0 180",
- position="0 120 -22",
- color="rgba(0,0,0,0.7)",
- },
- children={
- {
- tag="Button",
- attributes={
- fontSize=100,
- color="White",
- },
- id="hi",
- value="Nkosi React",
- onClick="drawSigil",
- },
- }
- }
- })
- return
- end
- end
- broadcastToAll("Cultist token not found in play area", "Red")
- return
- end
-
+ if obj.nickname == sigil then
+ match = true
+ break
end
-
end
- broadcastToAll(tokenType .. " token not found in chaos bag", "Red")
-
+ 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="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_arkhamslim",
+ color="#ffffff",
+ text="U",
+ },
+ },
+ }
+ }
+ })
+ end
+ end
+
+ if not symbolMatch then
+ broadcastToAll("No eligible symbol token found in play area", "Red")
+ return
+ end
end
-function drawSigil(_,_,id)
- log(id)
- --chaosBagApi.returnChaosTokenToBag(token)
- tokenType = "Skull"
- chaosBagApi.drawChaosToken(mat, true, tokenType, _)
+function drawSigil(player, tokenGUID)
+
+ 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
end
\ No newline at end of file
diff --git a/xml/playercards/NkosiMabati3.xml b/xml/playercards/NkosiMabati3.xml
deleted file mode 100644
index b0c8b815..00000000
--- a/xml/playercards/NkosiMabati3.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
- Choose sigil:
-
-
-
-
-
-
- |
- |
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
\ No newline at end of file