optimize and randomize DR and Aura test mode

This commit is contained in:
Sumsebrum 2021-07-29 17:11:54 +02:00
parent 51cd2b7311
commit 8a17592842
2 changed files with 66 additions and 49 deletions

View File

@ -272,57 +272,58 @@ function Auras:Test(unit)
self:AURA_FADE(unit, AURA_TYPE_DEBUFF) self:AURA_FADE(unit, AURA_TYPE_DEBUFF)
--Auras --Auras
local enabledAuras = 0 local enabledDebuffs, enabledBuffs, testauras = {}, {}
for _,value in pairs(Gladdy.db.auraListDefault) do
if value.enabled then
enabledAuras = enabledAuras + 1
end
end
if enabledAuras > 0 then
limit, i = rand(1, enabledAuras), 1
for spellIdStr,value in pairs(Gladdy.db.auraListDefault) do for spellIdStr,value in pairs(Gladdy.db.auraListDefault) do
if i > limit then break end
if value.enabled then if value.enabled then
spellid = tonumber(spellIdStr) if value.track == AURA_TYPE_BUFF then
spellName = select(1, GetSpellInfo(tonumber(spellIdStr))) tinsert(enabledBuffs, {value = value, spellIdStr = spellIdStr})
icon = select(3, GetSpellInfo(tonumber(spellIdStr))) else
tinsert(enabledDebuffs, {value = value, spellIdStr = spellIdStr})
end
end
end
if unit == "arena2" then
testauras = enabledBuffs
else
testauras = enabledDebuffs
end
if #testauras > 0 then
limit = rand(1, #testauras)
local v = testauras[rand(1, #testauras)]
spellid = tonumber(v.spellIdStr)
spellName = select(1, GetSpellInfo(tonumber(v.spellIdStr)))
icon = select(3, GetSpellInfo(tonumber(v.spellIdStr)))
if Gladdy.exceptionNames[spellid] then if Gladdy.exceptionNames[spellid] then
spellName = Gladdy.exceptionNames[spellid] spellName = Gladdy.exceptionNames[spellid]
end end
self:AURA_GAIN(unit,value.track, spellid, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration) if (unit == "arena2") then
i = i + 1 if (v.value.track == AURA_TYPE_BUFF) then
self:AURA_GAIN(unit,v.value.track, spellid, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
end end
else
self:AURA_GAIN(unit,v.value.track, spellid, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
end end
end end
--Interrupts --Interrupts
if (unit == "arena1" or unit == "arena3") then
local enabledInterrupts = {}
local spellSchools = {} local spellSchools = {}
for k,_ in pairs(Gladdy:GetSpellSchoolColors()) do for k,_ in pairs(Gladdy:GetSpellSchoolColors()) do
tinsert(spellSchools, k) tinsert(spellSchools, k)
end end
enabledAuras = 0
for _, value in pairs(Gladdy.db.auraListInterrupts) do
if value.enabled then
enabledAuras = enabledAuras + 1
end
end
if enabledAuras > 0 then
limit, i = rand(1, enabledAuras), 1
local extraSpellSchool
for spellIdStr, value in pairs(Gladdy.db.auraListInterrupts) do for spellIdStr, value in pairs(Gladdy.db.auraListInterrupts) do
if i > limit then break end
if value.enabled then if value.enabled then
enabledAuras = enabledAuras + 1 tinsert(enabledInterrupts, spellIdStr)
end end
spellid = tonumber(spellIdStr) end
if (unit == "arena1" or unit == "arena2") then if #enabledInterrupts > 0 then
extraSpellSchool = spellSchools[rand(1, #spellSchools)] local extraSpellSchool = spellSchools[rand(1, #spellSchools)]
spellid = tonumber(enabledInterrupts[rand(1, #enabledInterrupts)])
spellName = select(1, GetSpellInfo(spellid)) spellName = select(1, GetSpellInfo(spellid))
Gladdy:Print(spellName, extraSpellSchool)
self:SPELL_INTERRUPT(unit,spellid, spellName, "physical", spellid, spellName, extraSpellSchool) self:SPELL_INTERRUPT(unit,spellid, spellName, "physical", spellid, spellName, extraSpellSchool)
end end
i = i + 1
end
end end
end end

View File

@ -257,17 +257,32 @@ end
function Diminishings:Test(unit) function Diminishings:Test(unit)
if Gladdy.db.drEnabled then if Gladdy.db.drEnabled then
local limit = {} local enabledCategories = {}
for spellID,category in pairs(DRData:GetSpells()) do for cat,val in pairs(Gladdy.db.drCategories) do
if Gladdy.db.drCategories[category].enabled then if (val.enabled) then
if not limit[category] then tinsert(enabledCategories, {cat = cat , spellIDs = {}})
limit[category] = { count = 1, limit = rand(1,3) } enabledCategories[cat] = #enabledCategories
else
limit[category].count = limit[category].count + 1
end end
if limit[category].count <= limit[category].limit then
self:AuraFade(unit, spellID)
end end
for spellId,cat in pairs(DRData:GetSpells()) do
if enabledCategories[cat] then
tinsert(enabledCategories[enabledCategories[cat]].spellIDs, spellId)
end
end
--shuffle
for i = #enabledCategories, 2, -1 do
local j = rand(i)
enabledCategories[i], enabledCategories[j] = enabledCategories[j], enabledCategories[i]
end
--execute test
local index, amount = 0,0
for i=1, (#enabledCategories < 4 and #enabledCategories) or 4 do
amount = rand(1,3)
index = rand(1, #enabledCategories[i].spellIDs)
for _=1, amount do
self:AuraFade(unit, enabledCategories[i].spellIDs[index])
end end
end end
end end
@ -294,6 +309,7 @@ function Diminishings:AuraFade(unit, spellID)
lastIcon.diminishing = 1.0 lastIcon.diminishing = 1.0
end end
end end
if not lastIcon then return end
lastIcon.dr = drCat lastIcon.dr = drCat
lastIcon.timeLeft = Gladdy.db.drDuration lastIcon.timeLeft = Gladdy.db.drDuration
lastIcon.diminishing = DRData:NextDR(lastIcon.diminishing) lastIcon.diminishing = DRData:NextDR(lastIcon.diminishing)