From 4d13e649e7b1fdd70c44e8098d923580dfd50943 Mon Sep 17 00:00:00 2001 From: mcagnion Date: Tue, 12 May 2026 07:12:28 +0000 Subject: [PATCH 1/2] Apply changes from https://github.com/PathOfBuildingCommunity/PathOfBuilding/pull/9826 --- spec/System/TestItemTools_spec.lua | 40 +++++++++++++++++++++++++++++- src/Classes/ItemsTab.lua | 7 +++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/spec/System/TestItemTools_spec.lua b/spec/System/TestItemTools_spec.lua index ab7c6785e0..40224f2627 100644 --- a/spec/System/TestItemTools_spec.lua +++ b/spec/System/TestItemTools_spec.lua @@ -45,4 +45,42 @@ describe("TestItemTools", function() assert.are.equals(expected, result) end) 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 item = new("Item", [[ +Rarity: Rare +Dire Thread +Cord Belt +Can be Anointed +]]) + 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 = "Acrimony" }) + + assert.are.equals("Belt", overrides[1].repSlotName) + assert.are.equals("Belt", overrides[2].repSlotName) + end) +end) diff --git a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua index 40ef39e37e..a50bc0e613 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -2261,7 +2261,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) @@ -2295,8 +2295,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.base and self.displayItem.base.type or "Amulet" + 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.") From 3a03f6cf31298c401445f125d5a9f17bb15d1388 Mon Sep 17 00:00:00 2001 From: LocalIdentity Date: Mon, 25 May 2026 22:19:48 +1000 Subject: [PATCH 2/2] Fix logic --- spec/System/TestItemTools_spec.lua | 67 +++++++++++++++++------------- src/Classes/ItemsTab.lua | 2 +- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/spec/System/TestItemTools_spec.lua b/spec/System/TestItemTools_spec.lua index b1205eda30..fdcb21f4b7 100644 --- a/spec/System/TestItemTools_spec.lua +++ b/spec/System/TestItemTools_spec.lua @@ -58,37 +58,48 @@ describe("TestItemTools", function() if not common.classes.ItemsTab then LoadModule("Classes/ItemsTab") end - local item = new("Item", [[ - Rarity: Rare - Dire Thread - Plate Belt - Can be Anointed - ]]) - local overrides = { } - local fakeItemsTab = setmetatable({ - displayItem = item, - build = { - spec = { allocNodes = { } }, - calcsTab = { - GetMiscCalculator = function() - return function(override) - table.insert(overrides, override) - return { } - 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, }, - AddStatComparesToTooltip = function() - return 1 - end, - }, - }, common.classes.ItemsTab) - local tooltip = { - AddLine = function() end, - } + }, common.classes.ItemsTab) + local tooltip = { + AddLine = function() end, + } + + fakeItemsTab:AppendAnointTooltip(tooltip, { id = 1, dn = "Abasement" }) - fakeItemsTab:AppendAnointTooltip(tooltip, { id = 1, dn = "Abasement" }) + assert.are.equals(expectedSlot, overrides[1].repSlotName) + assert.are.equals(expectedSlot, overrides[2].repSlotName) + end - assert.are.equals("Belt", overrides[1].repSlotName) - assert.are.equals("Belt", overrides[2].repSlotName) + 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 58b8ca7bb6..e04d0bd0cd 100644 --- a/src/Classes/ItemsTab.lua +++ b/src/Classes/ItemsTab.lua @@ -2326,7 +2326,7 @@ function ItemsTabClass:AppendAnointTooltip(tooltip, node, actionText) header = "^7"..actionText.." nothing will give you: " end local calcFunc = self.build.calcsTab:GetMiscCalculator() - local repSlotName = self.displayItem.base and self.displayItem.base.type or "Amulet" + 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)