From be1d4475d1a27f30f90da0cecf0eff5fbb0ab401 Mon Sep 17 00:00:00 2001 From: Sumsebrum Date: Fri, 29 Jul 2022 07:44:40 +0200 Subject: [PATCH] detect spec minor fix + add deathknight to spec detection --- EventListener.lua | 32 ++++++++++++-------------------- Util.lua | 11 ++++++++++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/EventListener.lua b/EventListener.lua index 820f181..9a2692d 100644 --- a/EventListener.lua +++ b/EventListener.lua @@ -134,8 +134,9 @@ function EventListener:COMBAT_LOG_EVENT_UNFILTERED() if not Gladdy.buttons[srcUnit].spec then self:DetectSpec(srcUnit, Gladdy.specSpells[spellName]) end - if (eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED") then + if (eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED" or eventType == "SPELL_MISSED") then local unitRace = Gladdy.buttons[srcUnit].race + self:DetectSpec(srcUnit, Gladdy.specSpells[spellName]) -- cooldown tracker if Gladdy.db.cooldown and Cooldowns.cooldownSpellIds[spellName] then local unitClass @@ -149,7 +150,6 @@ function EventListener:COMBAT_LOG_EVENT_UNFILTERED() else unitClass = Gladdy.buttons[srcUnit].race end - self:DetectSpec(srcUnit, Gladdy.specSpells[spellName]) if spellID ~= 16188 and spellID ~= 17116 then -- Nature's Swiftness CD starts when buff fades Cooldowns:CooldownUsed(srcUnit, unitClass, spellId) end @@ -314,29 +314,21 @@ function EventListener:UNIT_SPELLCAST_SUCCEEDED(unit) end end -local function notIn(spec, list) - for _,v in ipairs(list) do - if spec == v then - return false - end - end - return true -end - function EventListener:DetectSpec(unit, spec) local button = Gladdy.buttons[unit] if (not button or not spec or button.spec) then return end - if button.class == "PALADIN" and notIn(spec, {L["Holy"], L["Retribution"], L["Protection"]}) - or button.class == "SHAMAN" and notIn(spec, {L["Restoration"], L["Enhancement"], L["Elemental"]}) - or button.class == "ROGUE" and notIn(spec, {L["Subtlety"], L["Assassination"], L["Combat"]}) - or button.class == "WARLOCK" and notIn(spec, {L["Demonology"], L["Destruction"], L["Affliction"]}) - or button.class == "PRIEST" and notIn(spec, {L["Shadow"], L["Discipline"], L["Holy"]}) - or button.class == "MAGE" and notIn(spec, {L["Frost"], L["Fire"], L["Arcane"]}) - or button.class == "DRUID" and notIn(spec, {L["Restoration"], L["Feral"], L["Balance"]}) - or button.class == "HUNTER" and notIn(spec, {L["Beast Mastery"], L["Marksmanship"], L["Survival"]}) - or button.class == "WARRIOR" and notIn(spec, {L["Arms"], L["Protection"], L["Fury"]}) then + if button.class == "PALADIN" and Gladdy:contains(spec, {L["Holy"], L["Retribution"], L["Protection"]}) + or button.class == "SHAMAN" and not Gladdy:contains(spec, {L["Restoration"], L["Enhancement"], L["Elemental"]}) + or button.class == "ROGUE" and not Gladdy:contains(spec, {L["Subtlety"], L["Assassination"], L["Combat"]}) + or button.class == "WARLOCK" and not Gladdy:contains(spec, {L["Demonology"], L["Destruction"], L["Affliction"]}) + or button.class == "PRIEST" and not Gladdy:contains(spec, {L["Shadow"], L["Discipline"], L["Holy"]}) + or button.class == "MAGE" and not Gladdy:contains(spec, {L["Frost"], L["Fire"], L["Arcane"]}) + or button.class == "DRUID" and not Gladdy:contains(spec, {L["Restoration"], L["Feral"], L["Balance"]}) + or button.class == "HUNTER" and not Gladdy:contains(spec, {L["Beast Mastery"], L["Marksmanship"], L["Survival"]}) + or button.class == "WARRIOR" and not Gladdy:contains(spec, {L["Arms"], L["Protection"], L["Fury"]}) + or button.class == "DEATHKNIGHT" and not Gladdy:contains(spec, {L["Unholy"], L["Blood"], L["Frost"]}) then return end if not button.spec then diff --git a/Util.lua b/Util.lua index 947a877..204ab05 100644 --- a/Util.lua +++ b/Util.lua @@ -141,4 +141,13 @@ function Gladdy:GetTagOption(name, order, enabledOption, func, toggle) "Can be combined with OR operator like |cff1ac742[percent|status]|r. The last valid option will be used.\n"], }) end -end \ No newline at end of file +end + +function Gladdy:contains(entry, list) + for _,v in pairs(list) do + if entry == v then + return true + end + end + return false +end