updated code
This commit is contained in:
parent
1b28fbdfdd
commit
1bfd025100
@ -109,6 +109,7 @@ do
|
|||||||
|
|
||||||
-- stateIDs for the multi-stated resource tokens
|
-- stateIDs for the multi-stated resource tokens
|
||||||
local stateTable = {
|
local stateTable = {
|
||||||
|
["Resource"] = 1,
|
||||||
["Ammo"] = 2,
|
["Ammo"] = 2,
|
||||||
["Charge"] = 3,
|
["Charge"] = 3,
|
||||||
["Secret"] = 4,
|
["Secret"] = 4,
|
||||||
@ -151,13 +152,13 @@ do
|
|||||||
|
|
||||||
-- Spawns a set of tokens on the given card.
|
-- Spawns a set of tokens on the given card.
|
||||||
---@param card Object Card to spawn tokens on
|
---@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"
|
-- "resource", "doom", or "clue"
|
||||||
---@param tokenCount Number How many tokens to spawn. For damage or horror this value will be set to the
|
---@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
|
-- spawned state object rather than spawning multiple tokens
|
||||||
---@param shiftDown Number An offset for the z-value of this group of 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
|
---@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, stateID)
|
TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)
|
||||||
local optionPanel = Global.getTable("optionPanel")
|
local optionPanel = Global.getTable("optionPanel")
|
||||||
|
|
||||||
if tokenType == "damage" or tokenType == "horror" then
|
if tokenType == "damage" or tokenType == "horror" then
|
||||||
@ -165,7 +166,7 @@ do
|
|||||||
elseif tokenType == "resource" and optionPanel["useResourceCounters"] then
|
elseif tokenType == "resource" and optionPanel["useResourceCounters"] then
|
||||||
TokenManager.spawnResourceCounterToken(card, tokenCount)
|
TokenManager.spawnResourceCounterToken(card, tokenCount)
|
||||||
else
|
else
|
||||||
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, stateID)
|
TokenManager.spawnMultipleTokens(card, tokenType, tokenCount, shiftDown, subType)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -196,8 +197,8 @@ do
|
|||||||
-- Other types should use spawnCounterToken()
|
-- Other types should use spawnCounterToken()
|
||||||
---@param tokenCount Number How many tokens to spawn
|
---@param tokenCount Number How many tokens to spawn
|
||||||
---@param shiftDown Number An offset for the z-value of this group of 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
|
---@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, stateID)
|
TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)
|
||||||
if tokenCount < 1 or tokenCount > 12 then
|
if tokenCount < 1 or tokenCount > 12 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -231,6 +232,7 @@ do
|
|||||||
|
|
||||||
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
|
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
|
||||||
local callback = nil
|
local callback = nil
|
||||||
|
local stateID = stateTable[subType]
|
||||||
if tokenType == "resource" and stateID ~= nil and stateID ~= 1 then
|
if tokenType == "resource" and stateID ~= nil and stateID ~= 1 then
|
||||||
callback = function(spawned) spawned.setState(stateID) end
|
callback = function(spawned) spawned.setState(stateID) end
|
||||||
end
|
end
|
||||||
@ -354,7 +356,7 @@ do
|
|||||||
tokenCount = tokenCount + extraUses[type]
|
tokenCount = tokenCount + extraUses[type]
|
||||||
end
|
end
|
||||||
-- Shift each spawned group after the first down so they don't pile on each other
|
-- 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
|
end
|
||||||
tokenSpawnTracker.markTokensSpawned(card.getGUID())
|
tokenSpawnTracker.markTokensSpawned(card.getGUID())
|
||||||
end
|
end
|
||||||
|
@ -592,9 +592,7 @@ function replenishTokens(card, count, replenish)
|
|||||||
-- get type of resource to spawn
|
-- get type of resource to spawn
|
||||||
local metadata = JSON.decode(card.getGMNotes()) or {}
|
local metadata = JSON.decode(card.getGMNotes()) or {}
|
||||||
local uses = metadata.uses or {}
|
local uses = metadata.uses or {}
|
||||||
local type = string.lower(uses[1].type) or "resource"
|
tokenManager.spawnTokenGroup(card, "resource", newCount, _, uses[1].type)
|
||||||
local stateID = stateTable[type]
|
|
||||||
tokenManager.spawnTokenGroup(card, "resource", newCount, _, stateID)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user