Skip to content

Commit

Permalink
Add itemClass stat mod validator
Browse files Browse the repository at this point in the history
  • Loading branch information
raethkcj committed Nov 28, 2024
1 parent 38df027 commit 6005df5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions RatingBuster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2042,12 +2042,13 @@ function RatingBuster.ProcessTooltip(tooltip)

RatingBuster:EnableKeybindings(tooltip)

local itemMinLevel = select(5, C_Item.GetItemInfo(link))
local itemMinLevel, _, _, _, _, _, _, itemClass = select(5, C_Item.GetItemInfo(link))

local statModContext = StatLogic:NewStatModContext({
profile = db:GetCurrentProfile(),
spec = RatingBuster:GetDisplayedSpec(),
level = math.max(itemMinLevel, playerLevel)
level = math.max(itemMinLevel, playerLevel),
itemClass = itemClass,
})

---------------------
Expand Down
11 changes: 11 additions & 0 deletions libs/StatLogic/StatLogic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,15 @@ addon.StatModValidators = {
["GLYPH_REMOVED"] = true,
}
},
itemClass = {
validate = function(case, _, statModContext)
local itemClass = statModContext and statModContext.itemClass
return itemClass and case.itemClass[itemClass] or false
end,
events = {
["UNIT_INVENTORY_CHANGED"] = "player",
}
},
known = {
validate = function(case)
return not not FindSpellBookSlotBySpellID(case.known)
Expand Down Expand Up @@ -1341,6 +1350,7 @@ do
---@field profile? string
---@field spec? integer
---@field level? integer
---@field itemClass? Enum.ItemClass
---@field overrideStats? StatTable

-- Helper object for repeatedly calling GetStatMod for varying StatMods but consistent other parameters
Expand All @@ -1360,6 +1370,7 @@ do
self.profile,
self.spec,
self.level,
self.itemClass == Enum.ItemClass.Weapon and "w" or "n"
})
end

Expand Down

0 comments on commit 6005df5

Please sign in to comment.