66 lines
2.2 KiB
Lua
66 lines
2.2 KiB
Lua
local ADDON_NAME = "HailMaryGuildTools"
|
|
local HMGT = LibStub("AceAddon-3.0"):GetAddon(ADDON_NAME)
|
|
if not HMGT then return end
|
|
|
|
HMGT.TrackerPlayerState = HMGT.TrackerPlayerState or {}
|
|
|
|
local internals = HMGT.TrackerInternals or {}
|
|
local IsSpellKnownLocally = internals.IsSpellKnownLocally
|
|
|
|
function HMGT:CollectOwnAvailableTrackerSpells(classToken, specIndex)
|
|
local class = classToken or select(2, UnitClass("player"))
|
|
local spec = tonumber(specIndex) or tonumber(GetSpecialization())
|
|
if not class or not spec or spec <= 0 then
|
|
return {}
|
|
end
|
|
if not HMGT_SpellData or type(HMGT_SpellData.GetSpellsForSpec) ~= "function" then
|
|
return {}
|
|
end
|
|
|
|
local knownSpells = {}
|
|
for _, datasetName in ipairs({ "Interrupts", "RaidCooldowns", "GroupCooldowns" }) do
|
|
local dataset = HMGT_SpellData[datasetName]
|
|
if type(dataset) == "table" then
|
|
local spells = HMGT_SpellData.GetSpellsForSpec(class, spec, dataset)
|
|
for _, entry in ipairs(spells) do
|
|
local sid = tonumber(entry.spellId)
|
|
if sid and sid > 0 and IsSpellKnownLocally and IsSpellKnownLocally(sid) then
|
|
knownSpells[sid] = true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
local ownName = self:NormalizePlayerName(UnitName("player"))
|
|
local ownCDs = ownName and self:GetPlayerCooldownMap(ownName, false)
|
|
if ownCDs then
|
|
for sid in pairs(ownCDs) do
|
|
sid = tonumber(sid)
|
|
if sid and sid > 0 then
|
|
knownSpells[sid] = true
|
|
end
|
|
end
|
|
end
|
|
return knownSpells
|
|
end
|
|
|
|
function HMGT:IsTrackedSpellKnownForPlayer(playerName, spellId)
|
|
local sid = tonumber(spellId)
|
|
if not sid or sid <= 0 then
|
|
return false
|
|
end
|
|
|
|
local normalizedName = self:NormalizePlayerName(playerName)
|
|
local ownName = self:NormalizePlayerName(UnitName("player"))
|
|
local pData = normalizedName and self.playerData[normalizedName]
|
|
if pData and type(pData.knownSpells) == "table" and pData.knownSpells[sid] == true then
|
|
return true
|
|
end
|
|
|
|
if normalizedName and ownName and normalizedName == ownName and IsSpellKnownLocally then
|
|
return IsSpellKnownLocally(sid)
|
|
end
|
|
|
|
return false
|
|
end
|