Skip to content

Commit e74031b

Browse files
committed
Add search pattern to compare items against the character's max slot item level
1 parent 3645667 commit e74031b

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Search/CheckItem.lua

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,63 @@ local function AvgItemLevelPatternCheck(details, text)
16201620
end
16211621
end
16221622

1623+
local inventorySlotIlvl = {}
1624+
1625+
local function UpdateInventorySlotIlvl(details)
1626+
GetInvType(details)
1627+
1628+
if details.invType == "NONE" or GetItemLevel(details) == false then return end
1629+
1630+
local slot = inventorySlots[details.invType]
1631+
inventorySlotIlvl[slot] = max(inventorySlotIlvl[slot] or 0, details.itemLevel)
1632+
end
1633+
1634+
Syndicator.CallbackRegistry:RegisterCallback("BagCacheUpdate", function (_, character, data)
1635+
for i=0,1 do
1636+
local key = i == 0 and "bags" or "bank"
1637+
local inventory = SYNDICATOR_DATA.Characters[character][key]
1638+
for index in pairs(data[key]) do
1639+
local list = Syndicator.Search.GetBaseInfoFromList(inventory[index + 1])
1640+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1641+
end
1642+
end
1643+
end)
1644+
1645+
Syndicator.CallbackRegistry:RegisterCallback("EquippedCacheUpdate", function(_, character)
1646+
local equipped = SYNDICATOR_DATA.Characters[character].equipped
1647+
local list = Syndicator.Search.GetBaseInfoFromList(equipped)
1648+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1649+
end)
1650+
1651+
local function SlotItemLevelPatternCheck(details, text)
1652+
GetInvType(details)
1653+
1654+
if details.invType == "NONE" or GetItemLevel(details) == false then
1655+
return false
1656+
end
1657+
1658+
local op1, op2, diff = text:match("^([<>=]?)slotilvl([+-]?)(%d*)$")
1659+
local ilvl = details.itemLevel
1660+
local slot = inventorySlots[details.invType]
1661+
1662+
local slotilvl = inventorySlotIlvl[slot]
1663+
if not slotilvl then
1664+
return false
1665+
end
1666+
1667+
if tonumber(diff) then
1668+
slotilvl = slotilvl + tonumber(diff) * (op2 == "-" and -1 or 1)
1669+
end
1670+
1671+
if op1 == "<" then
1672+
return ilvl < slotilvl
1673+
elseif op1 == ">" then
1674+
return ilvl > slotilvl
1675+
else
1676+
return ilvl == slotilvl
1677+
end
1678+
end
1679+
16231680
local function GetAuctionValue(details)
16241681
if details.auctionValue then
16251682
return details.auctionValue >= 0
@@ -1679,6 +1736,7 @@ local patterns = {
16791736
["^[><=]?%d+$"] = ItemLevelPatternCheck,
16801737
["^%d+%-%d+$"] = ItemLevelRangePatternCheck,
16811738
["^[><=]?avgilvl[+-]?%d*$"] = AvgItemLevelPatternCheck,
1739+
["^[><=]?slotilvl[+-]?%d*$"] = SlotItemLevelPatternCheck,
16821740

16831741
["^[><=]?%d+[gsc]$"] = AHValuePatternCheck,
16841742
["^%d+[gsc]%-%d+[gsc]$"] = AHValueRangePatternCheck,

0 commit comments

Comments
 (0)