Skip to content

Commit

Permalink
Refactoring: Renamed logic add/test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
homo-programmatis committed Aug 31, 2016
1 parent a534349 commit 89c060a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
72 changes: 36 additions & 36 deletions PackageDruid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ local function GetPackage_DruidCat()

-- Main box
logicList = newPackage.LogicLists[1];
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_TigersFury);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_SavageRoar);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Rake);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_LunarInspiration);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Rip);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_PredatorySwiftness_Bloodtalons);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Bloodtalons);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Thrash_Cat);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_BrutalSlash);
g_Addon.AddLogicUnused(logicList, 5);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_TigersFury);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_SavageRoar);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Rake);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_LunarInspiration);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Rip);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_PredatorySwiftness_Bloodtalons);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Bloodtalons);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Thrash_Cat);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_BrutalSlash);
g_Addon.Logic_AddUnused(logicList, 5);

-- Events box
logicList = newPackage.LogicLists[2];
g_Addon.AddLogicFirstAvailable(logicList, g_Addon.Logics.Druid_Incarnation_Cat, g_Addon.Logics.Druid_Berserk, g_Addon.Logics.Druid_Incarnation_Bear); -- BearIncarnation - In case of Guardian in cat form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_AshamanesFrenzy);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_ElunesGuidance);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_WildCharge);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_PredatorySwiftness);
g_Addon.Logic_AddFirstGood(logicList, g_Addon.Logics.Druid_Incarnation_Cat, g_Addon.Logics.Druid_Berserk, g_Addon.Logics.Druid_Incarnation_Bear); -- BearIncarnation - In case of Guardian in cat form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_AshamanesFrenzy);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_ElunesGuidance);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_WildCharge);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_PredatorySwiftness);

-- Survival box
logicList = newPackage.LogicLists[3];
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_SurvivalInstincts);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_RageOfTheSleeper); -- In case of Guardian in cat form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Barkskin); -- In case of Guardian in cat form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Renewal);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_LunarBeam); -- In case of Guardian in cat form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_BristlingFur); -- In case of Guardian in cat form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_SurvivalInstincts);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_RageOfTheSleeper); -- In case of Guardian in cat form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Barkskin); -- In case of Guardian in cat form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Renewal);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_LunarBeam); -- In case of Guardian in cat form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_BristlingFur); -- In case of Guardian in cat form

return newPackage;
end
Expand Down Expand Up @@ -76,27 +76,27 @@ local function GetPackage_DruidBear()

-- Main box
logicList = newPackage.LogicLists[1];
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Mangle_Bear);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Thrash_Bear);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Pulverize);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_GalacticGuardian);
g_Addon.AddLogicUnused(logicList, 3);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Mangle_Bear);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Thrash_Bear);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Pulverize);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_GalacticGuardian);
g_Addon.Logic_AddUnused(logicList, 3);

-- Events box
logicList = newPackage.LogicLists[2];
g_Addon.AddLogicFirstAvailable(logicList, g_Addon.Logics.Druid_Incarnation_Bear, g_Addon.Logics.Druid_Incarnation_Cat, g_Addon.Logics.Druid_Berserk); -- CatIncarnation/Berserk - in case of Feral in bear form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_AshamanesFrenzy); -- In case of Feral in bear form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_ElunesGuidance); -- In case of Feral in bear form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_WildCharge);
g_Addon.Logic_AddFirstGood(logicList, g_Addon.Logics.Druid_Incarnation_Bear, g_Addon.Logics.Druid_Incarnation_Cat, g_Addon.Logics.Druid_Berserk); -- CatIncarnation/Berserk - in case of Feral in bear form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_AshamanesFrenzy); -- In case of Feral in bear form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_ElunesGuidance); -- In case of Feral in bear form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_WildCharge);

-- Survival box
logicList = newPackage.LogicLists[3];
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_SurvivalInstincts);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_RageOfTheSleeper);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Barkskin);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_Renewal); -- In case of Feral in bear form
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_LunarBeam);
g_Addon.AddLogicIfAvailable(logicList, g_Addon.Logics.Druid_BristlingFur);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_SurvivalInstincts);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_RageOfTheSleeper);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Barkskin);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_Renewal); -- In case of Feral in bear form
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_LunarBeam);
g_Addon.Logic_AddIfItsGood(logicList, g_Addon.Logics.Druid_BristlingFur);

return newPackage;
end
Expand Down
12 changes: 6 additions & 6 deletions _FrameLogic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ g_Addon.LogicUnusedFrame =
Type = nil,
};

function g_Addon.IsLogicAvailable(a_Logic)
function g_Addon.Logic_IsAvailable(a_Logic)
if (nil ~= a_Logic.IsAvailable) then
return a_Logic.IsAvailable(a_Logic);
end
Expand All @@ -27,25 +27,25 @@ function g_Addon.IsLogicAvailable(a_Logic)
return false;
end

function g_Addon.AddLogicIfAvailable(a_Table, a_Logic)
if (not g_Addon.IsLogicAvailable(a_Logic)) then
function g_Addon.Logic_AddIfItsGood(a_Table, a_Logic)
if (not g_Addon.Logic_IsAvailable(a_Logic)) then
return;
end

table.insert(a_Table, a_Logic);
end

function g_Addon.AddLogicFirstAvailable(a_Table, ...)
function g_Addon.Logic_AddFirstGood(a_Table, ...)
local logicList = {...};
for _, logic in pairs(logicList) do
if (g_Addon.IsLogicAvailable(logic)) then
if (g_Addon.Logic_IsAvailable(logic)) then
table.insert(a_Table, logic);
return;
end
end
end

function g_Addon.AddLogicUnused(a_Table, a_MinCount)
function g_Addon.Logic_AddUnused(a_Table, a_MinCount)
local currentCount = #a_Table;
if (currentCount >= a_MinCount) then
return;
Expand Down

0 comments on commit 89c060a

Please sign in to comment.