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
32 changes: 32 additions & 0 deletions spec/System/TestTradeQueryGenerator_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,38 @@ describe("TradeQueryGenerator", function()
end)
end)

describe("Query options", function()
it("uses remembered links in the next filter for the same slot", function()
local queryGen = new("TradeQueryGenerator"):TradeQueryGenerator({ itemsTab = { items = { } } })

local function runQuery(slotName, links)
local requestedOptions
queryGen.StartQuery = function(_, _, options)
requestedOptions = options
end
local context = {
slotTbl = { slotName = slotName, alreadyCorrupted = false },
controls = { tradeTypeSelection = { selIndex = 1 } },
}
queryGen:RequestQuery({ slotName = slotName }, context, { }, function() end)
if links ~= nil then
main.popups[1].controls.links:SetText(links)
end
main.popups[1].controls.generateQuery:Click()
return requestedOptions.links
end

assert.are.equal(6, runQuery("Body Armour", "6"))
assert.are.equal(6, runQuery("Body Armour"))
assert.is_nil(runQuery("Helmet"))
assert.is_nil(runQuery("Body Armour", ""))
assert.is_nil(runQuery("Body Armour"))
assert.are.equal(6, runQuery("Body Armour", "6"))
assert.are.equal(0, runQuery("Body Armour", "0"))
assert.is_nil(runQuery("Body Armour"))
end)
end)

describe("WeightedRatioOutputs", function()
local maxStatIncrease

Expand Down
6 changes: 5 additions & 1 deletion src/Classes/TradeQueryGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function TradeQueryGeneratorClass:TradeQueryGenerator(queryTab)
self.lastMaxPrice = nil
self.lastMaxPriceTypeIndex = nil
self.lastMaxLevel = nil
self.lastLinksBySlot = { }
return self
end

Expand Down Expand Up @@ -1329,6 +1330,8 @@ Remove: %s will be removed from the search results.]], term, term, term)

if not slot.slotName:find("Belt") and not slot.slotName:find("Ring") and not slot.slotName:find("Amulet") then
controls.links = new("EditControl"):EditControl({"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 70, 18}, nil, nil, "%D")
local lastLinks = self.lastLinksBySlot[slot.slotName]
controls.links.buf = lastLinks and tostring(lastLinks) or ""
controls.linksLabel = new("LabelControl"):LabelControl({"RIGHT",controls.links,"LEFT"}, {-5, 0, 0, 16}, "^7# of Links:")
updateLastAnchor(controls.links)
end
Expand Down Expand Up @@ -1407,8 +1410,9 @@ Remove: %s will be removed from the search results.]], term, term, term)
options.sockets = tonumber(controls.sockets.buf)
self.lastSockets = options.sockets
end
if controls.links and controls.links.buf then
if controls.links then
options.links = tonumber(controls.links.buf)
self.lastLinksBySlot[slot.slotName] = options.links and options.links > 0 and options.links or nil
end
if controls.includeAllWEMods then
options.includeAllWEMods = controls.includeAllWEMods.state
Expand Down
Loading