Skip to content

Commit 75594eb

Browse files
vaisestLocalIdentity
andauthored
Fix megalomaniac trader crash (#10181)
* Fix #10180 * Add test * Fix test --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 6b1b26c commit 75594eb

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

spec/System/TestTradeQuery_spec.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,45 @@ describe("TradeQuery", function()
6161
assert.are.equal(0, #tooltip.lines)
6262
end)
6363
end)
64+
describe("GetResultEvaluation", function()
65+
it("evaluates a socketed Megalomaniac by node combination", function()
66+
local slotTbl = {
67+
slotName = "Megalomaniac", unique = true, alreadyCorrupted = true, selectedJewelNodeId = 12345,
68+
}
69+
local tq = new("TradeQuery"):TradeQuery({ itemsTab = {} })
70+
tq.statSortSelectionList = {}
71+
tq.tradeQueryGenerator = new("TradeQueryGenerator"):TradeQueryGenerator({ itemsTab = {} })
72+
tq.itemsTab.build = {
73+
spec = {
74+
tree = {
75+
clusterNodeMap = {
76+
["Node One"] = { dn = "Node One" },
77+
["Node Two"] = { dn = "Node Two" },
78+
["Node Three"] = { dn = "Node Three" },
79+
}
80+
}
81+
}
82+
}
83+
tq.slotTables[1] = slotTbl
84+
tq.resultTbl[1] = {
85+
[1] = {
86+
item_string = table.concat({
87+
"1 Added Passive Skill is Node One",
88+
"1 Added Passive Skill is Node Two",
89+
"1 Added Passive Skill is Node Three",
90+
}, "\n")
91+
}
92+
}
93+
94+
local evaluation = tq:GetResultEvaluation(1, 1, function() return {} end, {})
95+
96+
assert.are.equal(4, #evaluation)
97+
for _, entry in ipairs(evaluation) do
98+
assert.is_table(entry.DNs)
99+
assert.is_true(#entry.DNs >= 2)
100+
end
101+
end)
102+
end)
64103
describe("ReduceOutput", function()
65104
it("preserves lower-is-better values for weighted result comparison", function()
66105
local weights = {

src/Classes/TradeQuery.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,7 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
834834
end
835835
local slotTbl = self.slotTables[row_idx]
836836
local jewelNodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
837-
local slotName = jewelNodeId and "Jewel " .. tostring(jewelNodeId) or slotTbl.slotName
838-
if slotName == "Megalomaniac" then
837+
if slotTbl.slotName == "Megalomaniac" then
839838
local addedNodes = {}
840839
for nodeName in (result.item_string.."\r\n"):gmatch("1 Added Passive Skill is (.-)\r?\n") do
841840
t_insert(addedNodes, self.itemsTab.build.spec.tree.clusterNodeMap[nodeName])
@@ -857,6 +856,7 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
857856
}
858857
table.sort(result.evaluation, function(a, b) return a.weight > b.weight end)
859858
else
859+
local slotName = jewelNodeId and "Jewel " .. tostring(jewelNodeId) or slotTbl.slotName
860860
local item = new("Item"):Item(result.item_string)
861861

862862
local output = self:ReduceOutput(calcFunc({ repSlotName = slotName, repItem = item }))

0 commit comments

Comments
 (0)