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
68 changes: 47 additions & 21 deletions src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ Highest Weight - Displays the order retrieved from trade]]
end
end
table.sort(activeSocketList)
local activeUniqueJewelSocket
for _, nodeId in ipairs(activeSocketList) do
if not activeUniqueJewelSocket and not self.itemsTab.build.spec.nodes[nodeId].containJewelSocket then
activeUniqueJewelSocket = nodeId
end
t_insert(slotTables, { slotName = self.itemsTab.sockets[nodeId].label, nodeId = nodeId })
end

Expand Down Expand Up @@ -525,23 +529,23 @@ Highest Weight - Displays the order retrieved from trade]]
return hideRowFunc(self, #slotTables+1)
end
local row_count = #slotTables + 1
self.slotTables[row_count] = { slotName = "Megalomaniac", unique = true, alreadyCorrupted = true }
self.slotTables[row_count] = { slotName = "Megalomaniac", unique = true, alreadyCorrupted = true, selectedJewelNodeId = activeUniqueJewelSocket }
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) -- Megalomaniac needs to drop an extra row for "Other Trades"
self.controls["name"..row_count].shown = function()
return hideRowFunc(self, row_count)
end

row_count = row_count + 1
self.slotTables[row_count] = { slotName = "Heart of the Well", unique = true, selectedJewelNodeId = activeSocketList[1] }
self.slotTables[row_count] = { slotName = "Heart of the Well", unique = true, selectedJewelNodeId = activeUniqueJewelSocket }
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)
end

row_count = row_count + 1
self.slotTables[row_count] = { slotName = "Against the Darkness", unique = true, selectedJewelNodeId = activeSocketList[1] }
self.slotTables[row_count] = { slotName = "Against the Darkness", unique = true, selectedJewelNodeId = activeUniqueJewelSocket }
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()
Expand Down Expand Up @@ -798,7 +802,7 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
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("Allocates (.-)\r?\n") do
local node = self.itemsTab.build.spec.tree.notableMap[nodeName:lower()]
Expand Down Expand Up @@ -852,14 +856,22 @@ function TradeQueryClass:UpdateControlsWithItems(row_idx)
end

self.sortedResultTbl[row_idx] = sortedItems
local pb_index = self.sortedResultTbl[row_idx][1].index
if not sortedItems[1] then
self.itemIndexTbl[row_idx] = nil
self.totalPrice[row_idx] = nil
self.controls.fullPrice.label = "Total Price: " .. self:GetTotalPriceString()
self:UpdateDropdownList(row_idx)
self:SetNotice(self.controls.pbNotice, "^4No compatible items found for this slot.")
return
end
local pb_index = sortedItems[1].index
self.itemIndexTbl[row_idx] = pb_index
self.controls["priceButton".. row_idx].tooltipText = "Sorted by " .. self.itemSortSelectionList[self.pbItemSortSelectionIndex]
self.totalPrice[row_idx] = {
currency = self.resultTbl[row_idx][pb_index].currency,
amount = self.resultTbl[row_idx][pb_index].amount,
}
self.controls.fullPrice.label = "Total Price: " .. self:GetTotalPriceString()
self.controls.fullPrice.label = "^7Total Price: " .. self:GetTotalPriceString()
self:UpdateDropdownList(row_idx)
end

Expand All @@ -870,7 +882,7 @@ function TradeQueryClass:SetFetchResultReturn(row_idx, index)
currency = self.resultTbl[row_idx][index].currency,
amount = self.resultTbl[row_idx][index].amount,
}
self.controls.fullPrice.label = "Total Price: " .. self:GetTotalPriceString()
self.controls.fullPrice.label = "^7Total Price: " .. self:GetTotalPriceString()
end
end

Expand Down Expand Up @@ -950,15 +962,34 @@ function TradeQueryClass:SortFetchResults(row_idx, mode)
return newTbl
end

-- ensure we only take in items that parse properly to avoid crash issues and fit in the
-- provided slotName
---@param itemEntries table
---@param slotName string
function TradeQueryClass:FilterToSafeItems(itemEntries, slotName)
local itemsSafe = {}
for _, entry in ipairs(itemEntries) do
local item = new("Item", entry.item_string)
if item.base and ((not slotName) or self.itemsTab:IsItemValidForSlot(item, slotName)) then
t_insert(itemsSafe, entry)
end
end
return itemsSafe
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
local nodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
local activeSlot = nodeId and self.itemsTab.sockets[nodeId] or
slotTbl.slotName and (self.itemsTab.slots[slotTbl.slotName] or
slotTbl.slotName == "Watcher's Eye" and self:findValidSlotForWatchersEye() or
slotTbl.fullName and self.itemsTab.slots[slotTbl.fullName]) -- fullName for Abyssal Sockets
local function getSelectedSlot()
local selectedNodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
return selectedNodeId and self.itemsTab.sockets[selectedNodeId] or activeSlot
end
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), 135, row_height - 4}, nameColor..slotTbl.slotName)
controls["bestButton"..row_idx] = new("ButtonControl", { "LEFT", controls["name"..row_idx], "LEFT"}, {135 + 8, 0, 80, row_height}, "Find best", function()
Expand Down Expand Up @@ -987,14 +1018,8 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
self:SetNotice(context.controls.pbNotice, "")
end

-- ensure we only take in items that parse properly to avoid crash issues.
local itemsSafe = {}
for _, entry in ipairs(items) do
local item = new("Item", entry.item_string)
if item.base then
t_insert(itemsSafe, entry)
end
end
local selectedSlot = getSelectedSlot()
local itemsSafe = self:FilterToSafeItems(items, selectedSlot and selectedSlot.slotName)

if self.tradeQueryGenerator.lastAugmentBehaviour == "Copy Current" or self.tradeQueryGenerator.lastAnointBehaviour == "Copy Current" then
for i, _ in ipairs(itemsSafe) do
Expand Down Expand Up @@ -1079,7 +1104,9 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
else
self:SetNotice(controls.pbNotice, "")
self.lastQueries[row_idx] = query
self.resultTbl[row_idx] = items
local selectedSlot = getSelectedSlot()
local itemsSafe = self:FilterToSafeItems(items, selectedSlot and selectedSlot.slotName)
self.resultTbl[row_idx] = itemsSafe
self:UpdateControlsWithItems(row_idx)
end
controls["priceButton"..row_idx].label = "Price Item"
Expand All @@ -1090,7 +1117,7 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
local validURL = controls["uri"..row_idx].validURL
local isSearching = controls["priceButton"..row_idx].label == "Searching..."
local selectedJewelSlot = slotTbl.selectedJewelNodeId and self.itemsTab.sockets[slotTbl.selectedJewelNodeId]
local hasRequiredJewelSlot = not slotTbl.unique or slotTbl.slotName == "Megalomaniac" or selectedJewelSlot and not selectedJewelSlot.inactive
local hasRequiredJewelSlot = not slotTbl.unique or selectedJewelSlot and not selectedJewelSlot.inactive
return isAuthorized and validURL and not isSearching and hasRequiredJewelSlot
end
controls["priceButton"..row_idx].tooltipFunc = function(tooltip)
Expand All @@ -1099,8 +1126,7 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
tooltip:AddLine(16, "You must log in to use the search feature")
elseif not controls["uri"..row_idx].validURL then
tooltip:AddLine(16, "Enter a valid trade URL")
elseif slotTbl.unique and slotTbl.slotName ~= "Megalomaniac"
and (not slotTbl.selectedJewelNodeId or not self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or self.itemsTab.sockets[slotTbl.selectedJewelNodeId].inactive) then
elseif slotTbl.unique and (not slotTbl.selectedJewelNodeId or not self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or self.itemsTab.sockets[slotTbl.selectedJewelNodeId].inactive) then
tooltip:AddLine(16, "Requires an active Jewel Socket")
end
end
Expand All @@ -1112,7 +1138,7 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
self.sortedResultTbl[row_idx] = nil
self.resultTbl[row_idx] = nil
self.totalPrice[row_idx] = nil
self.controls.fullPrice.label = "Total Price: " .. self:GetTotalPriceString()
self.controls.fullPrice.label = "^7Total Price: " .. self:GetTotalPriceString()
end)
controls["changeButton"..row_idx].shown = function() return self.resultTbl[row_idx] end
controls["resultDropdown"..row_idx] = new("DropDownControl", { "TOPLEFT", controls["changeButton"..row_idx], "TOPRIGHT"}, {8, 0, 351, row_height}, {}, function(index)
Expand Down
9 changes: 6 additions & 3 deletions src/Classes/TradeQueryGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ function TradeQueryGeneratorClass:InitMods()

for catIdx, _ in ipairs(body.result) do
table.sort(body.result[catIdx].entries, function(a, b)
if a.text == b.text then
return a.id < b.id
end
return a.text < b.text
end)
end
Expand Down Expand Up @@ -1162,10 +1165,10 @@ Remove: anoints are completely ignored, and removed from items.]]
options.special = { itemName = context.slotTbl.slotName }
end

if context.slotTbl.slotName == "Heart of the Well" or context.slotTbl.slotName == "Against the Darkness" then
if context.slotTbl.slotName == "Megalomaniac" or context.slotTbl.slotName == "Heart of the Well" or context.slotTbl.slotName == "Against the Darkness" then
local activeSocketList = { }
for nodeId, jewelSlot in pairs(self.itemsTab.sockets) do
if not jewelSlot.inactive then
if not jewelSlot.inactive and not self.itemsTab.build.spec.nodes[nodeId].containJewelSocket then
t_insert(activeSocketList, jewelSlot)
end
end
Expand All @@ -1184,7 +1187,7 @@ Remove: anoints are completely ignored, and removed from items.]]
end


if isJewelSlot then
if isJewelSlot and not context.slotTbl.unique then
controls.jewelType = new("DropDownControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 100, 18}, { "Base", "Radius" }, 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:")
Expand Down
21 changes: 9 additions & 12 deletions src/Classes/TradeQueryRequests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,25 +398,22 @@ function TradeQueryRequestsClass:FetchResultBlock(url, callback)

t_insert(rawLines, "Implicits: " .. (#item.enchantMods + #item.runeMods + #item.implicitMods))
for _, modLine in ipairs(item.enchantMods) do
t_insert(rawLines, "{enchant}" .. escapeGGGString(modLine))
t_insert(rawLines, "{enchant}" .. escapeGGGString(modLine))
end
for _, modLine in ipairs(item.runeMods) do
t_insert(rawLines, "{enchant}{rune}" .. escapeGGGString(modLine))
t_insert(rawLines, "{enchant}{rune}" .. escapeGGGString(modLine))
end
for _, modLine in ipairs(item.implicitMods) do
t_insert(rawLines, escapeGGGString(modLine))
end
for _, modLine in ipairs(item.fracturedMods) do
t_insert(rawLines, "{fractured}" .. escapeGGGString(modLine))
end
for _, modLine in ipairs(item.explicitMods) do
t_insert(rawLines, escapeGGGString(modLine))
end
for _, modLine in ipairs(item.desecratedMods) do
t_insert(rawLines, "{desecrated}" .. escapeGGGString(modLine))
end
for _, modLine in ipairs(item.craftedMods) do
t_insert(rawLines, "{crafted}" .. escapeGGGString(modLine))
local s = ""
for flagName, flag in pairs(modLine.flags or {}) do
if flag then
s = s .. string.format("{%s}", flagName)
end
end
t_insert(rawLines, s .. escapeGGGString(modLine.description))
end
if item.mirrored then
t_insert(rawLines, "Mirrored")
Expand Down
73 changes: 51 additions & 22 deletions src/Data/QueryMods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27696,18 +27696,10 @@ return {
["max"] = 300,
["min"] = 100,
},
["2HWeapon"] = {
["max"] = 50,
["min"] = 30,
},
["Amulet"] = {
["max"] = 40,
["min"] = 30,
},
["Quarterstaff"] = {
["max"] = 50,
["min"] = 30,
},
["Wand"] = {
["max"] = 300,
["min"] = 300,
Expand Down Expand Up @@ -27767,20 +27759,6 @@ return {
["type"] = "implicit",
},
},
["3489782002"] = {
["Amulet"] = {
["max"] = 30,
["min"] = 20,
},
["specialCaseData"] = {
},
["tradeMod"] = {
["id"] = "implicit.stat_3489782002",
["text"] = "# to maximum Energy Shield",
["type"] = "implicit",
},
["usePositiveSign"] = true,
},
["3544800472"] = {
["Chest"] = {
["max"] = 40,
Expand Down Expand Up @@ -28248,10 +28226,18 @@ return {
},
},
["774059442"] = {
["2HWeapon"] = {
["max"] = 50,
["min"] = 30,
},
["Chest"] = {
["max"] = 1000,
["min"] = 750,
},
["Quarterstaff"] = {
["max"] = 50,
["min"] = 30,
},
["specialCaseData"] = {
},
["tradeMod"] = {
Expand Down Expand Up @@ -29900,6 +29886,23 @@ return {
["type"] = "augment",
},
},
["1936645603"] = {
["2HWeapon"] = {
["max"] = 30,
["min"] = 30,
},
["Staff"] = {
["max"] = 30,
["min"] = 30,
},
["specialCaseData"] = {
},
["tradeMod"] = {
["id"] = "rune.stat_1936645603",
["text"] = "Gain #% of Physical Damage as Extra Fire Damage",
["type"] = "augment",
},
},
["1937310173"] = {
["Chest"] = {
["max"] = 50,
Expand Down Expand Up @@ -30996,6 +30999,19 @@ return {
["type"] = "augment",
},
},
["258955603"] = {
["Helmet"] = {
["max"] = 20,
["min"] = 20,
},
["specialCaseData"] = {
},
["tradeMod"] = {
["id"] = "rune.stat_258955603",
["text"] = "Alternating every 5 seconds:Take #% more Damage from HitsTake #% more Damage over time",
["type"] = "augment",
},
},
["2608793552"] = {
["1HMace"] = {
["max"] = 15,
Expand Down Expand Up @@ -32971,6 +32987,19 @@ return {
["type"] = "augment",
},
},
["352044736"] = {
["Helmet"] = {
["max"] = 1,
["min"] = 1,
},
["specialCaseData"] = {
},
["tradeMod"] = {
["id"] = "rune.stat_352044736",
["text"] = "Every Rage also grants #% increased Stun Threshold",
["type"] = "augment",
},
},
["3523867985"] = {
["Boots"] = {
["max"] = 20,
Expand Down
Loading
Loading