Skip to content
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
23 changes: 23 additions & 0 deletions spec/System/TestTradeQuery_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,29 @@ describe("TradeQuery", function()
end)
end)
describe("GetResultEvaluation", function()
it("uses the first visible ring for a Pearl result without a selected slot", function()
local tq = new("TradeQuery"):TradeQuery({ itemsTab = {} })
tq.statSortSelectionList = {}
tq.tradeQueryGenerator = new("TradeQueryGenerator"):TradeQueryGenerator({ itemsTab = {} })
tq.itemsTab.slots = {
["Ring 1"] = { slotName = "Ring 1", shown = function() return false end },
["Ring 2"] = { slotName = "Ring 2", shown = function() return true end },
}
tq.slotTables[1] = { slotName = "Pearl of Tsoatha", unique = true }
tq.resultTbl[1] = {
[1] = { item_string = "Rarity: RARE\nBehemoth Hold\nGold Ring" },
}
local evaluatedSlot

tq:GetResultEvaluation(1, 1, function(override)
evaluatedSlot = override.repSlotName
return {}
end, {})

assert.are.equal("Ring 2", evaluatedSlot)
assert.are.equal("Ring 2", tq.slotTables[1].selectedSlotName)
end)

it("evaluates a socketed Megalomaniac by node combination", function()
local slotTbl = {
slotName = "Megalomaniac", unique = true, alreadyCorrupted = true, selectedJewelNodeId = 12345,
Expand Down
22 changes: 17 additions & 5 deletions src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function TradeQueryClass:PriceItem()
self.clickTime = nil
return "Not authenticated"
else
return "Logging in... (" .. left .. ") - URL copied to clipboard"
return "Logging in... (" .. left .. ")"
end
else
return colorCodes.WARNING.."Not authenticated"
Expand Down Expand Up @@ -539,6 +539,7 @@ Highest Weight - Displays the order retrieved from trade]]
---@field unique boolean? Row targets a specific unique instead of a slot
---@field alreadyCorrupted boolean? The targeted unique only drops corrupted
---@field selectedJewelNodeId number? Jewel socket the unique row searches for
---@field selectedSlotName string? A slot name which was selected in the TradeQueryGenerator popup

---@type TradeQuerySlotTable[]
local slotTables = {}
Expand Down Expand Up @@ -574,10 +575,12 @@ Highest Weight - Displays the order retrieved from trade]]
-- dynamically hide rows that are above or below the scrollBar
local hideRowFunc = function(self, index)
if scrollBarShown then
-- 22 items fit in the scrollBar "box" so as the offset moves, we need to dynamically show what is within the boundaries
if (index < 23 and (self.controls.scrollBar.offset < ((row_height + row_vertical_padding)*(index-1) + row_vertical_padding))) or
local rowWithPadding = row_height + row_vertical_padding
-- this many items fit in the scrollBar "box" so as the offset moves, we need to dynamically show what is within the boundaries
local maxItemsInView = math.floor(self.controls.scrollBar.height / rowWithPadding) - 2
if (index <= maxItemsInView and (self.controls.scrollBar.offset < (rowWithPadding * (index - 1) + row_vertical_padding))) or
-- the second and in this applies if we have more than 44 slots because we need to hide the next "page" of rows as they go above the line, e.g. #23 could be above or below the "box"
(index >= 23 and (self.controls.scrollBar.offset > (row_height + row_vertical_padding)*(index-22) and self.controls.scrollBar.offset < (row_height + row_vertical_padding)*(index-1))) then
(index >= maxItemsInView + 1 and (self.controls.scrollBar.offset > rowWithPadding * (index - maxItemsInView) and self.controls.scrollBar.offset < rowWithPadding * (index - 1))) then
return true
end
else
Expand Down Expand Up @@ -856,7 +859,16 @@ 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
if slotTbl.slotName == "Pearl of Tsoatha" and not slotTbl.selectedSlotName then
for index = 1, 3 do
local ringSlot = self.itemsTab.slots["Ring " .. index]
if ringSlot and ringSlot.shown() then
slotTbl.selectedSlotName = ringSlot.slotName
break
end
end
end
local slotName = jewelNodeId and "Jewel " .. tostring(jewelNodeId) or slotTbl.selectedSlotName or slotTbl.slotName
local item = new("Item"):Item(result.item_string)

local output = self:ReduceOutput(calcFunc({ repSlotName = slotName, repItem = item }))
Expand Down
2 changes: 2 additions & 0 deletions src/Classes/TradeQueryGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1490,10 +1490,12 @@ Remove: %s will be removed from the search results.]], term, term, term)
options.statWeights = statWeights
if controls.jewelSlot then
slot = controls.jewelSlot:GetSelValue()
-- pass node id back to table so evaluation can use the correct socket instead of the unique pseudo slot
context.slotTbl.selectedJewelNodeId = slot.nodeId
end
if controls.ringSlot then
slot = controls.ringSlot:GetSelValue()
context.slotTbl.selectedSlotName = slot.slotName
end

self:StartQuery(slot, options)
Expand Down
Loading