diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index 3f31c3b3..7853f75d 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -238,5 +238,20 @@ "Name": "box-cover-mask-wide", "Type": 0, "URL": "http://cloud-3.steamusercontent.com/ugc/2115061298538827369/A20C2ECB8ECDC1B0AD8B2B38F68CA1C1F5E07D37/" + }, + { + "Name": "token-skull", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547231/E0FEEF462DE4E7704832CA2415D0D027A6BF5041/" + }, + { + "Name": "token-bless", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547028/7855033DE0EB1FDDF706E1303054D35FE0902532/" + }, + { + "Name": "token-curse", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547135/2360372CBE9452CB7B4D135BE13BBA6D46B7D427/" } ] diff --git a/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json b/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json index e937c8b1..0a08a89d 100644 --- a/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json +++ b/objects/AllPlayerCards.15bb07/NkosiMabati3.6c5628.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "require(\"playercards/cards/NkosiMabati3\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -58,5 +58,5 @@ "scaleZ": 1 }, "Value": 0, - "XmlUI": "" + "XmlUI": "\u003cInclude src=\"playercards/NkosiMabati3.xml\"/\u003e" } diff --git a/src/playercards/cards/NkosiMabati3.ttslua b/src/playercards/cards/NkosiMabati3.ttslua new file mode 100644 index 00000000..d8e416a0 --- /dev/null +++ b/src/playercards/cards/NkosiMabati3.ttslua @@ -0,0 +1,110 @@ +local playmatApi = require("playermat/PlaymatApi") +local guidReferenceApi = require("core/GUIDReferenceApi") +local chaosBagApi = require("chaosbag/ChaosBagApi") + +function onSave() + return JSON.encode() +end + +function onLoad(savedData) + self.addContextMenuItem("Enable Helper", createButtons) + self.addContextMenuItem("Clear Helper", deleteButtons) +end + +-- Create buttons to choose sigil +function createButtons() + self.clearContextMenu() + self.addContextMenuItem("Clear Helper", deleteButtons) + self.UI.show("choose") + self.UI.show("sigils") +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) + +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() + 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 + + end + + end + broadcastToAll(tokenType .. " token not found in chaos bag", "Red") + +end + +function drawSigil(_,_,id) + log(id) + --chaosBagApi.returnChaosTokenToBag(token) + tokenType = "Skull" + chaosBagApi.drawChaosToken(mat, true, tokenType, _) +end \ No newline at end of file diff --git a/xml/playercards/NkosiMabati3.xml b/xml/playercards/NkosiMabati3.xml new file mode 100644 index 00000000..b0c8b815 --- /dev/null +++ b/xml/playercards/NkosiMabati3.xml @@ -0,0 +1,72 @@ + + Choose sigil: + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file