|
|
@ -5,15 +5,9 @@ local Tinkr, Bastion = ... |
|
|
|
local AuraTable = {} |
|
|
|
local AuraTable = {} |
|
|
|
AuraTable.__index = AuraTable |
|
|
|
AuraTable.__index = AuraTable |
|
|
|
|
|
|
|
|
|
|
|
local function tsize(t) |
|
|
|
|
|
|
|
local keys = {} |
|
|
|
|
|
|
|
for k, v in pairs(t) do |
|
|
|
|
|
|
|
table.insert(keys, k) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
return keys[#keys] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Constructor |
|
|
|
-- Constructor |
|
|
|
|
|
|
|
---@param unit Unit |
|
|
|
|
|
|
|
---@return AuraTable |
|
|
|
function AuraTable:New(unit) |
|
|
|
function AuraTable:New(unit) |
|
|
|
local self = setmetatable({}, AuraTable) |
|
|
|
local self = setmetatable({}, AuraTable) |
|
|
|
|
|
|
|
|
|
|
@ -28,6 +22,8 @@ function AuraTable:New(unit) |
|
|
|
return self |
|
|
|
return self |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param auras UnitAuraUpdateInfo |
|
|
|
|
|
|
|
---@return nil |
|
|
|
function AuraTable:OnUpdate(auras) |
|
|
|
function AuraTable:OnUpdate(auras) |
|
|
|
if not auras then |
|
|
|
if not auras then |
|
|
|
self:Update() |
|
|
|
self:Update() |
|
|
@ -73,6 +69,8 @@ function AuraTable:OnUpdate(auras) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param instanceID number |
|
|
|
|
|
|
|
---@return nil |
|
|
|
function AuraTable:RemoveInstanceID(instanceID) |
|
|
|
function AuraTable:RemoveInstanceID(instanceID) |
|
|
|
if not self.instanceIDLookup[instanceID] then |
|
|
|
if not self.instanceIDLookup[instanceID] then |
|
|
|
return |
|
|
|
return |
|
|
@ -93,6 +91,10 @@ function AuraTable:RemoveInstanceID(instanceID) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Update the aura table |
|
|
|
|
|
|
|
---@param instanceID number |
|
|
|
|
|
|
|
---@param aura Aura |
|
|
|
|
|
|
|
---@return nil |
|
|
|
function AuraTable:AddOrUpdateAuraInstanceID(instanceID, aura) |
|
|
|
function AuraTable:AddOrUpdateAuraInstanceID(instanceID, aura) |
|
|
|
local spellId = aura:GetSpell():GetID() |
|
|
|
local spellId = aura:GetSpell():GetID() |
|
|
|
|
|
|
|
|
|
|
@ -114,6 +116,7 @@ function AuraTable:AddOrUpdateAuraInstanceID(instanceID, aura) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get a units buffs |
|
|
|
-- Get a units buffs |
|
|
|
|
|
|
|
---@return nil |
|
|
|
function AuraTable:GetUnitBuffs() |
|
|
|
function AuraTable:GetUnitBuffs() |
|
|
|
if Tinkr.classic then |
|
|
|
if Tinkr.classic then |
|
|
|
for i = 1, 40 do |
|
|
|
for i = 1, 40 do |
|
|
@ -152,6 +155,7 @@ function AuraTable:GetUnitBuffs() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get a units debuffs |
|
|
|
-- Get a units debuffs |
|
|
|
|
|
|
|
---@return nil |
|
|
|
function AuraTable:GetUnitDebuffs() |
|
|
|
function AuraTable:GetUnitDebuffs() |
|
|
|
if Tinkr.classic then |
|
|
|
if Tinkr.classic then |
|
|
|
for i = 1, 40 do |
|
|
|
for i = 1, 40 do |
|
|
@ -190,6 +194,7 @@ function AuraTable:GetUnitDebuffs() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Update auras |
|
|
|
-- Update auras |
|
|
|
|
|
|
|
---@return nil |
|
|
|
function AuraTable:Update() |
|
|
|
function AuraTable:Update() |
|
|
|
-- print("Updating auras for " .. tostring(self.unit)) |
|
|
|
-- print("Updating auras for " .. tostring(self.unit)) |
|
|
|
self:Clear() |
|
|
|
self:Clear() |
|
|
@ -203,6 +208,7 @@ function AuraTable:Update() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get a units auras |
|
|
|
-- Get a units auras |
|
|
|
|
|
|
|
---@return table |
|
|
|
function AuraTable:GetUnitAuras() |
|
|
|
function AuraTable:GetUnitAuras() |
|
|
|
if not self.did then |
|
|
|
if not self.did then |
|
|
|
self.did = true |
|
|
|
self.did = true |
|
|
@ -226,6 +232,7 @@ function AuraTable:GetUnitAuras() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Get a units auras |
|
|
|
-- Get a units auras |
|
|
|
|
|
|
|
---@return table |
|
|
|
function AuraTable:GetMyUnitAuras() |
|
|
|
function AuraTable:GetMyUnitAuras() |
|
|
|
if not self.did then |
|
|
|
if not self.did then |
|
|
|
self.did = true |
|
|
|
self.did = true |
|
|
@ -249,6 +256,7 @@ function AuraTable:GetMyUnitAuras() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Clear the aura table |
|
|
|
-- Clear the aura table |
|
|
|
|
|
|
|
---@return nil |
|
|
|
function AuraTable:Clear() |
|
|
|
function AuraTable:Clear() |
|
|
|
self.auras = {} |
|
|
|
self.auras = {} |
|
|
|
self.playerAuras = {} |
|
|
|
self.playerAuras = {} |
|
|
@ -256,6 +264,7 @@ function AuraTable:Clear() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Check if the unit has a specific aura |
|
|
|
-- Check if the unit has a specific aura |
|
|
|
|
|
|
|
---@param spell Spell |
|
|
|
---@return Aura |
|
|
|
---@return Aura |
|
|
|
function AuraTable:Find(spell) |
|
|
|
function AuraTable:Find(spell) |
|
|
|
local auras = self:GetUnitAuras() |
|
|
|
local auras = self:GetUnitAuras() |
|
|
@ -281,6 +290,8 @@ function AuraTable:Find(spell) |
|
|
|
return Bastion.Aura:New() |
|
|
|
return Bastion.Aura:New() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Check if the unit has a specific aura |
|
|
|
|
|
|
|
---@param spell Spell |
|
|
|
---@return Aura |
|
|
|
---@return Aura |
|
|
|
function AuraTable:FindMy(spell) |
|
|
|
function AuraTable:FindMy(spell) |
|
|
|
local auras = self:GetMyUnitAuras() |
|
|
|
local auras = self:GetMyUnitAuras() |
|
|
@ -305,6 +316,10 @@ function AuraTable:FindMy(spell) |
|
|
|
return Bastion.Aura:New() |
|
|
|
return Bastion.Aura:New() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Check if the unit has a specific aura |
|
|
|
|
|
|
|
---@param spell Spell |
|
|
|
|
|
|
|
---@param source Unit |
|
|
|
|
|
|
|
---@return Aura |
|
|
|
function AuraTable:FindFrom(spell, source) |
|
|
|
function AuraTable:FindFrom(spell, source) |
|
|
|
local auras = self:GetUnitAuras() |
|
|
|
local auras = self:GetUnitAuras() |
|
|
|
local aurasub = auras[spell:GetID()] |
|
|
|
local aurasub = auras[spell:GetID()] |
|
|
@ -331,6 +346,8 @@ function AuraTable:FindFrom(spell, source) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Find the aura from the current unit |
|
|
|
-- Find the aura from the current unit |
|
|
|
|
|
|
|
---@param spell Spell |
|
|
|
|
|
|
|
---@return Aura |
|
|
|
function AuraTable:FindTheirs(spell) |
|
|
|
function AuraTable:FindTheirs(spell) |
|
|
|
local auras = self:GetUnitAuras() |
|
|
|
local auras = self:GetUnitAuras() |
|
|
|
local aurasub = auras[spell:GetID()] |
|
|
|
local aurasub = auras[spell:GetID()] |
|
|
@ -357,6 +374,7 @@ function AuraTable:FindTheirs(spell) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Find any |
|
|
|
-- Find any |
|
|
|
|
|
|
|
---@param spell Spell |
|
|
|
---@return Aura |
|
|
|
---@return Aura |
|
|
|
function AuraTable:FindAny(spell) |
|
|
|
function AuraTable:FindAny(spell) |
|
|
|
local a = self:Find(spell) |
|
|
|
local a = self:Find(spell) |
|
|
@ -368,6 +386,7 @@ function AuraTable:FindAny(spell) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Has any stealable aura |
|
|
|
-- Has any stealable aura |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function AuraTable:HasAnyStealableAura() |
|
|
|
function AuraTable:HasAnyStealableAura() |
|
|
|
for _, auras in pairs(self:GetUnitAuras()) do |
|
|
|
for _, auras in pairs(self:GetUnitAuras()) do |
|
|
|
for _, aura in pairs(auras) do |
|
|
|
for _, aura in pairs(auras) do |
|
|
@ -385,6 +404,8 @@ function AuraTable:HasAnyStealableAura() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Has any dispelable aura |
|
|
|
-- Has any dispelable aura |
|
|
|
|
|
|
|
---@param spell Spell |
|
|
|
|
|
|
|
---@return boolean |
|
|
|
function AuraTable:HasAnyDispelableAura(spell) |
|
|
|
function AuraTable:HasAnyDispelableAura(spell) |
|
|
|
for _, auras in pairs(self:GetUnitAuras()) do |
|
|
|
for _, auras in pairs(self:GetUnitAuras()) do |
|
|
|
for _, aura in pairs(auras) do |
|
|
|
for _, aura in pairs(auras) do |
|
|
|