Skip to content

Commit 1bddcdc

Browse files
committed
Fix QueryMods.lua generation. Change soulcores.lua to export trade hashes in a similar format as previous mod export changes.
1 parent edd0dc4 commit 1bddcdc

7 files changed

Lines changed: 711 additions & 7208 deletions

File tree

src/Classes/TradeQueryGenerator.lua

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,28 @@ function TradeQueryGeneratorClass.WeightedRatioOutputs(baseOutput, newOutput, st
183183
return meanStatDiff
184184
end
185185

186+
186187
function TradeQueryGeneratorClass:ProcessMod(mod, tradeQueryStatsParsed, itemCategoriesMask, itemCategoriesOverride)
187-
188-
for index, modLine in ipairs(mod) do
188+
-- processes mods from the data exports to a format that is more useful for
189+
-- generating weights.
190+
191+
-- this function generally uses the .tradeHashes field of each exported mod,
192+
-- which contains a map from the trade hash to the mod lines/stats
193+
194+
-- at a high level, this function matches each stat / mod line to an entry in
195+
-- https://www.pathofexile.com/api/trade2/data/stats via the trade hash. that
196+
-- entry is then used to determine if the mod is inverted, i.e. that the mod
197+
-- here is x increased by y, while the trade site has x decreased by -y. the
198+
-- function also records the minimum and maximum values of each stat, so we can
199+
-- later test for a midpoint of those values to generate a weight
200+
for tradeHash, modLines in pairs(mod.tradeHashes) do
201+
-- the mod export sometimes splits stats to multiple lines. they should
202+
-- still get parsed correctly if we combine them, and that makes it
203+
-- simpler to process them
204+
if not modLines then
205+
ConPrintf("")
206+
end
207+
local modLine = table.concat(modLines, " ")
189208
if modLine:find("Grants Level") or modLine:find("inflict Decay") then -- skip mods that grant skills / decay, as they will often be overwhelmingly powerful but don't actually fit into the build
190209
goto nextModLine
191210
end
@@ -214,8 +233,11 @@ function TradeQueryGeneratorClass:ProcessMod(mod, tradeQueryStatsParsed, itemCat
214233
-- iterate trade mod category to find mod with matching text.
215234
local function getTradeMod()
216235
local entry
217-
local tradeHashStr = tostring(mod.tradeHash)
236+
local tradeHashStr = tostring(tradeHash)
218237
for _, v in ipairs(tradeQueryStatsParsed.result[tradeStatCategoryIndices[modType]].entries) do
238+
if _ == 33 then
239+
ConPrintf("")
240+
end
219241
-- prefix removed
220242
local ids = v.id:gsub(".+..stat_", "").."|"
221243
-- split by non-integer
@@ -247,7 +269,7 @@ function TradeQueryGeneratorClass:ProcessMod(mod, tradeQueryStatsParsed, itemCat
247269
local tradeMod = nil
248270
local invert
249271

250-
local uniqueIndex = tostring(mod.tradeHash)
272+
local uniqueIndex = tostring(tradeHash)
251273

252274
if self.modData[modType][uniqueIndex] == nil then
253275
if tradeMod == nil then
@@ -306,7 +328,7 @@ function TradeQueryGeneratorClass:ProcessMod(mod, tradeQueryStatsParsed, itemCat
306328
end
307329

308330
if #tokens ~= 0 and #tokens ~= 2 and #tokens ~= 4 then
309-
logToFile("Unexpected # of tokens found for mod: %s", mod[index])
331+
logToFile("Unexpected # of tokens found for mod: %s", modLine)
310332
goto nextModLine
311333
end
312334

@@ -461,7 +483,7 @@ function TradeQueryGeneratorClass:InitMods()
461483
for name, runeMods in pairsSortByKey(data.itemMods.Runes) do
462484
for slotType, mods in pairs(runeMods) do
463485
for i, modLine in ipairs(mods) do
464-
local mod = {modLine, tradeHash = mods.tradeHashes[i], type = "Rune"}
486+
local mod = {modLine, tradeHashes = mods.tradeHashes, type = "Rune"}
465487
if slotType == "weapon" then
466488
self:ProcessMod(mod, tradeQueryStatsParsed, regularItemMask, { ["1HWeapon"] = true, ["2HWeapon"] = true, ["1HMace"] = true, ["Claw"] = true, ["Quarterstaff"] = true, ["Bow"] = true, ["2HMace"] = true, ["Crossbow"] = true, ["Spear"] = true, ["Flail"] = true, ["Talisman"] = true })
467489
elseif slotType == "armour" then
@@ -493,7 +515,16 @@ function TradeQueryGeneratorClass:InitMods()
493515
end
494516

495517
local queryModsFile = io.open(queryModFilePath, 'w')
496-
queryModsFile:write("-- This file is automatically generated, do not edit!\n-- Stat data (c) Grinding Gear Games\n\n")
518+
queryModsFile:write([[-- This file is automatically generated, do not edit!
519+
-- Stat data (c) Grinding Gear Games
520+
521+
-- This file contains categories of stats, mapped from trade hash to details
522+
-- relevant for generating search weights Note that the trade site requires a
523+
-- prefix of e.g. explicit.stat_{hash}. See
524+
-- https://www.pathofexile.com/api/trade2/data/stats for a list of all trade
525+
-- site stats.
526+
527+
]])
497528
queryModsFile:write("return " .. stringify(self.modData))
498529
queryModsFile:close()
499530
end

0 commit comments

Comments
 (0)