@@ -64,12 +64,15 @@ function M.shouldBeInverted(tradeId, modLine, modType)
6464 if category .id == modType then
6565 for _ , stat in ipairs (category .entries ) do
6666 if tradeId == stat .id then
67- -- local modifiers don't seem to be inverted
68- if stat .text :match (" (Local)" ) then
67+ -- remove radius jewel extra text
68+ local formattedTradeSiteText = M .formatDatabaseText (stat .text )
69+ -- local modifiers don't seem to be inverted. same goes for
70+ -- the single stat that has (charm) in it
71+ if formattedTradeSiteText :match (" (Local)" ) or formattedTradeSiteText :match (" %(Charm%)$" ) then
6972 return false
7073 end
7174 -- trade site sometimes has a + sign, sometimes not
72- return not (formattedLine == stat . text or formattedLine :gsub (" ^%+" , " " ) == stat . text )
75+ return not (formattedLine == formattedTradeSiteText or formattedLine :gsub (" ^%+" , " " ) == formattedTradeSiteText )
7376 end
7477 end
7578 end
@@ -83,16 +86,21 @@ function M.formatDatabaseText(text)
8386 -- (123-124) -> #
8487 text = text :gsub (" %(%d+%-%d+%)" , " #" )
8588 text = text :gsub (" %d+" , " #" )
89+ -- remove radius jewel text. the same description is used for regular and
90+ -- radius jewels in the exports
91+ text = text :gsub (" ^Notable Passive Skills in Radius also grant " , " " )
92+ text = text :gsub (" ^Small Passive Skills in Radius also grant " , " " )
8693 return text
8794end
8895
8996-- Helper: find the trade stat ID for a mod line
90- function M .findTradeHash (item , modLine , modType )
97+ function M .findTradeHash (item , modLine , modType , isDesecrated )
9198 local formattedLine = M .formatDatabaseText (modLine )
9299 -- the data export splits some mods into different parts, even though they
93100 -- are technically just one stat. we handle that here
94- function findStat (dbMod )
95- if not item :GetModSpawnWeight (dbMod , nil , { default = true }) then
101+ function findStat (dbMod , allowDefault )
102+ local excludeTags = (not allowDefault ) and { default = true } or nil
103+ if # dbMod .weightKey > 0 and not (item :GetModSpawnWeight (dbMod , nil , excludeTags ) > 0 ) then
96104 return nil
97105 end
98106 for tradeHash , description in pairs (dbMod .tradeHashes ) do
@@ -115,7 +123,9 @@ function M.findTradeHash(item, modLine, modType)
115123 end
116124 -- explicit
117125 elseif modType ~= " implicit" then
118- for _ , dbMod in pairs (data .itemMods .Item ) do
126+ local modList = (item .base and item .base .type == " Jewel" and data .itemMods .Jewel )
127+ or data .itemMods .Item
128+ for _ , dbMod in pairs (modList ) do
119129 local tradeHashMaybe = findStat (dbMod )
120130 if tradeHashMaybe then
121131 return tradeHashMaybe
@@ -124,11 +134,30 @@ function M.findTradeHash(item, modLine, modType)
124134 end
125135 -- implicit, and special explicit (e.g. unique and essence)
126136 for _ , dbMod in pairs (data .itemMods .Exclusive ) do
127- local tradeHashMaybe = findStat (dbMod )
137+ local tradeHashMaybe = findStat (dbMod , true )
128138 if tradeHashMaybe then
129139 return tradeHashMaybe
130140 end
131141 end
142+ -- desecrated mods (some of these are unique)
143+ if isDesecrated then
144+ for _ , dbMod in pairs (data .itemMods .Desecrated ) do
145+ local tradeHashMaybe = findStat (dbMod )
146+ if tradeHashMaybe then
147+ return tradeHashMaybe
148+ end
149+ end
150+ end
151+ -- charm mods
152+ if item .base and item .base .type == " Charm" then
153+ for _ , dbMod in pairs (data .itemMods .Charm ) do
154+ -- charms don't seem to have any spawn weights, so allow the default tag here
155+ local tradeHashMaybe = findStat (dbMod , true )
156+ if tradeHashMaybe then
157+ return tradeHashMaybe
158+ end
159+ end
160+ end
132161end
133162-- Map slot name + item type to (trade API category string, itemCategoryTags key).
134163-- queryStr: e.g. "armour.shield", "weapon.onemace"
0 commit comments