Skip to content

Commit f9e12c8

Browse files
committed
Fix radius jewels, charms, and desecrate-only mods in comparison trader
1 parent c96eff0 commit f9e12c8

4 files changed

Lines changed: 44 additions & 14 deletions

File tree

src/Classes/CompareBuySimilar.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ function M.openPopup(item, slotName, primaryBuild)
208208
for _, modLine in ipairs(source.list) do
209209
if item:CheckModLineVariant(modLine) then
210210
local formatted = itemLib.formatModLine(modLine)
211-
formatted = formatted and formatted:gsub(main.notSupportedTooltipText, "")
211+
formatted = formatted and formatted:gsub(" %^8%(Not supported in PoB yet%)", "")
212212
if formatted then
213213
-- Use range-resolved text for matching
214214
local resolvedLine = (modLine.range and itemLib.applyRange(modLine.line, modLine.range, modLine.valueScalar)) or modLine.line
215-
local tradeHash = tradeHelpers.findTradeHash(item, resolvedLine, source.type)
215+
local tradeHash = tradeHelpers.findTradeHash(item, resolvedLine, source.type, modLine.desecrated)
216216
local identifier = tradeHash and string.format("%s.stat_%s", source.type, tradeHash)
217217
local value = tradeHelpers.modLineValue(resolvedLine)
218218
t_insert(modEntries, {

src/Classes/CompareTab.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,7 +2358,7 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
23582358
end
23592359
end
23602360
if categories.items then
2361-
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
2361+
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Charm 1", "Charm 2", "Charm 3" }
23622362
if self:ShouldShowRing3(compareEntry) then
23632363
t_insert(baseSlots, 10, "Ring 3")
23642364
end
@@ -2522,7 +2522,7 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
25222522
-- Items
25232523
-- ==========================================
25242524
if categories.items then
2525-
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
2525+
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Charm 1", "Charm 2", "Charm 3" }
25262526
if self:ShouldShowRing3(compareEntry) then
25272527
t_insert(baseSlots, 10, "Ring 3")
25282528
end
@@ -3421,7 +3421,7 @@ function CompareTabClass:ShouldShowRing3(compareEntry)
34213421
end
34223422

34233423
function CompareTabClass:DrawItems(vp, compareEntry, inputEvents)
3424-
local baseSlots = { "Weapon 1", "Weapon 2", "Weapon 1 Swap", "Weapon 2 Swap", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
3424+
local baseSlots = { "Weapon 1", "Weapon 2", "Weapon 1 Swap", "Weapon 2 Swap", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Charm 1", "Charm 2", "Charm 3" }
34253425
if self:ShouldShowRing3(compareEntry) then
34263426
t_insert(baseSlots, 12, "Ring 3")
34273427
end

src/Classes/CompareTradeHelpers.lua

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
8794
end
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
132161
end
133162
-- Map slot name + item type to (trade API category string, itemCategoryTags key).
134163
-- queryStr: e.g. "armour.shield", "weapon.onemace"

src/Modules/Data.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ data.itemMods = {
622622
Jewel = LoadModule("Data/ModJewel"),
623623
Corruption = LoadModule("Data/ModCorrupted"),
624624
Runes = LoadModule("Data/ModRunes"),
625-
Exclusive = LoadModule("Data/ModItemExclusive")
625+
Exclusive = LoadModule("Data/ModItemExclusive"),
626+
Desecrated = LoadModule("Data/ModVeiled")
626627
}
627628

628629
-- update JewelRadius affixes for Time-Lost jewels

0 commit comments

Comments
 (0)