diff --git a/config.json b/config.json index 4209991e..993dbc4a 100644 --- a/config.json +++ b/config.json @@ -225,7 +225,6 @@ "Tokencache_Curse.16a9a7", "Tokencache_Frost.b2b7be", "PhysicsDetector.b300d8", - "Universal.834ad5", "ArkhamSCE380-5122024-Page1.bd6b3e" ], "PlayArea": 1, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index 0e5b1d78..df236edd 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -12,7 +12,7 @@ "z": 0.118 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -22,7 +22,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -32,7 +32,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -42,7 +42,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -52,7 +52,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { diff --git a/objects/Playermat2Orange.bd0ff4.json b/objects/Playermat2Orange.bd0ff4.json index 7e61a822..534057e6 100644 --- a/objects/Playermat2Orange.bd0ff4.json +++ b/objects/Playermat2Orange.bd0ff4.json @@ -12,7 +12,7 @@ "z": 0.118 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -22,7 +22,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -32,7 +32,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -42,7 +42,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -52,7 +52,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index 57698e72..45f4eeb1 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -12,7 +12,7 @@ "z": 0.118 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -22,7 +22,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -32,7 +32,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -42,7 +42,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -52,7 +52,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index edb3e19d..a256db3e 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -12,7 +12,7 @@ "z": 0.118 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -22,7 +22,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -32,7 +32,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -42,7 +42,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { @@ -52,7 +52,7 @@ "z": -0.28 }, "Tags": [ - "ActionToken" + "UniversalToken" ] }, { diff --git a/objects/TokenSource.124381.json b/objects/TokenSource.124381.json index 62f31d17..3554fef3 100644 --- a/objects/TokenSource.124381.json +++ b/objects/TokenSource.124381.json @@ -20,7 +20,7 @@ "Path.7234af", "Resource.910e09", "ResourceCounter.498ec0", - "Neutral.04765c" + "UniversalActionAbilityToken.834ad5" ], "ContainedObjects_path": "TokenSource.124381", "Description": "", diff --git a/objects/Universal.834ad5.json b/objects/TokenSource.124381/UniversalActionAbilityToken.834ad5.json similarity index 97% rename from objects/Universal.834ad5.json rename to objects/TokenSource.124381/UniversalActionAbilityToken.834ad5.json index 175ddd21..bacf7108 100644 --- a/objects/Universal.834ad5.json +++ b/objects/TokenSource.124381/UniversalActionAbilityToken.834ad5.json @@ -163,10 +163,14 @@ "LuaScript": "require(\"core/UniversalActionAbilityToken\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "universalActionAbility", "Name": "Custom_Tile", - "Nickname": "Universal", + "Nickname": "Universal Action Ability Token", "Snap": true, "Sticky": true, + "Tags": [ + "UniversalToken" + ], "Tooltip": true, "Transform": { "posX": -50.981, diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 24a796c4..22c055e8 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -1387,7 +1387,7 @@ function removePlayermat(matColor) if not matObjects.Playermat then return end -- remove action tokens - local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken") + local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isUniversalToken") for _, obj in ipairs(actionTokens) do obj.destruct() end diff --git a/src/core/UniversalActionAbilityToken.ttslua b/src/core/UniversalActionAbilityToken.ttslua index a0912a1a..ca87322d 100644 --- a/src/core/UniversalActionAbilityToken.ttslua +++ b/src/core/UniversalActionAbilityToken.ttslua @@ -98,6 +98,8 @@ function updateDisplay() tag = "Image", attributes = { image = "Border", + -- update color on the back for neutral + color = (class == "Neutral") and "#000000" or "#FFFFFF", height = "200", width = "200", position = "0 0 -10.2", @@ -110,7 +112,7 @@ function updateDisplay() attributes = { id = "SymbolBack", image = symbol, - -- update color of symbol on the back for neutral + -- update color on the back for neutral color = (class == "Neutral") and "#000000" or "#FFFFFF", height = "200", width = "200", @@ -127,6 +129,13 @@ function updateDisplay() else self.setName(class .. " " .. symbol) end + + -- update scale + if symbol == "FreeTrigger" or symbol == "Reaction" then + self.setScale({0.35, 1, 0.35}) + else + self.setScale({0.45, 1, 0.45}) + end end function addContextMenu() @@ -140,18 +149,18 @@ function addContextMenu() end function updateClass(newClass) - class = newClass + class = newClass or "Neutral" updateDisplay() end function updateSymbol(newSymbol) - symbol = newSymbol + symbol = newSymbol or class updateDisplay() end -function updateClassAndSymbol(newClass, newSymbol) - class = newClass - symbol = newSymbol +function updateClassAndSymbol(params) + class = params.class or "Neutral" + symbol = params.symbol or class updateDisplay() end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 0e603868..10bb80af 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -846,11 +846,13 @@ function maybeUpdateActiveInvestigator(card) if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end local notes = JSON.decode(card.getGMNotes()) - local class + local class = "Neutral" + local extraToken if notes ~= nil and notes.type == "Investigator" and notes.id ~= nil then if notes.id == activeInvestigatorId then return end class = notes.class + extraToken = notes.extraToken activeInvestigatorId = notes.id ownedObjects.InvestigatorSkillTracker.call("updateStats", { notes.willpowerIcons, @@ -866,46 +868,33 @@ function maybeUpdateActiveInvestigator(card) return end - -- change state of action tokens - local search = searchArea(self.positionToWorld({ -1.1, 0.05, -0.27 }), { 4, 1, 1 }) - local smallToken = nil - local STATE_TABLE = { - ["Guardian"] = 1, - ["Seeker"] = 2, - ["Rogue"] = 3, - ["Mystic"] = 4, - ["Survivor"] = 5, - ["Neutral"] = 6 - } - - for _, obj in ipairs(search) do - if obj.getDescription() == "Action Token" and obj.getStateId() > 0 then - if obj.getScale().x < 0.4 then - smallToken = obj - else - setObjectState(obj, STATE_TABLE[class]) - end - end + -- remove old action tokens + for _, obj in ipairs(searchAroundSelf("isUniversalToken")) do + obj.destruct() end - -- update the small token with special action for certain investigators - local SPECIAL_ACTIONS = { - ["04002"] = 8, -- Ursula Downs - ["01002"] = 9, -- Daisy Walker - ["01502"] = 9, -- Daisy Walker - ["01002-pb"] = 9, -- Daisy Walker - ["06003"] = 10, -- Tony Morgan - ["04003"] = 11, -- Finn Edwards - ["08016"] = 14 -- Bob Jenkins - } + -- spawn three regular action tokens (investigator specific one in the bottom spot) + for i = 1, 3 do + -- get position + local pos = self.positionToWorld(Vector(-1.54 + i * 0.18, 0, -0.28)):setAt("y", 0.1) - if smallToken ~= nil then - setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class]) + tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned) + spawned.call("updateClassAndSymbol", { class = class, symbol = class }) + end) end -end -function setObjectState(obj, stateId) - if obj.getStateId() ~= stateId then obj.setState(stateId) end + -- spawn additional token (maybe specific for investigator) + if extraToken ~= "None" then + -- set value to class if currently "nil" + extraToken = extraToken or class + + -- get position + local pos = self.positionToWorld(Vector(-1, 0, 0.118)):setAt("y", 0.1) + + tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned) + spawned.call("updateClassAndSymbol", { class = class, symbol = extraToken }) + end) + end end --------------------------------------------------------- diff --git a/src/util/SearchLib.ttslua b/src/util/SearchLib.ttslua index fbf19661..0cb1369f 100644 --- a/src/util/SearchLib.ttslua +++ b/src/util/SearchLib.ttslua @@ -1,12 +1,12 @@ do local SearchLib = {} local filterFunctions = { - isActionToken = function(x) return x.getDescription() == "Action Token" end, isCard = function(x) return x.type == "Card" end, isDeck = function(x) return x.type == "Deck" end, isCardOrDeck = function(x) return x.type == "Card" or x.type == "Deck" end, isClue = function(x) return x.memo == "clueDoom" and x.is_face_down == false end, - isTileOrToken = function(x) return x.type == "Tile" end + isTileOrToken = function(x) return x.type == "Tile" end, + isUniversalToken = function(x) return x.getMemo() == "universalActionAbility" end, } -- performs the actual search and returns a filtered list of object references diff --git a/src/util/TokenSpawnTool.ttslua b/src/util/TokenSpawnTool.ttslua index 13ef3842..b01a2283 100644 --- a/src/util/TokenSpawnTool.ttslua +++ b/src/util/TokenSpawnTool.ttslua @@ -3,7 +3,7 @@ local searchLib = require("util/SearchLib") local tokenManager = require("core/token/TokenManager") local TOKEN_INDEX = {} -TOKEN_INDEX[1] = "actionToken" +TOKEN_INDEX[1] = "universalActionAbility" TOKEN_INDEX[3] = "resourceCounter" TOKEN_INDEX[4] = "damage" TOKEN_INDEX[5] = "path" @@ -23,15 +23,6 @@ local stateTable = { ["offering"] = 8 } -local actionStateTable = { - ["Guardian"] = 1, - ["Seeker"] = 2, - ["Rogue"] = 3, - ["Mystic"] = 4, - ["Survivor"] = 5, - ["Neutral"] = 6 -} - ---@param index number Index of the pressed key ---@param playerColor string Color of the triggering player function onScriptingButtonDown(index, playerColor) @@ -58,7 +49,7 @@ function onScriptingButtonDown(index, playerColor) break end end - + -- this is used to load the correct state for additional resource tokens (e.g. "Ammo") local stateID = stateTable[string.lower(subType)] if stateID ~= nil and stateID ~= 1 then @@ -87,20 +78,20 @@ function onScriptingButtonDown(index, playerColor) end end -- check for nearest investigator card and change action token state to its class - elseif tokenType == "actionToken" then + elseif tokenType == "universalActionAbility" then local matColor = playmatApi.getMatColorByPosition(position) local result = playmatApi.searchAroundPlaymat(matColor, "isCard") - local investigatorClass = "Neutral" + local class = "Neutral" for j, card in ipairs(result) do local metadata = JSON.decode(card.getGMNotes()) or {} if metadata.type == "Investigator" then - investigatorClass = metadata.class + class = metadata.class + break end end - local stateID = actionStateTable[investigatorClass] - if stateID ~= nil and stateID ~= 6 then - callback = function(spawned) spawned.setState(stateID) end + callback = function(spawned) + spawned.call("updateClassAndSymbol", { class = class, symbol = class }) end end