Skip to content

Commit

Permalink
Code Cleanup
Browse files Browse the repository at this point in the history
Just removed the dedicated moonkin and k'iru song of victory checks and created a generic reusable single buff check function.
  • Loading branch information
Softrix committed Sep 21, 2022
1 parent c93c951 commit 4be871c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion SmartBuff-Classic.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 11403
## Title: |TInterface\Addons\Smartbuff\Icons\IconEnabled:0|t SmartBuff |cffffffff(Classic Version)|r
## Version: 34.11403
## Version: 35.11403
## Author: |cff20d2ffCodermik (Mik / Castanova on EU-Mirage Raceway) & Aeldra|r (EU-Proudmoore)
## Notes: Cast the most important buffs on you or party, raid, pets and assigned tanks. Use /sbm for options menu.
## DefaultState: Enabled
Expand Down
2 changes: 1 addition & 1 deletion SmartBuff-TBC.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 20504
## Title: |TInterface\Addons\Smartbuff\Icons\IconEnabled:0|t SmartBuff |cffffffff(TBC Classic)|r
## Version: 34.20504
## Version: 35.20504
## Author: |cff20d2ffCodermik (Mik / Castanova on EU-Mirage Raceway) & Aeldra|r (EU-Proudmoore)
## Notes: Cast the most important buffs on you or party, raid, pets and assigned tanks. Use /sbm for options menu.
## DefaultState: Enabled
Expand Down
25 changes: 7 additions & 18 deletions SmartBuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
-- Cast the most important buffs on you, tanks or party/raid members/pets.
-------------------------------------------------------------------------------

SMARTBUFF_DATE = "190922";
SMARTBUFF_VERSION = "r34."..SMARTBUFF_DATE;
SMARTBUFF_DATE = "210922 Dev";
SMARTBUFF_VERSION = "r35."..SMARTBUFF_DATE;
SMARTBUFF_VERSIONMIN = 11403; -- min version
SMARTBUFF_VERSIONNR = 30400; -- max version
SMARTBUFF_TITLE = "SmartBuff";
Expand Down Expand Up @@ -264,11 +264,11 @@ local function ChkS(text)
return text;
end

-- check for moonkin buff
local function CheckMoonkinBuff()
-- check for a given buff.
local function CheckForBuff(buff)
for i=1,40 do
name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura("player",i);
if name == SMARTBUFF_DRUID_MOONKIN then
if name == buff then
return true;
end
end
Expand All @@ -278,7 +278,7 @@ end
local function IsFlying()
if (O.WarnWhileMounted) then return false; end
local result = GetShapeshiftForm(false)
if ((result == 5 and not CheckMoonkinBuff()) or result == 6) and sPlayerClass == "DRUID" then
if ((result == 5 and not CheckForBuff(SMARTBUFF_DRUID_MOONKIN)) or result == 6) and sPlayerClass == "DRUID" then
return true
end
return false
Expand Down Expand Up @@ -338,17 +338,6 @@ local function CT()
return currentTemplate;
end

-- check for K'iru's Song of Victory
local function CheckKirusSongBuff()
for i=1,40 do
name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura("player",i);
if name == SMARTBUFF_KIRUSSOV then
return true;
end
end
return false;
end

local function GetBuffSettings(buff)
if (B and buff) then
return B[CS()][CT()][buff];
Expand Down Expand Up @@ -2042,7 +2031,7 @@ function SMARTBUFF_BuffUnit(unit, subgroup, mode, spell)
end

-- check if daily island buff is active
if (bUsable and CheckKirusSongBuff() and (sPlayerClass == "PRIEST" or sPlayerClass == "MAGE")) then
if (bUsable and CheckForBuff(SMARTBUFF_KIRUSSOV) and (sPlayerClass == "PRIEST" or sPlayerClass == "MAGE")) then
-- island buff is more powerful than the class buffs which prevents the addon moving past this.
if (buffnS == SMARTBUFF_AI or buffnS == SMARTBUFF_ABRB1 or buffnS == SMARTBUFF_PWF or buffnS == SMARTBUFF_POFRB1) then
bUsable = false;
Expand Down
2 changes: 1 addition & 1 deletion SmartBuff.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 30400
## Title: |TInterface\Addons\Smartbuff\Icons\IconEnabled:0|t SmartBuff |cffffffff(WOTLK Classic)|r
## Version: 34.30400
## Version: 35.30400
## Author: |cff20d2ffCodermik (Mik / Castanova on EU-Mirage Raceway) & Aeldra|r (EU-Proudmoore)
## Notes: Cast the most important buffs on you or party, raid, pets and assigned tanks. Use /sbm for options menu.
## DefaultState: Enabled
Expand Down

0 comments on commit 4be871c

Please sign in to comment.