Skip to content

Commit 812d87b

Browse files
committed
reuse canBeAnointed for Cord Belts and refactor isAnointed function for checks and persistence logic
1 parent 498330e commit 812d87b

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/Classes/Item.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
756756
self.prefixes.limit = (self.prefixes.limit or 0) + (tonumber(lineLower:match("%+(%d+) prefix modifiers? allowed")) or 0) - (tonumber(lineLower:match("%-(%d+) prefix modifiers? allowed")) or 0)
757757
elseif lineLower:match(" suffix modifiers? allowed") then
758758
self.suffixes.limit = (self.suffixes.limit or 0) + (tonumber(lineLower:match("%+(%d+) suffix modifiers? allowed")) or 0) - (tonumber(lineLower:match("%-(%d+) suffix modifiers? allowed")) or 0)
759-
elseif lineLower == "this item can be anointed by cassia" then
759+
elseif lineLower:find("can be anointed") then -- blight uniques and Cord Belt
760760
self.canBeAnointed = true
761761
elseif lineLower == "can have a second enchantment modifier" then
762762
self.canHaveTwoEnchants = true

src/Classes/ItemsTab.lua

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ for _, entry in pairs(data.flavourText) do
5656
end
5757
end
5858

59+
local function isAnointable(item)
60+
return (item.canBeAnointed or item.base.type == "Amulet")
61+
end
5962

6063
local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Control", function(self, build)
6164
self.UndoHandler()
@@ -439,11 +442,6 @@ holding Shift will put it in the second.]])
439442
return #self.displayItem.sockets < self.displayItem.selectableSocketCount + self.displayItem.abyssalSocketCount
440443
end
441444

442-
local function isAnointable()
443-
return (self.displayItem.canBeAnointed or
444-
self.displayItem.base.type == "Amulet" or
445-
self.displayItem.baseName:match("Cord Belt"))
446-
end
447445
-- Section: Enchant / Anoint / Corrupt
448446
self.controls.displayItemSectionEnchant = new("Control", {"TOPLEFT",self.controls.displayItemSectionSockets,"BOTTOMLEFT"}, {0, 0, 0, function()
449447
return (self.controls.displayItemEnchant:IsShown() or self.controls.displayItemEnchant2:IsShown() or self.controls.displayItemAnoint:IsShown() or self.controls.displayItemAnoint2:IsShown() or self.controls.displayItemCorrupt:IsShown() ) and 28 or 0
@@ -464,14 +462,14 @@ holding Shift will put it in the second.]])
464462
self:AnointDisplayItem(1)
465463
end)
466464
self.controls.displayItemAnoint.shown = function()
467-
return self.displayItem and isAnointable()
465+
return self.displayItem and isAnointable(self.displayItem)
468466
end
469467
self.controls.displayItemAnoint2 = new("ButtonControl", {"TOPLEFT",self.controls.displayItemAnoint,"TOPRIGHT",true}, {8, 0, 100, 20}, "Anoint 2...", function()
470468
self:AnointDisplayItem(2)
471469
end)
472470
self.controls.displayItemAnoint2.shown = function()
473471
return self.displayItem and
474-
isAnointable() and
472+
isAnointable(self.displayItem) and
475473
self.displayItem.canHaveTwoEnchants and
476474
#self.displayItem.enchantModLines > 0
477475
end
@@ -480,7 +478,7 @@ holding Shift will put it in the second.]])
480478
end)
481479
self.controls.displayItemAnoint3.shown = function()
482480
return self.displayItem and
483-
isAnointable() and
481+
isAnointable(self.displayItem) and
484482
self.displayItem.canHaveThreeEnchants and
485483
#self.displayItem.enchantModLines > 1
486484
end
@@ -489,7 +487,7 @@ holding Shift will put it in the second.]])
489487
end)
490488
self.controls.displayItemAnoint4.shown = function()
491489
return self.displayItem and
492-
isAnointable() and
490+
isAnointable(self.displayItem) and
493491
self.displayItem.canHaveFourEnchants and
494492
#self.displayItem.enchantModLines > 2
495493
end
@@ -1589,8 +1587,7 @@ function ItemsTabClass:CreateDisplayItemFromRaw(itemRaw, normalise)
15891587
if newItem.base then
15901588
local itemType = newItem.base.type
15911589
-- if the new item is anointable and does not have an anoint and your current respective item does, apply that anoint to the new item
1592-
if (itemType == "Amulet" or (itemType == "Belt" and newItem.baseName:match("Cord Belt")))
1593-
and #newItem.enchantModLines == 0 and self.activeItemSet[itemType].selItemId > 0 then
1590+
if isAnointable(newItem) and #newItem.enchantModLines == 0 and self.activeItemSet[itemType].selItemId > 0 then
15941591
local currentAnoint = self.items[self.activeItemSet[itemType].selItemId].enchantModLines
15951592
if currentAnoint and #currentAnoint == 1 then -- skip if amulet has more than one anoint e.g. Stranglegasp
15961593
newItem.enchantModLines = currentAnoint

0 commit comments

Comments
 (0)