Skip to content

Commit b50aa92

Browse files
author
LocalIdentity
committed
Fix FullDPS stat fallback
1 parent 2a2d3b6 commit b50aa92

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

spec/System/TestTradeQuery_spec.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
describe("TradeQuery", function ()
22
local mock_tradeQuery
3+
local mock_queryGen
34

45
before_each(function()
56
mock_tradeQuery = new("TradeQuery", { itemsTab = {} })
7+
mock_queryGen = new("TradeQueryGenerator", { itemsTab = {} })
68
end)
79

810
describe("ReduceOutput", function()
@@ -21,5 +23,24 @@ describe("TradeQuery", function ()
2123
assert.are.equals(260, result.AverageDamage)
2224
assert.is_nil(result.Life)
2325
end)
26+
27+
it("keeps fallback DPS stats when FullDPS is selected but not present", function()
28+
mock_tradeQuery.statSortSelectionList = { { stat = "FullDPS", weightMult = 1 } }
29+
30+
local baseOutput = {
31+
CombinedDPS = 100,
32+
TotalDPS = 100,
33+
TotalDotDPS = 0,
34+
}
35+
local reducedOutput = mock_tradeQuery:ReduceOutput({
36+
CombinedDPS = 120,
37+
TotalDPS = 120,
38+
TotalDotDPS = 0,
39+
})
40+
41+
local result = mock_queryGen.WeightedRatioOutputs(baseOutput, reducedOutput, mock_tradeQuery.statSortSelectionList)
42+
43+
assert.are.equals(1.2, result)
44+
end)
2445
end)
2546
end)

src/Classes/TradeQuery.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,11 @@ function TradeQueryClass:ReduceOutput(output)
780780
local smallOutput = {}
781781
for _, statTable in ipairs(self.statSortSelectionList) do
782782
smallOutput[statTable.stat] = data.powerStatList.GetFromOutput(output, statTable)
783+
if statTable.stat == "FullDPS" and not output.FullDPS then
784+
smallOutput.TotalDPS = data.powerStatList.GetFromOutput(output, { stat = "TotalDPS" })
785+
smallOutput.TotalDotDPS = data.powerStatList.GetFromOutput(output, { stat = "TotalDotDPS" })
786+
smallOutput.CombinedDPS = data.powerStatList.GetFromOutput(output, { stat = "CombinedDPS" })
787+
end
783788
end
784789
return smallOutput
785790
end

0 commit comments

Comments
 (0)