Skip to content
Closed
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
28 changes: 27 additions & 1 deletion src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,14 @@ Highest Weight - Displays the order retrieved from trade]]
return hideRowFunc(self, row_count)
end
row_count = row_count + 1
-- Watcher's Eye
self.slotTables[row_count] = { slotName = "Watcher's Eye", unique = true }
self:PriceItemRowDisplay(row_count, top_pane_alignment_ref, row_vertical_padding, row_height)
self.controls["name"..row_count].y = self.controls["name"..row_count].y + (row_height + row_vertical_padding)
self.controls["name"..row_count].shown = function()
return hideRowFunc(self, row_count) and self:findValidSlotForWatchersEye()
end
row_count = row_count + 1

local effective_row_count = row_count - ((scrollBarShown and #activeSocketList >= 4) and #activeSocketList-4 or 0) + 2 + 2 -- Two top menu rows, two bottom rows, 4 sockets overlap the other controls at the bottom of the pane
self.effective_rows_height = row_height * (effective_row_count - #activeSocketList + 3 or 0) -- scrollBar height
Expand Down Expand Up @@ -849,12 +857,30 @@ function TradeQueryClass:addChaosEquivalentPriceToItems(items)
return outputItems
end

-- return valid slot for Watcher's Eye
function TradeQueryClass:findValidSlotForWatchersEye()
local tmpWE=nil
for _,v in ipairs(data.uniques.generated) do
if v:find("Watcher's Eye") then
tmpWE= new("Item",v)
break
end
end
for _,v in pairs(self.itemsTab.sockets) do
if not v.inactive then
if self.itemsTab:IsItemValidForSlot(tmpWE,v.slotName,self.itemsTab.activeItemSet) then
return self.itemsTab.sockets[v.nodeId]
end
end
end
end

-- Method to generate pane elements for each item slot
function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, row_vertical_padding, row_height)
local controls = self.controls
local slotTbl = self.slotTables[row_idx]
local activeSlotRef = slotTbl.nodeId and self.itemsTab.activeItemSet[slotTbl.nodeId] or self.itemsTab.activeItemSet[slotTbl.slotName]
local activeSlot = slotTbl.nodeId and self.itemsTab.sockets[slotTbl.nodeId] or slotTbl.slotName and self.itemsTab.slots[slotTbl.slotName]
local activeSlot = slotTbl.nodeId and self.itemsTab.sockets[slotTbl.nodeId] or slotTbl.slotName and self.itemsTab.slots[slotTbl.slotName] or slotTbl.slotName == "Watcher's Eye" and self:findValidSlotForWatchersEye()
local nameColor = slotTbl.unique and colorCodes.UNIQUE or "^7"
controls["name"..row_idx] = new("LabelControl", top_pane_alignment_ref, 0, row_idx*(row_height + row_vertical_padding), 100, row_height - 4, nameColor..slotTbl.slotName)
controls["bestButton"..row_idx] = new("ButtonControl", { "LEFT", controls["name"..row_idx], "LEFT"}, 100 + 8, 0, 80, row_height, "Find best", function()
Expand Down
90 changes: 88 additions & 2 deletions src/Classes/TradeQueryGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ local tradeStatCategoryIndices = {
["Exarch"] = 3,
["Synthesis"] = 3,
["PassiveNode"] = 2,
["WatchersEye"] = 2,
}

local influenceSuffixes = { "_shaper", "_elder", "_adjudicator", "_basilisk", "_crusader", "_eyrie"}
Expand Down Expand Up @@ -402,6 +403,7 @@ function TradeQueryGeneratorClass:InitMods()
["Exarch"] = { },
["Synthesis"] = { },
["PassiveNode"] = { },
["WatchersEye"] = { },
}

-- originates from: https://www.pathofexile.com/api/trade/data/stats
Expand Down Expand Up @@ -460,6 +462,17 @@ function TradeQueryGeneratorClass:InitMods()
end
self:GenerateModData(clusterNotableMods, tradeQueryStatsParsed)

-- Watcher's Eye
local watchersEyeMods = {}
for _,v in pairs(data.uniqueMods["Watcher's Eye"]) do
if v.Id:find("SublimeVision") or v.Id:find("SummonArbalist") then
goto continue
end
watchersEyeMods[v.Id] = v.mod
watchersEyeMods[v.Id].type = "WatchersEye"
::continue::
end
self:GenerateModData(watchersEyeMods,tradeQueryStatsParsed,{ ["BaseJewel"] = true, ["AnyJewel"] = true },{["AnyJewel"]="AnyJewel"})
-- Base item implicit mods. A lot of this code is duplicated from generateModData(), but with important small logical flow changes to handle the format differences
for baseName, entry in pairs(data.itemBases) do
if entry.implicit ~= nil then
Expand Down Expand Up @@ -674,6 +687,28 @@ function TradeQueryGeneratorClass:StartQuery(slot, options)
calcNodesInsteadOfMods = true,
}
end
if options.special.itemName == "Watcher's Eye" then
special={
queryExtra = {
name = "Watcher's Eye"
},
queryFilters = {
type_filters = {
filters = {
category = {
option = "jewel"
},
rarity = {
option = "unique"
}
}
}
},
watchersEye = true
}
itemCategory = "AnyJewel"
itemCategoryQueryStr = "jewel"
end
elseif slot.slotName == "Weapon 2" or slot.slotName == "Weapon 1" then
if existingItem then
if existingItem.type == "Shield" then
Expand Down Expand Up @@ -821,6 +856,13 @@ function TradeQueryGeneratorClass:ExecuteQuery()
self:GeneratePassiveNodeWeights(self.modData.PassiveNode)
return
end
if self.calcContext.special.watchersEye then
self:GenerateModWeights(self.modData.WatchersEye)
if self.calcContext.options.includeCorrupted then
self:GenerateModWeights(self.modData["Corrupted"])
end
return
end
self:GenerateModWeights(self.modData["Explicit"])
self:GenerateModWeights(self.modData["Implicit"])
if self.calcContext.options.includeCorrupted then
Expand All @@ -838,6 +880,36 @@ function TradeQueryGeneratorClass:ExecuteQuery()
end
end

function TradeQueryGeneratorClass:addMoreWEMods()
local function getTableOfTradeModIds(tbl)
local tmpTable={}
for _,val in ipairs(tbl) do
table.insert(tmpTable,val.tradeModId)
end
return tmpTable
end
for _,skillGroup in ipairs(self.itemsTab.build.skillsTab.socketGroupList) do
for _,gem in ipairs(skillGroup.gemList) do
local tmpAura=""
if not gem.enabled then
goto continue
elseif gem.nameSpec:find("Vaal") and gem.enableGlobal2 then
tmpAura=gem.nameSpec:gsub("Vaal ",""):gsub("Impurity","Purity"):gsub("of","Of"):gsub(" ","")
elseif gem.gemData and gem.gemData.tags.aura or gem.fromItem then
tmpAura=gem.nameSpec:gsub("of","Of"):gsub(" ","")
else
goto continue
end
for id,mod in pairs(self.modData.WatchersEye) do
if id:find(tmpAura) and not isValueInTable(getTableOfTradeModIds(self.modWeights),mod.tradeMod.id) then
table.insert(self.modWeights,{invert=false,meanStatDiff=0,weight=0,tradeModId=mod.tradeMod.id})
end
end
::continue::
end
end
end

function TradeQueryGeneratorClass:FinishQuery()
-- Calc original item Stats without anoint or enchant, and use that diff as a basis for default min sum.
local originalItem = self.calcContext.slot and self.itemsTab.items[self.calcContext.slot.selItemId]
Expand All @@ -861,6 +933,10 @@ function TradeQueryGeneratorClass:FinishQuery()
local originalOutput = originalItem and self.calcContext.calcFunc({ repSlotName = self.calcContext.slot.slotName, repItem = self.calcContext.testItem }, { nodeAlloc = true }) or self.calcContext.baseOutput
local currentStatDiff = TradeQueryGeneratorClass.WeightedRatioOutputs(self.calcContext.baseOutput, originalOutput, self.calcContext.options.statWeights) * 1000 - (self.calcContext.baseStatValue or 0)

if self.calcContext.options.includeAllWEMods then
self:addMoreWEMods()
end

-- Sort by mean Stat diff rather than weight to more accurately prioritize stats that can contribute more
table.sort(self.modWeights, function(a, b)
return a.meanStatDiff > b.meanStatDiff
Expand Down Expand Up @@ -1045,12 +1121,12 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
updateLastAnchor(controls.includeEldritch)
end

if isJewelSlot then
if isJewelSlot and context.slotTbl.slotName ~= "Watcher's Eye" then
controls.jewelType = new("DropDownControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, 0, 5, 100, 18, { "Any", "Base", "Abyss" }, function(index, value) end)
controls.jewelType.selIndex = self.lastJewelType or 1
controls.jewelTypeLabel = new("LabelControl", {"RIGHT",controls.jewelType,"LEFT"}, -5, 0, 0, 16, "Jewel Type:")
updateLastAnchor(controls.jewelType)
elseif slot and not isAbyssalJewelSlot then
elseif slot and not isAbyssalJewelSlot and context.slotTbl.slotName ~= "Watcher's Eye" then
controls.influence1 = new("DropDownControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, 0, 5, 100, 18, influenceDropdownNames, function(index, value) end)
controls.influence1.selIndex = self.lastInfluence1 or 1
controls.influence1Label = new("LabelControl", {"RIGHT",controls.influence1,"LEFT"}, -5, 0, 0, 16, "Influence 1:")
Expand Down Expand Up @@ -1130,6 +1206,13 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
end
popupHeight = popupHeight + 4

if context.slotTbl.slotName == "Watcher's Eye" then
controls.includeAllWEMods = new("CheckBoxControl", {"TOPRIGHT",lastItemAnchor,"BOTTOMRIGHT"}, 0, 5, 18, "Include all Watcher's Eye mods:", function(state) end)
controls.includeAllWEMods.tooltipText = "Include all Watcher's Eye mods in the generated query for which weights couldn't be calculated"
lastItemAnchor = controls.includeAllWEMods
popupHeight = popupHeight + 23
end

controls.generateQuery = new("ButtonControl", { "BOTTOM", nil, "BOTTOM" }, -45, -10, 80, 20, "Execute", function()
main:ClosePopup()

Expand Down Expand Up @@ -1175,6 +1258,9 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
if controls.links and controls.links.buf then
options.links = tonumber(controls.links.buf)
end
if controls.includeAllWEMods then
options.includeAllWEMods = controls.includeAllWEMods.state
end
options.statWeights = statWeights

self:StartQuery(slot, options)
Expand Down
Loading