Skip to content

Commit 50a8eb5

Browse files
committed
Buy similar: match timeless jewel mod
1 parent fca0497 commit 50a8eb5

3 files changed

Lines changed: 56 additions & 21 deletions

File tree

src/Classes/CompareBuySimilar.lua

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ local function buildURL(item, slotName, controls, modEntries, defenceEntries, is
131131
local filter = { id = entry.tradeId }
132132
if entry.options then
133133
filter.value = { option = entry.value }
134+
-- some entries don't want to search for ranges, but aren't
135+
-- implemented using options on the trade site (timeless jewels)
136+
elseif entry.needsExactValue then
137+
filter.value = { min = entry.value, max = entry.value }
134138
elseif entry.value then
135139
local minVal = tonumber(controls[prefix .. "Min"].buf)
140+
136141
local maxVal = tonumber(controls[prefix .. "Max"].buf)
137142
local value = {}
138143
if minVal then
@@ -213,25 +218,55 @@ function M.openPopup(item, slotName, primaryBuild)
213218
local formatted = itemLib.formatModLine(modLine)
214219
if formatted then
215220
-- Use range-resolved text for matching
216-
local resolvedLine = (modLine.range and itemLib.applyRange(modLine.line, modLine.range, modLine.valueScalar)) or modLine.line
217-
218-
local tradeHash, options, value = tradeHelpers.findTradeHash(item, resolvedLine, source.type)
219-
local identifier = tradeHash and string.format("%s.stat_%s", source.type, tradeHash)
220-
if not options then
221-
value = tradeHelpers.modLineValue(resolvedLine)
221+
local resolvedLine = (modLine.range and itemLib.applyRange(modLine.line, modLine.range, modLine.valueScalar)) or
222+
modLine.line
223+
224+
local timelessPatterns = { "bathed in the blood of %d+ sacrificed in the name of (.+)",
225+
"carved to glorify %d+ new faithful converted by high templar (.+)",
226+
"commanded leadership over %d+ warriors under (.+)",
227+
"commissioned %d+ coins to commemorate (.+)",
228+
"denoted service of %d+ dekhara in the akhara of (.+)",
229+
"remembrancing %d+ songworthy deeds by the line of (.+)" }
230+
local conquerorTradeId = nil
231+
for _, pat in ipairs(timelessPatterns) do
232+
local conqueror = resolvedLine:lower():match(pat)
233+
if conqueror then
234+
conquerorTradeId = "explicit.pseudo_timeless_jewel_" .. conqueror
235+
break
236+
end
222237
end
223238

224-
225-
t_insert(modEntries, {
226-
line = modLine.line,
227-
formatted = formatted,
228-
tradeId = identifier,
229-
value = value,
230-
options = options,
231-
modType = source.type,
232-
type = source.type,
233-
invert = tradeHelpers.shouldBeInverted(identifier, resolvedLine, source.type)
234-
})
239+
-- timeless jewels have a special trade id format based
240+
-- on the conqueror name, which doesn't use a hash
241+
if item.jewelData and item.jewelData.conqueredBy and conquerorTradeId then
242+
t_insert(modEntries, {
243+
line = modLine.line,
244+
formatted = formatted,
245+
tradeId = conquerorTradeId,
246+
value = item.jewelData.conqueredBy.id,
247+
-- it doesn't actually use options, but
248+
-- searching for ranges is useless here
249+
options = nil,
250+
needsExactValue = true,
251+
type = source.type,
252+
invert = false
253+
})
254+
else
255+
local tradeHash, options, value = tradeHelpers.findTradeHash(item, resolvedLine, source.type)
256+
local identifier = tradeHash and string.format("%s.stat_%s", source.type, tradeHash)
257+
if not options then
258+
value = tradeHelpers.modLineValue(resolvedLine)
259+
end
260+
t_insert(modEntries, {
261+
line = modLine.line,
262+
formatted = formatted,
263+
tradeId = identifier,
264+
value = value,
265+
options = options,
266+
type = source.type,
267+
invert = tradeHelpers.shouldBeInverted(identifier, resolvedLine, source.type)
268+
})
269+
end
235270
end
236271
end
237272
end
@@ -410,7 +445,7 @@ function M.openPopup(item, slotName, primaryBuild)
410445
displayText)
411446
-- when the trade site has a dropdown for the value, we opt to disable
412447
-- the inputs as they are numeric
413-
if not entry.options and entry.value then
448+
if not (entry.options or entry.needsExactValue) and entry.value then
414449
controls[prefix .. "Min"] = newPlainNumericEdit(nil, {minFieldX - popupWidth/2, ctrlY, fieldW, fieldH}, entry.value ~= 0 and tostring(m_floor(entry.value)) or "", "Min", 8)
415450
controls[prefix .. "Max"] = newPlainNumericEdit(nil, {maxFieldX - popupWidth/2, ctrlY, fieldW, fieldH}, "", "Max", 8)
416451
if not canSearch then

src/Classes/TradeHelpers.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ end
166166
function M.findTradeHash(item, modLine, modType)
167167
-- these mod results in false positives and are either useless, or
168168
-- effectively found by searching for the unique item's name
169-
if modLine == "Passage" or modLine == "Passive Skills in Radius can be Allocated without being connected to your tree" then
169+
if modLine == "Passage" or modLine == "Passive Skills in Radius can be Allocated without being connected to your tree" then
170170
return nil
171171
end
172172

@@ -175,7 +175,7 @@ function M.findTradeHash(item, modLine, modType)
175175
-- are technically just one stat. we handle that here
176176

177177
local isUnique = item.rarity == "UNIQUE" or item.rarity == "RELIC"
178-
function findStat(dbMod, ignoreWeights)
178+
local function findStat(dbMod, ignoreWeights)
179179
local excludeTags = (not isUnique) and { default = true } or nil
180180
-- cluster jewel mod weights are weird
181181
local isMatchingClusterMod = dbMod.group and dbMod.group:match("^Affliction") and

src/Data/TimelessJewelData/LegionTradeIds.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ return {
2525
},
2626
[4] = {
2727
keystone = {
28-
[1] = "explicit.pseudo_timeless_jewel_avarius",
28+
[1] = "explicit.pseudo_timeless_jewel_avarius",
2929
[2] = "explicit.pseudo_timeless_jewel_dominus",
3030
[3] = "explicit.pseudo_timeless_jewel_maxarius"
3131
},

0 commit comments

Comments
 (0)