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
60 changes: 35 additions & 25 deletions src/Classes/TradeQueryGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local utils = LoadModule("Modules/Utils")
-- exist yet, but might exist in the future
local tradeCategoryNames = {
["Ring"] = { "Ring" },
["Amulet"] = { "Amulet" },
["Amulet"] = { "Amulet", "Amulet: Talisman" },
["Belt"] = { "Belt" },
["Chest"] = { "Body Armour", "Body Armour: Armour", "Body Armour: Armour/Energy Shield", "Body Armour: Armour/Evasion", "Body Armour: Armour/Evasion/Energy Shield", "Body Armour: Energy Shield", "Body Armour: Evasion", "Body Armour: Evasion/Energy Shield",
-- "Body Armour: Ward"
Expand Down Expand Up @@ -120,6 +120,7 @@ local function getStatEntries(modType)
["Rune"] = "rune",
["HeartOfTheWell"] = "explicit",
["AgainstTheDarkness"] = "explicit",
["Enchant"] = "enchant",
}
if tradeStatCategoryIndices[modType] then
for _, cat in ipairs(tradeStats) do
Expand Down Expand Up @@ -412,6 +413,7 @@ function TradeQueryGeneratorClass:InitMods()
self.modData = {
["Explicit"] = { },
["Implicit"] = { },
["Enchant"] = {},
["Corrupted"] = { },
["Scourge"] = { },
["Eater"] = { },
Expand Down Expand Up @@ -484,33 +486,40 @@ function TradeQueryGeneratorClass:InitMods()
{ ["AnyJewel"] = "AnyJewel" })

-- implicit mods
local function processImplicit(baseEntry, modId, modType)
local mod = copyTable(data.itemMods.ItemExclusive[modId] or error("mod id doesn't exist " .. modId))
mod.type = modType

-- create trade type mask for base type
local maskOverride = {}
for tradeName, typeNames in pairs(tradeCategoryNames) do
for _, typeName in ipairs(typeNames) do
local entryName = baseEntry.type
if baseEntry.subType then
entryName = entryName .. ": " .. baseEntry.subType
end
if typeName == entryName then
maskOverride[tradeName] = true;
break
end
end
end

-- mask found process implicit mod this avoids processing unimplemented bases
if next(maskOverride) ~= nil then
self:ProcessMod("", mod, tradeQueryStatsParsed, regularItemMask, maskOverride)
end
end
for _, entry in pairsSortByKey(data.itemBases) do
if entry.type == "Graft" then
goto continue
end
for _, modId in ipairs(entry.implicitIds or {}) do
local mod = copyTable(data.itemMods.ItemExclusive[modId] or error("mod id doesn't exist " .. modId))
mod.type = "Implicit"

-- create trade type mask for base type
local maskOverride = {}
for tradeName, typeNames in pairs(tradeCategoryNames) do
for _, typeName in ipairs(typeNames) do
local entryName = entry.type
if entry.subType then
entryName = entryName .. ": " .. entry.subType
end
if typeName == entryName then
maskOverride[tradeName] = true;
break
end
end
end

-- mask found process implicit mod this avoids processing unimplemented bases
if next(maskOverride) ~= nil then
self:ProcessMod("", mod, tradeQueryStatsParsed, regularItemMask, maskOverride)
end
processImplicit(entry, modId, "Implicit")
end
-- talismans have implicit-like enchants on the bases
for _, modId in ipairs(entry.enchantIds or {}) do
processImplicit(entry, modId, "Enchant")
end
::continue::
end
Expand Down Expand Up @@ -769,6 +778,7 @@ function TradeQueryGeneratorClass:ExecuteQuery()
if self.calcContext.options.includeCorrupted then
self:GenerateModWeights(self.modData["Corrupted"])
end
self:GenerateModWeights(self.modData["Enchant"])
if self.calcContext.options.includeScourge then
self:GenerateModWeights(self.modData["Scourge"])
end
Expand Down Expand Up @@ -1119,8 +1129,8 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
end

if isAmuletSlot then
controls.includeTalisman = new("CheckBoxControl", {"TOPRIGHT",lastItemAnchor,"BOTTOMRIGHT"}, {0, 5, 18}, "Talisman Mods:", function(state) end)
controls.includeTalisman.state = (self.lastIncludeTalisman == nil or self.lastIncludeTalisman == true)
controls.includeTalisman = new("CheckBoxControl", { "TOPRIGHT", lastItemAnchor, "BOTTOMRIGHT" }, { 0, 5, 18 }, "Talisman Mods:", function(state) end, "Whether talisman enchant mods should be included. Disabled by default due to the maximum filter limit.")
controls.includeTalisman.state = not not self.lastIncludeTalisman
updateLastAnchor(controls.includeTalisman)
end

Expand Down
Loading
Loading