keep state for replenishing
This commit is contained in:
parent
04b40f0da1
commit
82fdeda11b
@ -231,7 +231,7 @@ do
|
||||
|
||||
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
|
||||
local callback = nil
|
||||
if tokenType == "resource" and stateID ~= nil then
|
||||
if tokenType == "resource" and stateID ~= nil and stateID ~= 1 then
|
||||
callback = function(spawned) spawned.setState(stateID) end
|
||||
end
|
||||
|
||||
|
@ -546,6 +546,16 @@ function replenishTokens(card, count, replenish)
|
||||
-- don't continue for cards on your deck (Norman) or in your discard pile
|
||||
if self.positionToLocal(cardPos).x < -1 then return end
|
||||
|
||||
-- resource token states
|
||||
local stateTable = {
|
||||
["resource"] = 1,
|
||||
["ammo"] = 2,
|
||||
["charge"] = 3,
|
||||
["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 })
|
||||
local clickableResourceCounter = nil
|
||||
@ -553,10 +563,13 @@ function replenishTokens(card, count, replenish)
|
||||
|
||||
for _, obj in ipairs(search) do
|
||||
local obj = obj.hit_object
|
||||
if obj.getCustomObject().image == "http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/" then
|
||||
local memo = obj.getMemo()
|
||||
|
||||
if (stateTable[memo] or 0) > 0 then
|
||||
resourceState = stateTable[memo]
|
||||
foundTokens = foundTokens + math.abs(obj.getQuantity())
|
||||
obj.destruct()
|
||||
elseif obj.getMemo() == "resourceCounter" then
|
||||
elseif memo == "resourceCounter" then
|
||||
foundTokens = obj.getVar("val")
|
||||
clickableResourceCounter = obj
|
||||
break
|
||||
@ -578,7 +591,7 @@ function replenishTokens(card, count, replenish)
|
||||
if clickableResourceCounter then
|
||||
clickableResourceCounter.call("updateVal", newCount)
|
||||
else
|
||||
tokenManager.spawnTokenGroup(card, "resource", newCount)
|
||||
tokenManager.spawnTokenGroup(card, "resource", newCount, _, resourceState)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user