From 1bfd025100fe604167b4920dd5dfb7b2c00e8a3c Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 21 Jun 2023 22:58:32 +0200 Subject: [PATCH] updated code --- src/core/token/TokenManager.ttslua | 16 +++++++++------- src/playermat/Playmat.ttslua | 4 +--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 6f0fe627..47afacc2 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -109,6 +109,7 @@ do -- stateIDs for the multi-stated resource tokens local stateTable = { + ["Resource"] = 1, ["Ammo"] = 2, ["Charge"] = 3, ["Secret"] = 4, @@ -151,13 +152,13 @@ do -- Spawns a set of tokens on the given card. ---@param card Object Card to spawn tokens on - ---@param tokenType String type of token to spawn, valid values are "damage", "horror", + ---@param tokenType String Type of token to spawn, valid values are "damage", "horror", -- "resource", "doom", or "clue" ---@param tokenCount Number How many tokens to spawn. For damage or horror this value will be set to the -- spawned state object rather than spawning multiple tokens ---@param shiftDown Number An offset for the z-value of this group of tokens - ---@param stateID Number Index of the state to load for this token - TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, stateID) + ---@param subType Number Subtype of token to spawn. This will only differ from the tokenName for resource tokens + TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType) local optionPanel = Global.getTable("optionPanel") if tokenType == "damage" or tokenType == "horror" then @@ -165,7 +166,7 @@ do elseif tokenType == "resource" and optionPanel["useResourceCounters"] then TokenManager.spawnResourceCounterToken(card, tokenCount) else - TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, stateID) + TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType) end end @@ -196,8 +197,8 @@ do -- Other types should use spawnCounterToken() ---@param tokenCount Number How many tokens to spawn ---@param shiftDown Number An offset for the z-value of this group of tokens - ---@param stateID Number Index of the state to load for this token - TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, stateID) + ---@param subType Number Subtype of token to spawn. This will only differ from the tokenName for resource tokens + TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType) if tokenCount < 1 or tokenCount > 12 then return end @@ -231,6 +232,7 @@ do -- this is used to load the correct state for additional resource tokens (e.g. "Ammo") local callback = nil + local stateID = stateTable[subType] if tokenType == "resource" and stateID ~= nil and stateID ~= 1 then callback = function(spawned) spawned.setState(stateID) end end @@ -354,7 +356,7 @@ do tokenCount = tokenCount + extraUses[type] end -- Shift each spawned group after the first down so they don't pile on each other - TokenManager.spawnTokenGroup(card, token, tokenCount, (i - 1) * 0.8, stateTable[type]) + TokenManager.spawnTokenGroup(card, token, tokenCount, (i - 1) * 0.8, type) end tokenSpawnTracker.markTokensSpawned(card.getGUID()) end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 4767077c..d5c7217f 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -592,9 +592,7 @@ function replenishTokens(card, count, replenish) -- get type of resource to spawn local metadata = JSON.decode(card.getGMNotes()) or {} local uses = metadata.uses or {} - local type = string.lower(uses[1].type) or "resource" - local stateID = stateTable[type] - tokenManager.spawnTokenGroup(card, "resource", newCount, _, stateID) + tokenManager.spawnTokenGroup(card, "resource", newCount, _, uses[1].type) end end