doom counter update
This commit is contained in:
parent
b1cff2fc28
commit
2d85f913b1
@ -27,32 +27,54 @@ end
|
|||||||
|
|
||||||
-- main function
|
-- main function
|
||||||
function countDoom()
|
function countDoom()
|
||||||
local doom = 0
|
local objList = {}
|
||||||
for i = 1, 4 do
|
|
||||||
doom = doom + countDoomFromList(playmatApi.searchAroundPlaymat(COLORS[i]))
|
-- get doom objects in play area zone
|
||||||
|
for _, obj in ipairs(ZONE.getObjects()) do
|
||||||
|
if filterDoom(obj) then
|
||||||
|
table.insert(objList, obj)
|
||||||
end
|
end
|
||||||
doom = doom + countDoomFromList(ZONE.getObjects())
|
end
|
||||||
|
|
||||||
|
-- get doom objects on playmats
|
||||||
|
for i = 1, 4 do
|
||||||
|
local playmatList = playmatApi.searchAroundPlaymat(COLORS[i])
|
||||||
|
for _, obj in ipairs(playmatList) do
|
||||||
|
if filterDoom(obj) then
|
||||||
|
table.insert(objList, obj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local doom = countDoomFromList(objList)
|
||||||
self.editButton({ index = 0, label = tostring(doom) })
|
self.editButton({ index = 0, label = tostring(doom) })
|
||||||
end
|
end
|
||||||
|
|
||||||
function countDoomFromList(objList)
|
function countDoomFromList(objList)
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, obj in ipairs(objList) do
|
for _, obj in ipairs(objList) do
|
||||||
count = count + isDoom(obj)
|
count = count + getDoomAmount(obj)
|
||||||
end
|
end
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
-- checks an object for the doom image and gets quantity (for stacks)
|
function filterDoom(obj)
|
||||||
function isDoom(obj)
|
if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL)
|
||||||
if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL) or
|
or (obj.name == "Custom_Token" and obj.getCustomObject().image == doomURL) then
|
||||||
(obj.name == "Custom_Token" and obj.getCustomObject().image == doomURL) then
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- gets quantity (for stacks) of doom
|
||||||
|
function getDoomAmount(obj)
|
||||||
if not obj.hasTag(IGNORE_TAG) then
|
if not obj.hasTag(IGNORE_TAG) then
|
||||||
return math.abs(obj.getQuantity())
|
return math.abs(obj.getQuantity())
|
||||||
end
|
else
|
||||||
end
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- removes doom from playermats / playarea
|
-- removes doom from playermats / playarea
|
||||||
function removeDoom(options)
|
function removeDoom(options)
|
||||||
@ -75,7 +97,7 @@ end
|
|||||||
function removeDoomFromList(objList)
|
function removeDoomFromList(objList)
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, obj in ipairs(objList) do
|
for _, obj in ipairs(objList) do
|
||||||
local amount = isDoom(obj)
|
local amount = getDoomAmount(obj)
|
||||||
if amount > 0 then
|
if amount > 0 then
|
||||||
TRASH.putObject(obj)
|
TRASH.putObject(obj)
|
||||||
count = count + amount
|
count = count + amount
|
||||||
|
Loading…
Reference in New Issue
Block a user