From 6005df54ec5bd3a987392af6f671c04c01e330cc Mon Sep 17 00:00:00 2001 From: Casey Raethke Date: Wed, 27 Nov 2024 20:26:15 -0600 Subject: [PATCH] Add itemClass stat mod validator --- RatingBuster.lua | 5 +++-- libs/StatLogic/StatLogic.lua | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/RatingBuster.lua b/RatingBuster.lua index dc4f3d5..a89d900 100644 --- a/RatingBuster.lua +++ b/RatingBuster.lua @@ -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, }) --------------------- diff --git a/libs/StatLogic/StatLogic.lua b/libs/StatLogic/StatLogic.lua index 134c397..c32dea0 100644 --- a/libs/StatLogic/StatLogic.lua +++ b/libs/StatLogic/StatLogic.lua @@ -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) @@ -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 @@ -1360,6 +1370,7 @@ do self.profile, self.spec, self.level, + self.itemClass == Enum.ItemClass.Weapon and "w" or "n" }) end