Skip to content

Commit b438877

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

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
@@ -1651,6 +1651,63 @@ local function AvgItemLevelPatternCheck(details, text)
16511651
end
16521652
end
16531653

1654+
local inventorySlotIlvl = {}
1655+
1656+
local function UpdateInventorySlotIlvl(details)
1657+
GetInvType(details)
1658+
1659+
if details.invType == "NONE" or GetItemLevel(details) == false then return end
1660+
1661+
local slot = inventorySlots[details.invType]
1662+
inventorySlotIlvl[slot] = max(inventorySlotIlvl[slot] or 0, details.itemLevel)
1663+
end
1664+
1665+
Syndicator.CallbackRegistry:RegisterCallback("BagCacheUpdate", function (_, character, data)
1666+
for i=0,1 do
1667+
local key = i == 0 and "bags" or "bank"
1668+
local inventory = SYNDICATOR_DATA.Characters[character][key]
1669+
for index in pairs(data[key]) do
1670+
local list = Syndicator.Search.GetBaseInfoFromList(inventory[index + 1])
1671+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1672+
end
1673+
end
1674+
end)
1675+
1676+
Syndicator.CallbackRegistry:RegisterCallback("EquippedCacheUpdate", function(_, character)
1677+
local equipped = SYNDICATOR_DATA.Characters[character].equipped
1678+
local list = Syndicator.Search.GetBaseInfoFromList(equipped)
1679+
for _, details in pairs(list) do UpdateInventorySlotIlvl(details) end
1680+
end)
1681+
1682+
local function SlotItemLevelPatternCheck(details, text)
1683+
GetInvType(details)
1684+
1685+
if details.invType == "NONE" or GetItemLevel(details) == false then
1686+
return false
1687+
end
1688+
1689+
local op1, op2, diff = text:match("^([<>=]?)slotilvl([+-]?)(%d*)$")
1690+
local ilvl = details.itemLevel
1691+
local slot = inventorySlots[details.invType]
1692+
1693+
local slotilvl = inventorySlotIlvl[slot]
1694+
if not slotilvl then
1695+
return false
1696+
end
1697+
1698+
if tonumber(diff) then
1699+
slotilvl = slotilvl + tonumber(diff) * (op2 == "-" and -1 or 1)
1700+
end
1701+
1702+
if op1 == "<" then
1703+
return ilvl < slotilvl
1704+
elseif op1 == ">" then
1705+
return ilvl > slotilvl
1706+
else
1707+
return ilvl == slotilvl
1708+
end
1709+
end
1710+
16541711
local function GetAuctionValue(details)
16551712
if details.auctionValue then
16561713
return details.auctionValue >= 0
@@ -1710,6 +1767,7 @@ local patterns = {
17101767
["^[><=]?%d+$"] = ItemLevelPatternCheck,
17111768
["^%d+%-%d+$"] = ItemLevelRangePatternCheck,
17121769
["^[><=]?avgilvl[+-]?%d*$"] = AvgItemLevelPatternCheck,
1770+
["^[><=]?slotilvl[+-]?%d*$"] = SlotItemLevelPatternCheck,
17131771

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

0 commit comments

Comments
 (0)