From d7e14fd9ec9ed1c7ef1344d0a9cc5cceb748cbe8 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 2 Nov 2024 00:12:07 +0100 Subject: [PATCH] Added helper for Elle Rubash --- .../ElleRubash2.43c3e0.json | 7 +++-- src/core/Global.ttslua | 4 +++ src/playercards/cards/ElleRubash2.ttslua | 28 +++++++++++++++++++ .../cards/ProtectiveIncantation1.ttslua | 2 +- xml/playercards/ElleRubash2.xml | 14 ++++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/playercards/cards/ElleRubash2.ttslua create mode 100644 xml/playercards/ElleRubash2.xml diff --git a/objects/AllPlayerCards.15bb07/ElleRubash2.43c3e0.json b/objects/AllPlayerCards.15bb07/ElleRubash2.43c3e0.json index 77aee9aa..93def21d 100644 --- a/objects/AllPlayerCards.15bb07/ElleRubash2.43c3e0.json +++ b/objects/AllPlayerCards.15bb07/ElleRubash2.43c3e0.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "require(\"playercards/cards/ElleRubash2\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", @@ -43,7 +43,8 @@ "Sticky": true, "Tags": [ "Asset", - "PlayerCard" + "PlayerCard", + "CardWithHelper" ], "Tooltip": true, "Transform": { @@ -58,5 +59,5 @@ "scaleZ": 1 }, "Value": 0, - "XmlUI": "" + "XmlUI": "\u003cInclude src=\"playercards/ElleRubash2.xml\"/\u003e" } diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index b724fd3e..4605967f 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2708,6 +2708,10 @@ end -- Callback functions for token spawning --------------------------------------------------------- +function addTagToToken(obj, tag) + obj.addTag(tag) +end + function updateUniversalActionAbilityToken(obj, params) obj.call("updateClassAndSymbol", params) if params.addTag then diff --git a/src/playercards/cards/ElleRubash2.ttslua b/src/playercards/cards/ElleRubash2.ttslua new file mode 100644 index 00000000..cd0bfbc2 --- /dev/null +++ b/src/playercards/cards/ElleRubash2.ttslua @@ -0,0 +1,28 @@ +require("playercards/CardsWithHelper") +local tokenManagerApi = require("core/token/TokenManagerApi") + +-- intentionally global +hasXML = true +isHelperEnabled = false + +function updateSave() + self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled }) +end + +function onLoad(savedData) + if savedData and savedData ~= "" then + local loadedData = JSON.decode(savedData) + isHelperEnabled = loadedData.isHelperEnabled + if isHelperEnabled then updateDisplay() end + end +end + +function spawnIgnoredDoom() + tokenManagerApi.spawnToken( + self.positionToWorld({ 0, 0, -0.9 }) + Vector(0, 1, 0), + "doom", + self.getRotation(), + "addTagToToken", + "DoomCounter_ignore" + ) +end diff --git a/src/playercards/cards/ProtectiveIncantation1.ttslua b/src/playercards/cards/ProtectiveIncantation1.ttslua index 11dab875..c090fb6e 100644 --- a/src/playercards/cards/ProtectiveIncantation1.ttslua +++ b/src/playercards/cards/ProtectiveIncantation1.ttslua @@ -1,7 +1,7 @@ VALID_TOKENS = {} INVALID_TOKENS = { - ["Auto-fail"] = true + ["Auto-fail"] = true } UPDATE_ON_HOVER = true diff --git a/xml/playercards/ElleRubash2.xml b/xml/playercards/ElleRubash2.xml new file mode 100644 index 00000000..cfe64c71 --- /dev/null +++ b/xml/playercards/ElleRubash2.xml @@ -0,0 +1,14 @@ +