Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node power sorting #4617

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1991,4 +1991,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