LibOpenRaid Update

This commit is contained in:
Tercio Jose
2022-09-07 22:07:50 -03:00
parent 0306cda9c3
commit 842e86404b
6 changed files with 89 additions and 5 deletions
+42 -3
View File
@@ -147,7 +147,7 @@ local filterStringToCooldownType = {
["interrupt"] = CONST_COOLDOWN_TYPE_INTERRUPT,
}
function openRaidLib.CooldownManager.DoesSpellPassFilter(spellId, filters)
function openRaidLib.CooldownManager.DoesSpellPassFilters(spellId, filters)
local allCooldownsData = LIB_OPEN_RAID_COOLDOWNS_INFO
local cooldownData = allCooldownsData[spellId]
if (cooldownData) then
@@ -155,6 +155,8 @@ function openRaidLib.CooldownManager.DoesSpellPassFilter(spellId, filters)
local cooldownType = filterStringToCooldownType[filter]
if (cooldownData.type == cooldownType) then
return true
elseif (cooldownData[filter]) then --custom filter
return true
end
end
else
@@ -175,14 +177,51 @@ local getCooldownsForFilter = function(unitName, allCooldowns, unitDataFilteredC
for spellId, cooldownInfo in pairs(allCooldowns) do
local cooldownData = allCooldownsData[spellId]
if (cooldownData and cooldownData.type == filterStringToCooldownType[filter]) then
filterTable[spellId] = cooldownInfo
if (cooldownData) then
if (cooldownData.type == filterStringToCooldownType[filter]) then
filterTable[spellId] = cooldownInfo
elseif (cooldownData[filter]) then --custom filter
filterTable[spellId] = cooldownInfo
end
end
end
end
return filterTable
end
function openRaidLib.AddCooldownFilter(filterName, spells)
--integrity check
if (type(filterName) ~= "string") then
openRaidLib.DiagnosticError("Usage: openRaidLib.AddFilter(string: filterName, table: spells)", debugstack())
return false
end
if (type(spells) ~= "table") then
openRaidLib.DiagnosticError("Usage: openRaidLib.AddFilter(string: filterName, table: spells)", debugstack())
return false
end
--clear previous filter spell table of the same name
for spellId, cooldownData in pairs(LIB_OPEN_RAID_COOLDOWNS_INFO) do
cooldownData[filterName] = nil
end
local allCooldownsData = LIB_OPEN_RAID_COOLDOWNS_INFO
for spellIndex, spellId in ipairs(spells) do
local cooldownData = allCooldownsData[spellId]
cooldownData[filterName] = true
end
--tag all cache filters as dirt
local allUnitsCooldowns = openRaidLib.GetAllUnitsCooldown()
for unitName in pairs(allUnitsCooldowns) do
openRaidLib.CooldownManager.NeedRebuildFilters[unitName] = true
end
return true
end
--@allCooldowns: all cooldowns sent by an unit, {[spellId] = cooldownInfo}
--@filters: string with filters, "defensive-raid, "defensive-personal"
function openRaidLib.FilterCooldowns(unitName, allCooldowns, filters)