Skip to content

Commit

Permalink
refactor: handle additional deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Jun 20, 2024
1 parent 305fa8a commit 747f6a6
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 200 deletions.
64 changes: 28 additions & 36 deletions Components/Core/Conditions/Categories/BuffsDebuffs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ local strlowerCache = TMW.strlowerCache
local huge = math.huge
local empty = {}

local UnitAura = UnitAura
local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex
local GetAuras = TMW.COMMON.Auras.GetAuras

function Env.AuraStacks(unit, name, filter)
for i = 1, huge do
local buffName, _, count, _, _, _, _, _, _, id = UnitAura(unit, i, filter)
local data = GetAuraDataByIndex(unit, i, filter)

if not buffName then
if not data then
return 0
elseif id == name or strlowerCache[buffName] == name then
if count == 0 then
elseif data.spellId == name or strlowerCache[data.name] == name then
if data.applications == 0 then
return 1
else
return count
return data.applications
end
end
end
Expand Down Expand Up @@ -66,10 +66,10 @@ function Env.AuraCount(units, spells, filter)

for u = 1, #units do
for i = 1, huge do
local buffName, _, _, _, _, _, _, _, _, id = UnitAura(units[u], i, filter)
if not buffName then
local data = GetAuraDataByIndex(units[u], i, filter)
if not data then
break
elseif names[id] or names[strlowerCache[buffName]] then
elseif names[data.spellId] or names[strlowerCache[data.name]] then
n = n + 1
end
end
Expand Down Expand Up @@ -100,18 +100,18 @@ function Env.AuraCountPacked(units, spells, kindKey, onlyMine)
end

function Env.AuraDur(unit, name, filter)
local buffName, _, duration, expirationTime, id
local data
for i = 1, huge do
buffName, _, _, _, duration, expirationTime, _, _, _, id = UnitAura(unit, i, filter)
if not id or id == name or strlowerCache[buffName] == name then
data = GetAuraDataByIndex(unit, i, filter)
if not data or data.spellId == name or strlowerCache[data.name] == name then
break
end
end

if not buffName then
if not data then
return 0, 0, 0
else
return expirationTime == 0 and huge or expirationTime - TMW.time, duration, expirationTime
return data.expirationTime == 0 and huge or data.expirationTime - TMW.time, data.duration, data.expirationTime
end
end

Expand All @@ -132,20 +132,18 @@ function Env.AuraDurPacked(unit, name, kindKey, onlyMine)
end

function Env.AuraPercent(unit, name, filter)
local isID = isNumber[name]

local buffName, duration, expirationTime, id, _
local data
for i = 1, huge do
buffName, _, _, _, duration, expirationTime, _, _, _, id = UnitAura(unit, i, filter)
if not id or id == name or strlowerCache[buffName] == name then
data = GetAuraDataByIndex(unit, i, filter)
if not data or data.spellId == name or strlowerCache[data.name] == name then
break
end
end

if not buffName then
if not data then
return 0
else
return expirationTime == 0 and 1 or ((expirationTime - TMW.time) / duration)
return data.expirationTime == 0 and 1 or ((data.expirationTime - TMW.time) / data.duration)
end
end

Expand All @@ -166,23 +164,17 @@ function Env.AuraPercentPacked(unit, name, kindKey, onlyMine)
end

function Env.AuraVariableNumber(unit, name, filter)

local buffName, id, v1, v2, v3, v4, _
local data
for i = 1, huge do
buffName, _, _, _, _, _, _, _, _, id, _, _, _, _, _, v1, v2, v3, v4 = UnitAura(unit, i, filter)
if not id or id == name or strlowerCache[buffName] == name then
data = GetAuraDataByIndex(unit, i, filter)
if not data or data.spellId == name or strlowerCache[data.name] == name then
break
end
end

if v1 and v1 > 0 then
return v1
elseif v2 and v2 > 0 then
return v2
elseif v3 and v3 > 0 then
return v3
elseif v4 and v4 > 0 then
return v4
for i = 1, #data.points do
local v = data.points[i]
if v and v > 0 then return v end
end

return 0
Expand Down Expand Up @@ -255,10 +247,10 @@ function Env.AuraTooltipNumber(...)

local n
for i = 1, 60 do
local buffName, _, _, _, _, _, _, _, _, id = UnitAura(unit, i, filter)
if not buffName then
local data = GetAuraDataByIndex(unit, i, filter)
if not data then
break
elseif id == name or strlowerCache[buffName] == strlowerCache[name] then
elseif data.spellId == name or strlowerCache[data.name] == name then
n = i
break
end
Expand Down
21 changes: 13 additions & 8 deletions Components/Core/Conditions/Categories/Talents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ local GetSpecializationInfo, GetNumClasses =
GetSpecializationInfo, GetNumClasses
local GetNumBattlefieldScores, RequestBattlefieldScoreData, GetBattlefieldScore, GetNumArenaOpponents, GetArenaOpponentSpec =
GetNumBattlefieldScores, RequestBattlefieldScoreData, GetBattlefieldScore, GetNumArenaOpponents, GetArenaOpponentSpec
local UnitAura, IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID =
UnitAura, IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID
local IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID =
IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID

local GetSpellInfo = TMW.GetSpellInfo
local GetSpellName = TMW.GetSpellName
Expand Down Expand Up @@ -815,19 +815,24 @@ if IsInJailersTower then
self.watching = false
end
end

local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex
function AnimaPowWatcher:UNIT_AURA(_, unit)
if unit ~= "player" then return end

for i=1, 300 do
local name, _, count, _, _, _, _, _, _, spellID = UnitAura("player", i, "MAW");
if not spellID then return end
local data = GetAuraDataByIndex("player", i, "MAW");
if not data then return end

local spellId = data.spellId
local count = data.count
if count == 0 then
count = 1;
count = 1
end

if currentAnimaPows[spellID] ~= count then
currentAnimaPows[spellID] = count;
currentAnimaPows[strlowerCache[name]] = count;
if currentAnimaPows[data.spellId] ~= count then
currentAnimaPows[data.spellId] = count;
currentAnimaPows[strlowerCache[data.name]] = count;
TMW:Fire("TMW_ANIMA_POWER_COUNT_CHANGED")
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local print = TMW.print

local OnGCD = TMW.OnGCD

local IsAddOnLoaded = C_AddOns and C_AddOns.IsAddOnLoaded or IsAddOnLoaded
local pairs, wipe =
pairs, wipe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ local TMW = TMW
local L = TMW.L
local print = TMW.print

local GetAddOnInfo = C_AddOns and C_AddOns.GetAddOnInfo or GetAddOnInfo

local LMB = LibStub("Masque", true) or (LibMasque and LibMasque("Button"))


Expand Down
Loading

0 comments on commit 747f6a6

Please sign in to comment.