don't remove other tokens when there is a clickable counter
This commit is contained in:
parent
22877c7bb4
commit
3d3fb95137
@ -276,6 +276,12 @@ function removeOneUse(playerColor, hoveredObject)
|
||||
end
|
||||
end
|
||||
|
||||
-- error handling
|
||||
if not targetObject then
|
||||
broadcastToColor("No tokens found!", playerColor, "Yellow")
|
||||
return
|
||||
end
|
||||
|
||||
-- release sealed token if card has one and no uses
|
||||
if tokenChecker.isChaosToken(targetObject) and hoveredObject.hasTag("CardThatSeals") then
|
||||
local func = hoveredObject.getVar("releaseOneToken") -- check if function exists
|
||||
@ -285,12 +291,6 @@ function removeOneUse(playerColor, hoveredObject)
|
||||
end
|
||||
end
|
||||
|
||||
-- error handling
|
||||
if not targetObject then
|
||||
broadcastToColor("No tokens found!", playerColor, "Yellow")
|
||||
return
|
||||
end
|
||||
|
||||
-- handling for stacked tokens
|
||||
if targetObject.getQuantity() > 1 then
|
||||
targetObject = targetObject.takeObject()
|
||||
|
@ -495,15 +495,16 @@ do
|
||||
local clickableResourceCounter = nil
|
||||
local foundTokens = 0
|
||||
|
||||
local maybeDeleteThese = {}
|
||||
if useInfo.token == "clue" then
|
||||
for _, obj in ipairs(searchLib.onObject(card, "isClue")) do
|
||||
foundTokens = foundTokens + math.abs(obj.getQuantity())
|
||||
obj.destruct()
|
||||
table.insert(maybeDeleteThese, obj)
|
||||
end
|
||||
elseif useInfo.token == "doom" then
|
||||
for _, obj in ipairs(searchLib.onObject(card, "isDoom")) do
|
||||
foundTokens = foundTokens + math.abs(obj.getQuantity())
|
||||
obj.destruct()
|
||||
table.insert(maybeDeleteThese, obj)
|
||||
end
|
||||
else
|
||||
-- search for the token instead if there's no special resource state for it
|
||||
@ -516,7 +517,7 @@ do
|
||||
local memo = obj.getMemo()
|
||||
if searchType == memo then
|
||||
foundTokens = foundTokens + math.abs(obj.getQuantity())
|
||||
obj.destruct()
|
||||
table.insert(maybeDeleteThese, obj)
|
||||
elseif memo == "resourceCounter" then
|
||||
foundTokens = obj.getVar("val")
|
||||
clickableResourceCounter = obj
|
||||
@ -540,6 +541,12 @@ do
|
||||
if clickableResourceCounter then
|
||||
clickableResourceCounter.call("updateVal", newCount)
|
||||
else
|
||||
-- delete existing tokens
|
||||
for _, obj in ipairs(maybeDeleteThese) do
|
||||
obj.destruct()
|
||||
end
|
||||
|
||||
-- spawn new token group
|
||||
TokenManager.spawnTokenGroup(card, useInfo.token, newCount, _, useInfo.type)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user