Skip to content

Commit d543ed1

Browse files
github-actions[bot]mcagnionLocalIdentity
authored
[pob1-port] Fix Cord Belt anoint comparison tooltip (#1838)
* Apply changes from PathOfBuildingCommunity/PathOfBuilding#9826 * Fix logic --------- Co-authored-by: mcagnion <mcagnion@users.noreply.github.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 1073050 commit d543ed1

2 files changed

Lines changed: 54 additions & 4 deletions

File tree

spec/System/TestItemTools_spec.lua

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,53 @@ describe("TestItemTools", function()
5353
assert.are.equals(0.5, item.rangeLineList[1].range)
5454
assert.are.equals(0, item.baseModList:Sum("BASE", nil, "PowerChargesMax"))
5555
end)
56-
end)
56+
57+
it("uses the displayed item slot for anoint comparison tooltips", function()
58+
if not common.classes.ItemsTab then
59+
LoadModule("Classes/ItemsTab")
60+
end
61+
62+
local function assertAnointUsesSlot(rawItem, expectedSlot)
63+
local item = new("Item", rawItem)
64+
local overrides = { }
65+
local fakeItemsTab = setmetatable({
66+
displayItem = item,
67+
build = {
68+
spec = { allocNodes = { } },
69+
calcsTab = {
70+
GetMiscCalculator = function()
71+
return function(override)
72+
table.insert(overrides, override)
73+
return { }
74+
end
75+
end,
76+
},
77+
AddStatComparesToTooltip = function()
78+
return 1
79+
end,
80+
},
81+
}, common.classes.ItemsTab)
82+
local tooltip = {
83+
AddLine = function() end,
84+
}
85+
86+
fakeItemsTab:AppendAnointTooltip(tooltip, { id = 1, dn = "Abasement" })
87+
88+
assert.are.equals(expectedSlot, overrides[1].repSlotName)
89+
assert.are.equals(expectedSlot, overrides[2].repSlotName)
90+
end
91+
92+
assertAnointUsesSlot([[
93+
Rarity: Rare
94+
Dire Thread
95+
Plate Belt
96+
Can be Anointed
97+
]], "Belt")
98+
assertAnointUsesSlot([[
99+
Rarity: Rare
100+
Spark Loop
101+
Ruby Ring
102+
Can be Anointed
103+
]], "Ring 1")
104+
end)
105+
end)

src/Classes/ItemsTab.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,7 @@ function ItemsTabClass:anointItem(node)
22922292
return item
22932293
end
22942294

2295-
---Appends tooltip information for anointing a new passive tree node onto the currently editing amulet
2295+
---Appends tooltip information for anointing a new passive tree node onto the currently editing item
22962296
---@param tooltip table @The tooltip to append into
22972297
---@param node table @The passive tree node that will be anointed, or nil to remove the current anoint.
22982298
function ItemsTabClass:AppendAnointTooltip(tooltip, node, actionText)
@@ -2326,8 +2326,9 @@ function ItemsTabClass:AppendAnointTooltip(tooltip, node, actionText)
23262326
header = "^7"..actionText.." nothing will give you: "
23272327
end
23282328
local calcFunc = self.build.calcsTab:GetMiscCalculator()
2329-
local outputBase = calcFunc({ repSlotName = "Amulet", repItem = self.displayItem })
2330-
local outputNew = calcFunc({ repSlotName = "Amulet", repItem = self:anointItem(node) })
2329+
local repSlotName = self.displayItem:GetPrimarySlot()
2330+
local outputBase = calcFunc({ repSlotName = repSlotName, repItem = self.displayItem })
2331+
local outputNew = calcFunc({ repSlotName = repSlotName, repItem = self:anointItem(node) })
23312332
local numChanges = self.build:AddStatComparesToTooltip(tooltip, outputBase, outputNew, header)
23322333
if node and numChanges == 0 then
23332334
tooltip:AddLine(14, "^7"..actionText.." "..node.dn.." changes nothing.")

0 commit comments

Comments
 (0)