use token type from metadata

This commit is contained in:
Chr1Z93 2023-06-19 10:08:16 +02:00
parent 82fdeda11b
commit 1b28fbdfdd

View File

@ -554,7 +554,6 @@ function replenishTokens(card, count, replenish)
["secret"] = 4,
["supply"] = 5
}
local resourceState = 1
-- get current amount of resource tokens on the card
local search = searchArea(cardPos, { 2.5, 0.5, 3.5 })
@ -566,7 +565,6 @@ function replenishTokens(card, count, replenish)
local memo = obj.getMemo()
if (stateTable[memo] or 0) > 0 then
resourceState = stateTable[memo]
foundTokens = foundTokens + math.abs(obj.getQuantity())
obj.destruct()
elseif memo == "resourceCounter" then
@ -591,7 +589,12 @@ function replenishTokens(card, count, replenish)
if clickableResourceCounter then
clickableResourceCounter.call("updateVal", newCount)
else
tokenManager.spawnTokenGroup(card, "resource", newCount, _, resourceState)
-- 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)
end
end