Skip to content

Commit

Permalink
Remove redundant crit/dodge functions
Browse files Browse the repository at this point in the history
  • Loading branch information
raethkcj committed Dec 25, 2023
1 parent 72673ba commit ee69880
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 119 deletions.
14 changes: 7 additions & 7 deletions RatingBuster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2154,13 +2154,13 @@ do
end
end
if profileDB.showCritFromAgi then
local effect = StatLogic:GetCritFromAgi(value, class, calcLevel)
local effect = value * StatLogic:GetCritPerAgi(class, calcLevel)
if effect > 0 then
tinsert(infoTable, (L["$value% Crit"]:gsub("$value", ("%+.2f"):format(effect))))
end
end
if profileDB.showDodgeFromAgi and (calcLevel == playerLevel) then
local effect = StatLogic:GetDodgeFromAgi(value)
local effect = value * StatLogic:GetDodgePerAgi()
if effect > 0 then
tinsert(infoTable, (L["$value% Dodge"]:gsub("$value", ("%+.2f"):format(effect))))
end
Expand Down Expand Up @@ -2252,7 +2252,7 @@ do
end
end
if profileDB.showSpellCritFromInt then
local effect = StatLogic:GetSpellCritFromInt(value, class, calcLevel)
local effect = value * StatLogic:GetSpellCritPerInt(class, calcLevel)
if effect > 0 then
tinsert(infoTable, (L["$value% Spell Crit"]:gsub("$value", ("%+.2f"):format(effect))))
end
Expand Down Expand Up @@ -2716,7 +2716,7 @@ local summaryCalcData = {
func = function(sum)
return sum[StatLogic.Stats.MeleeCrit]
+ StatLogic:GetEffectFromRating(sum["MELEE_CRIT_RATING"], "MELEE_CRIT_RATING", calcLevel)
+ StatLogic:GetCritFromAgi(sum[StatLogic.Stats.Agility], class, calcLevel)
+ sum[StatLogic.Stats.Agility] * StatLogic:GetCritPerAgi(class, calcLevel)
end,
ispercent = true,
},
Expand All @@ -2735,7 +2735,7 @@ local summaryCalcData = {
func = function(sum)
return sum[StatLogic.Stats.RangedCrit]
+ StatLogic:GetEffectFromRating(sum["RANGED_CRIT_RATING"], "RANGED_CRIT_RATING", calcLevel)
+ StatLogic:GetCritFromAgi(sum[StatLogic.Stats.Agility], class, calcLevel)
+ sum[StatLogic.Stats.Agility] * StatLogic:GetCritPerAgi(class, calcLevel)
end,
ispercent = true,
},
Expand Down Expand Up @@ -2973,7 +2973,7 @@ local summaryCalcData = {
func = function(sum)
return sum[StatLogic.Stats.SpellCrit]
+ StatLogic:GetEffectFromRating(summaryFunc["SPELL_CRIT_RATING"](sum), "SPELL_CRIT_RATING", calcLevel)
+ StatLogic:GetSpellCritFromInt(sum[StatLogic.Stats.Intellect], class, calcLevel)
+ sum[StatLogic.Stats.Intellect] * StatLogic:GetSpellCritPerInt(class, calcLevel)
end,
ispercent = true,
},
Expand Down Expand Up @@ -3033,7 +3033,7 @@ local summaryCalcData = {
return sum[StatLogic.Stats.Dodge]
+ StatLogic:GetEffectFromRating(sum["DODGE_RATING"], "DODGE_RATING", calcLevel)
+ summaryFunc[StatLogic.Stats.Defense](sum) * DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE
+ StatLogic:GetDodgeFromAgi(sum[StatLogic.Stats.Agility])
+ sum[StatLogic.Stats.Agility] * StatLogic:GetDodgePerAgi()
end,
ispercent = true,
},
Expand Down
112 changes: 0 additions & 112 deletions libs/StatLogic/StatLogic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1389,62 +1389,6 @@ function StatLogic:GetDodgePerAgi()
return dodgeFromAgi / agility
end

--[[---------------------------------
{ :GetDodgeFromAgi(agi)
-------------------------------------
-- Description
Calculates the dodge chance from agility for your current class and level.
-- Args
agi
number - agility
-- Returns
[dodge]
number - dodge percentage
[statid]
Stat - StatLogic.Stats.Dodge
-- Remarks
Only works for your currect class and current level, does not support class and level args.
-- Examples
StatLogic:GetDodgeFromAgi(1) -- GetDodgePerAgi
StatLogic:GetDodgeFromAgi(10)
}
-----------------------------------]]

function StatLogic:GetDodgeFromAgi(agi)
-- argCheck for invalid input
self:argCheck(agi, 2, "number")
-- Calculate
return agi * self:GetDodgePerAgi(), StatLogic.Stats.Dodge
end

--[[---------------------------------
{ :GetCritFromAgi(agi, [class], [level])
-------------------------------------
-- Description
Calculates the melee/ranged crit chance from agility for any class or level.
-- Args
agi
number - agility
[class] - (defaults: PlayerClass)
string - english class name
number - class id
[level] - (defaults: PlayerLevel)
number - player level used for calculation
-- Returns
[crit]
number - melee/ranged crit percentage
[statid]
Stat - StatLogic.Stats.MeleeCrit
-- Remarks
-- Examples
StatLogic:GetCritFromAgi(1) -- GetCritPerAgi
StatLogic:GetCritFromAgi(10)
StatLogic:GetCritFromAgi(10, "WARRIOR")
StatLogic:GetCritFromAgi(10, nil, 70)
StatLogic:GetCritFromAgi(10, "WARRIOR", 70)
}
-----------------------------------]]

function StatLogic:GetCritPerAgi(class, level)
-- argCheck for invalid input
self:argCheck(class, 3, "nil", "string", "number")
Expand All @@ -1467,48 +1411,6 @@ function StatLogic:GetCritPerAgi(class, level)
end
end

function StatLogic:GetCritFromAgi(agi, class, level)
-- argCheck for invalid input
self:argCheck(agi, 2, "number")
self:argCheck(class, 3, "nil", "string", "number")
self:argCheck(level, 4, "nil", "number")
class = self:ValidateClass(class)
-- if level is invalid input, default to player level
if type(level) ~= "number" or level < 1 or level > GetMaxPlayerLevel() then
level = UnitLevel("player")
end
-- Calculate
return agi * self:GetCritPerAgi(class, level), StatLogic.Stats.MeleeCrit
end

--[[---------------------------------
{ :GetSpellCritFromInt(int, [class], [level])
-------------------------------------
-- Description
Calculates the spell crit chance from intellect for any class or level.
-- Args
int
number - intellect
[class] - (defaults: PlayerClass)
string - english class name
number - class id
[level] - (defaults: PlayerLevel)
number - player level used for calculation
-- Returns
[spellcrit]
number - spell crit percentage
[statid]
Stat - StatLogic.Stats.SpellCrit
-- Remarks
-- Examples
StatLogic:GetSpellCritFromInt(1) -- GetSpellCritPerInt
StatLogic:GetSpellCritFromInt(10)
StatLogic:GetSpellCritFromInt(10, "MAGE")
StatLogic:GetSpellCritFromInt(10, nil, 70)
StatLogic:GetSpellCritFromInt(10, "MAGE", 70)
}
-----------------------------------]]

function StatLogic:GetSpellCritPerInt(class, level)
-- argCheck for invalid input
self:argCheck(class, 3, "nil", "string", "number")
Expand All @@ -1530,20 +1432,6 @@ function StatLogic:GetSpellCritPerInt(class, level)
end
end

function StatLogic:GetSpellCritFromInt(int, class, level)
-- argCheck for invalid input
self:argCheck(int, 2, "number")
self:argCheck(class, 3, "nil", "string", "number")
self:argCheck(level, 4, "nil", "number")
class = self:ValidateClass(class)
-- if level is invalid input, default to player level
if type(level) ~= "number" or level < 1 or level > GetMaxPlayerLevel() then
level = UnitLevel("player")
end
-- Calculate
return int * StatLogic:GetSpellCritPerInt(class, level), StatLogic.Stats.SpellCrit
end

----------------------------------
-- Stat Summary Ignore Settings --
----------------------------------
Expand Down

0 comments on commit ee69880

Please sign in to comment.