Skip to content

Commit

Permalink
cleaner implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Peechey committed Jan 3, 2024
1 parent 47ebc19 commit 8a9dd09
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/Modules/Build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ local function InsertIfNew(t, val)
table.insert(t, val)
end

local function SplitString(input, delim)
local split = {}
if input then
for str in string.gmatch(input, "([^"..delim.."]+)") do
table.insert(split, str)
end
end
return split
end

function buildMode:Init(dbFileName, buildName, buildXML, convertBuild)
self.dbFileName = dbFileName
self.buildName = buildName
Expand Down Expand Up @@ -268,8 +258,8 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild)
{ stat = "PreEffectiveCritChance", label = "Crit Chance", fmt = ".2f%%" },
{ stat = "CritChance", label = "Effective Crit Chance", fmt = ".2f%%", condFunc = function(v,o) return v ~= o.PreEffectiveCritChance end },
{ stat = "CritMultiplier", label = "Crit Multiplier", fmt = "d%%", pc = true, condFunc = function(v,o) return (o.CritChance or 0) > 0 end },
{ stat = "MainHand.Accuracy", label = "MH Accuracy", fmt = "d", condFunc = function(v,o) return o.PreciseTechnique end },
{ stat = "OffHand.Accuracy", label = "OH Accuracy", fmt = "d", condFunc = function(v,o) return o.PreciseTechnique end },
{ stat = "MainHand", childStat = "Accuracy", label = "MH Accuracy", fmt = "d", condFunc = function(v,o) return o.PreciseTechnique end },
{ stat = "OffHand", childStat = "Accuracy", label = "OH Accuracy", fmt = "d", condFunc = function(v,o) return o.PreciseTechnique end },
{ stat = "HitChance", label = "Hit Chance", fmt = ".0f%%", flag = "attack" },
{ stat = "HitChance", label = "Hit Chance", fmt = ".0f%%", condFunc = function(v,o) return o.enemyHasSpellBlock end },
{ stat = "TotalDPS", label = "Hit DPS", fmt = ".1f", compPercent = true, flag = "notAverage" },
Expand Down Expand Up @@ -1365,17 +1355,16 @@ end
function buildMode:AddDisplayStatList(statList, actor)
local statBoxList = self.controls.statBox.list
for index, statData in ipairs(statList) do
-- allows access to output values that are one node deeper (statData.stat is a table e.g. output.MainHand.Accuracy vs output.Life)
local statSplit = SplitString(statData.stat, "%.")
if not statData.flag or actor.mainSkill.skillFlags[statData.flag] then
local labelColor = "^7"
if statData.color then
labelColor = statData.color
end
if statData.stat then
local statVal = actor.output[statData.stat]
if statSplit[2] then
statVal = actor.output[statSplit[1]] and actor.output[statSplit[1]][statSplit[2]]
-- access output values that are one node deeper (statData.stat is a table e.g. output.MainHand.Accuracy vs output.Life)
if statVal and statData.childStat then
statVal = actor.output[statData.stat][statData.childStat]
end
if statVal and ((statData.condFunc and statData.condFunc(statVal,actor.output)) or (not statData.condFunc and statVal ~= 0)) then
local overCapStatVal = actor.output[statData.overCapStat] or nil
Expand Down Expand Up @@ -1521,7 +1510,7 @@ end
function buildMode:CompareStatList(tooltip, statList, actor, baseOutput, compareOutput, header, nodeCount)
local count = 0
for _, statData in ipairs(statList) do
if statData.stat and (not statData.flag or actor.mainSkill.skillFlags[statData.flag]) and statData.stat ~= "SkillDPS" then
if statData.stat and (not statData.flag or actor.mainSkill.skillFlags[statData.flag]) and not statData.childStat and statData.stat ~= "SkillDPS" then
local statVal1 = compareOutput[statData.stat] or 0
local statVal2 = baseOutput[statData.stat] or 0
local diff = statVal1 - statVal2
Expand Down

0 comments on commit 8a9dd09

Please sign in to comment.