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,56 +272,57 @@ 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 for spellIdStr,value in pairs(Gladdy.db.auraListDefault) do
if value.enabled then if value.enabled then
enabledAuras = enabledAuras + 1 if value.track == AURA_TYPE_BUFF then
tinsert(enabledBuffs, {value = value, spellIdStr = spellIdStr})
else
tinsert(enabledDebuffs, {value = value, spellIdStr = spellIdStr})
end
end end
end end
if enabledAuras > 0 then if unit == "arena2" then
limit, i = rand(1, enabledAuras), 1 testauras = enabledBuffs
for spellIdStr,value in pairs(Gladdy.db.auraListDefault) do else
if i > limit then break end testauras = enabledDebuffs
if value.enabled then end
spellid = tonumber(spellIdStr)
spellName = select(1, GetSpellInfo(tonumber(spellIdStr))) if #testauras > 0 then
icon = select(3, GetSpellInfo(tonumber(spellIdStr))) limit = rand(1, #testauras)
if Gladdy.exceptionNames[spellid] then local v = testauras[rand(1, #testauras)]
spellName = Gladdy.exceptionNames[spellid] spellid = tonumber(v.spellIdStr)
end spellName = select(1, GetSpellInfo(tonumber(v.spellIdStr)))
self:AURA_GAIN(unit,value.track, spellid, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration) icon = select(3, GetSpellInfo(tonumber(v.spellIdStr)))
i = i + 1 if Gladdy.exceptionNames[spellid] then
spellName = Gladdy.exceptionNames[spellid]
end
if (unit == "arena2") then
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
local spellSchools = {} if (unit == "arena1" or unit == "arena3") then
for k,_ in pairs(Gladdy:GetSpellSchoolColors()) do local enabledInterrupts = {}
tinsert(spellSchools, k) local spellSchools = {}
end for k,_ in pairs(Gladdy:GetSpellSchoolColors()) do
enabledAuras = 0 tinsert(spellSchools, k)
for _, value in pairs(Gladdy.db.auraListInterrupts) do
if value.enabled then
enabledAuras = enabledAuras + 1
end 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)]
spellName = select(1, GetSpellInfo(spellid)) spellid = tonumber(enabledInterrupts[rand(1, #enabledInterrupts)])
Gladdy:Print(spellName, extraSpellSchool) spellName = select(1, GetSpellInfo(spellid))
self:SPELL_INTERRUPT(unit,spellid, spellName, "physical", spellid, spellName, extraSpellSchool) self:SPELL_INTERRUPT(unit,spellid, spellName, "physical", spellid, spellName, extraSpellSchool)
end
i = i + 1
end 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 end
limit[category].count = limit[category].count + 1 end
end for spellId,cat in pairs(DRData:GetSpells()) do
if limit[category].count <= limit[category].limit then if enabledCategories[cat] then
self:AuraFade(unit, spellID) tinsert(enabledCategories[enabledCategories[cat]].spellIDs, spellId)
end 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)