Skip to content
Open
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
43 changes: 43 additions & 0 deletions spec/System/TestTradeQuery_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,49 @@ describe("TradeQuery", function()
assert.are.equal(0, #tooltip.lines)
end)
end)
describe("GetResultEvaluation", function()
local function newMegalomaniacTradeQuery(slotTbl)
return tq
end

it("evaluates a socketed Megalomaniac by node combination", function()
local slotTbl = {
slotName = "Megalomaniac", unique = true, alreadyCorrupted = true, selectedJewelNodeId = 12345,
}
local tq = new("TradeQuery", { itemsTab = {} })
tq.statSortSelectionList = {}
tq.tradeQueryGenerator = new("TradeQueryGenerator", { itemsTab = {} })
tq.itemsTab.build = {
spec = {
tree = {
clusterNodeMap = {
["Node One"] = { dn = "Node One" },
["Node Two"] = { dn = "Node Two" },
["Node Three"] = { dn = "Node Three" },
}
}
}
}
tq.slotTables[1] = slotTbl
tq.resultTbl[1] = {
[1] = {
item_string = table.concat({
"1 Added Passive Skill is Node One",
"1 Added Passive Skill is Node Two",
"1 Added Passive Skill is Node Three",
}, "\n")
}
}

local evaluation = tq:GetResultEvaluation(1, 1, function() return {} end, {})

assert.are.equal(4, #evaluation)
for _, entry in ipairs(evaluation) do
assert.is_table(entry.DNs)
assert.is_true(#entry.DNs >= 2)
end
end)
end)
describe("ReduceOutput", function()
it("preserves lower-is-better values for weighted result comparison", function()
local weights = {
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
end
local slotTbl = self.slotTables[row_idx]
local jewelNodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
local slotName = jewelNodeId and "Jewel " .. tostring(jewelNodeId) or slotTbl.slotName
if slotName == "Megalomaniac" then
if slotTbl.slotName == "Megalomaniac" then
local addedNodes = {}
for nodeName in (result.item_string.."\r\n"):gmatch("1 Added Passive Skill is (.-)\r?\n") do
t_insert(addedNodes, self.itemsTab.build.spec.tree.clusterNodeMap[nodeName])
Expand All @@ -839,6 +838,7 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
}
table.sort(result.evaluation, function(a, b) return a.weight > b.weight end)
else
local slotName = jewelNodeId and "Jewel " .. tostring(jewelNodeId) or slotTbl.slotName
local item = new("Item"):Item(result.item_string)

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