Skip to content

Commit

Permalink
Node power sorting (#4617)
Browse files Browse the repository at this point in the history
* fix node power when infinites are involved

* restore sorting by maximum hit taken
  • Loading branch information
Regisle authored Jul 29, 2022
1 parent 961b0fc commit 0d49cdb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Classes/NotableDBControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local t_insert = table.insert
local t_sort = table.sort
local m_max = math.max
local m_floor = math.floor
local m_huge = math.huge
local s_format = string.format

---@param node table
Expand Down Expand Up @@ -131,6 +132,7 @@ function NotableDBClass:ListBuilder()

if self.sortDetail and self.sortDetail.stat then -- stat-based
local cache = { }
local infinites = { }
local start = GetTime()
local calcFunc = self.itemsTab.build.calcsTab:GetMiscCalculator()
local itemType = self.itemsTab.displayItem.base.type
Expand All @@ -141,7 +143,11 @@ function NotableDBClass:ListBuilder()
if node.modKey ~= "" then
local output = calcFunc({ repSlotName = itemType, repItem = self.itemsTab:anointItem(node) }, {})
node.measuredPower = self:CalculatePowerStat(self.sortDetail, output, calcBase)
self.sortMaxPower = m_max(self.sortMaxPower, node.measuredPower)
if node.measuredPower == m_huge then
t_insert(infinites, node)
else
self.sortMaxPower = m_max(self.sortMaxPower, node.measuredPower)
end
end
local now = GetTime()
if now - start > 50 then
Expand All @@ -150,6 +156,13 @@ function NotableDBClass:ListBuilder()
start = now
end
end

if #infinites > 0 then
self.sortMaxPower = self.sortMaxPower * 2
for _, node in ipairs(infinites) do
node.measuredPower = self.sortMaxPower
end
end
end

table.sort(list, function(a, b)
Expand Down
12 changes: 12 additions & 0 deletions src/Modules/CalcDefence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1981,4 +1981,16 @@ function calcs.defence(env, actor)
t_insert(breakdown[damageType.."MaximumHitTaken"], s_format("Maximum hit you can take: %.0f", output[damageType.."MaximumHitTaken"]))
end
end

local minimum = m_huge
local SecondMinimum = m_huge
for _, damageType in ipairs(dmgTypeList) do
if output[damageType.."MaximumHitTaken"] < minimum then
SecondMinimum = minimum
minimum = output[damageType.."MaximumHitTaken"]
elseif output[damageType.."MaximumHitTaken"] < SecondMinimum then
SecondMinimum = output[damageType.."MaximumHitTaken"]
end
end
output.SecondMinimalMaximumHitTaken = SecondMinimum
end

0 comments on commit 0d49cdb

Please sign in to comment.