diff --git a/spec/System/TestItemTools_spec.lua b/spec/System/TestItemTools_spec.lua index 50303879d5..fdcb21f4b7 100644 --- a/spec/System/TestItemTools_spec.lua +++ b/spec/System/TestItemTools_spec.lua @@ -53,4 +53,53 @@ describe("TestItemTools", function() assert.are.equals(0.5, item.rangeLineList[1].range) assert.are.equals(0, item.baseModList:Sum("BASE", nil, "PowerChargesMax")) end) -end) \ No newline at end of file + + it("uses the displayed item slot for anoint comparison tooltips", function() + if not common.classes.ItemsTab then + LoadModule("Classes/ItemsTab") + end + + local function assertAnointUsesSlot(rawItem, expectedSlot) + local item = new("Item", rawItem) + local overrides = { } + local fakeItemsTab = setmetatable({ + displayItem = item, + build = { + spec = { allocNodes = { } }, + calcsTab = { + GetMiscCalculator = function() + return function(override) + table.insert(overrides, override) + return { } + end + end, + }, + AddStatComparesToTooltip = function() + return 1 + end, + }, + }, common.classes.ItemsTab) + local tooltip = { + AddLine = function() end, + } + + fakeItemsTab:AppendAnointTooltip(tooltip, { id = 1, dn = "Abasement" }) + + assert.are.equals(expectedSlot, overrides[1].repSlotName) + assert.are.equals(expectedSlot, overrides[2].repSlotName) + end + + assertAnointUsesSlot([[ + Rarity: Rare + Dire Thread + Plate Belt + Can be Anointed + ]], "Belt") + assertAnointUsesSlot([[ + Rarity: Rare + Spark Loop + Ruby Ring + Can be Anointed + ]], "Ring 1") + end) +end) diff --git a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua index 5e8e323922..e04d0bd0cd 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -2292,7 +2292,7 @@ function ItemsTabClass:anointItem(node) return item end ----Appends tooltip information for anointing a new passive tree node onto the currently editing amulet +---Appends tooltip information for anointing a new passive tree node onto the currently editing item ---@param tooltip table @The tooltip to append into ---@param node table @The passive tree node that will be anointed, or nil to remove the current anoint. function ItemsTabClass:AppendAnointTooltip(tooltip, node, actionText) @@ -2326,8 +2326,9 @@ function ItemsTabClass:AppendAnointTooltip(tooltip, node, actionText) header = "^7"..actionText.." nothing will give you: " end local calcFunc = self.build.calcsTab:GetMiscCalculator() - local outputBase = calcFunc({ repSlotName = "Amulet", repItem = self.displayItem }) - local outputNew = calcFunc({ repSlotName = "Amulet", repItem = self:anointItem(node) }) + local repSlotName = self.displayItem:GetPrimarySlot() + local outputBase = calcFunc({ repSlotName = repSlotName, repItem = self.displayItem }) + local outputNew = calcFunc({ repSlotName = repSlotName, repItem = self:anointItem(node) }) local numChanges = self.build:AddStatComparesToTooltip(tooltip, outputBase, outputNew, header) if node and numChanges == 0 then tooltip:AddLine(14, "^7"..actionText.." "..node.dn.." changes nothing.")