Merge pull request #840 from argonui/bless-curse
Added anti-spam handling to Bless/Curse Manager
This commit is contained in:
commit
8d732e7162
@ -9,6 +9,8 @@ buttonParamaters.width = 700
|
|||||||
buttonParamaters.height = 700
|
buttonParamaters.height = 700
|
||||||
|
|
||||||
local updating
|
local updating
|
||||||
|
local waitIds = {}
|
||||||
|
local currentCount = {}
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- creating buttons and menus + initializing tables
|
-- creating buttons and menus + initializing tables
|
||||||
@ -162,8 +164,11 @@ function doRemove(color)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
broadcastToColor("Removed " .. count.Bless .. " Bless and " .. count.Curse .. " Curse tokens from the chaos bag.", color, "White")
|
broadcastToColor("Removed " .. count.Bless .. " Bless and " .. count.Curse .. " Curse tokens from the chaos bag.",
|
||||||
broadcastToColor("Removed " .. removeTakenTokens("Bless") .. " Bless and " .. removeTakenTokens("Curse") .. " Curse tokens from play.", color, "White")
|
color, "White")
|
||||||
|
broadcastToColor(
|
||||||
|
"Removed " .. removeTakenTokens("Bless") .. " Bless and " .. removeTakenTokens("Curse") .. " Curse tokens from play.",
|
||||||
|
color, "White")
|
||||||
|
|
||||||
resetTables()
|
resetTables()
|
||||||
updateButtonLabels()
|
updateButtonLabels()
|
||||||
@ -286,8 +291,8 @@ function addToken(type)
|
|||||||
printToColor("10 tokens already in play, not adding any.", playerColor)
|
printToColor("10 tokens already in play, not adding any.", playerColor)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
printCountWithDelay(type)
|
||||||
numInPlay[type] = numInPlay[type] + 1
|
numInPlay[type] = numInPlay[type] + 1
|
||||||
printToAll("Adding " .. type .. " token " .. formatTokenCount(type))
|
|
||||||
updateButtonLabels()
|
updateButtonLabels()
|
||||||
return chaosBagApi.spawnChaosToken(type)
|
return chaosBagApi.spawnChaosToken(type)
|
||||||
end
|
end
|
||||||
@ -307,12 +312,13 @@ function removeToken(type)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
printCountWithDelay(type)
|
||||||
|
|
||||||
chaosBag.takeObject({
|
chaosBag.takeObject({
|
||||||
guid = table.remove(tokens),
|
guid = table.remove(tokens),
|
||||||
smooth = false,
|
smooth = false,
|
||||||
callback_function = function(obj)
|
callback_function = function(obj)
|
||||||
numInPlay[type] = numInPlay[type] - 1
|
numInPlay[type] = numInPlay[type] - 1
|
||||||
printToAll("Removing " .. type .. " token " .. formatTokenCount(type))
|
|
||||||
updateButtonLabels()
|
updateButtonLabels()
|
||||||
obj.destruct()
|
obj.destruct()
|
||||||
tokenArrangerApi.layout()
|
tokenArrangerApi.layout()
|
||||||
@ -333,6 +339,31 @@ function removeTakenTokens(type)
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- prints the changes to the chaos bag after 1s delay, bundles them into a single message
|
||||||
|
function printCountWithDelay(type)
|
||||||
|
if waitIds[type] then
|
||||||
|
Wait.stop(waitIds[type])
|
||||||
|
else
|
||||||
|
currentCount[type] = numInPlay[type]
|
||||||
|
end
|
||||||
|
|
||||||
|
waitIds[type] = Wait.time(function()
|
||||||
|
local diff = numInPlay[type] - currentCount[type]
|
||||||
|
local tokenString = " tokens "
|
||||||
|
if diff == 1 then
|
||||||
|
tokenString = " token "
|
||||||
|
end
|
||||||
|
|
||||||
|
if diff > 0 then
|
||||||
|
printToAll("Added " .. math.abs(diff) .. " " .. type .. tokenString .. formatTokenCount(type))
|
||||||
|
elseif diff < 0 then
|
||||||
|
printToAll("Removed " .. math.abs(diff) .. " " .. type .. tokenString .. formatTokenCount(type))
|
||||||
|
end
|
||||||
|
waitIds[type] = nil
|
||||||
|
currentCount[type] = nil
|
||||||
|
end, 1)
|
||||||
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- Wendy's Menu (context menu for cards on hotkey press)
|
-- Wendy's Menu (context menu for cards on hotkey press)
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user