Skip to content

Commit 5d6def3

Browse files
author
LocalIdentity
committed
Use code from ItemsTab + handle partial missing anoints
Moves the code to ItemsTab to use the existing anoint code there Now handles items like cowl of the thermophile and also Stranglegrasp not having all their possible anoints
1 parent 1ff904d commit 5d6def3

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

src/Classes/ItemsTab.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,18 @@ function ItemsTabClass:getAnoint(item)
23672367
return result
23682368
end
23692369

2370+
---Gets how many anoint slots are still missing on an item.
2371+
---@param item table @The item to inspect
2372+
---@return number @How many additional anoints can still be applied
2373+
function ItemsTabClass:getMissingAnointCount(item)
2374+
if not item or not item.base or not (item.canBeAnointed or item.base.type == "Amulet") then
2375+
return 0
2376+
end
2377+
local maxAnoints = item.canHaveFourEnchants and 4 or item.canHaveThreeEnchants and 3 or item.canHaveTwoEnchants and 2 or 1
2378+
local anointCount = #self:getAnoint(item)
2379+
return m_max(0, maxAnoints - m_min(anointCount, maxAnoints))
2380+
end
2381+
23702382
---Returns a copy of the currently displayed item, but anointed with a new node.
23712383
---Removes any existing enchantments before anointing. (Anoints are considered enchantments)
23722384
---@param node table @The passive tree node to anoint, or nil to just remove existing anoints.

src/Modules/CalcSetup.lua

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ local m_max = math.max
1414

1515
local tempTable1 = { }
1616

17-
local function isAnointableItem(item)
18-
return item and item.base and (item.canBeAnointed or item.base.type == "Amulet")
19-
end
20-
21-
local function itemHasAnoint(item)
22-
for _, modList in ipairs({ item.enchantModLines, item.scourgeModLines, item.implicitModLines, item.explicitModLines, item.crucibleModLines }) do
23-
for _, mod in ipairs(modList or {}) do
24-
if mod.line and mod.line:find("Allocates ", 1, true) then
25-
return true
26-
end
27-
end
28-
end
29-
return false
30-
end
31-
3217
-- Initialise modifier database with stats and conditions common to all actors
3318
function calcs.initModDB(env, modDB)
3419
modDB:NewMod("FireResistMax", "BASE", data.characterConstants["base_maximum_all_resistances_%"], "Base")
@@ -895,9 +880,14 @@ function calcs.initEnv(build, mode, override, specEnv)
895880

896881
for _, slot in ipairs(build.itemsTab.orderedSlots) do
897882
local item = items[slot.slotName]
898-
if isAnointableItem(item) and not itemHasAnoint(item) then
883+
local missingAnoints = build.itemsTab:getMissingAnointCount(item)
884+
if missingAnoints > 0 then
885+
local slotLabel = slot.label
886+
if missingAnoints > 1 then
887+
slotLabel = slotLabel .. " (" .. missingAnoints .. " missing)"
888+
end
899889
env.itemWarnings.missingAnointWarning = env.itemWarnings.missingAnointWarning or { }
900-
t_insert(env.itemWarnings.missingAnointWarning, slot.label)
890+
t_insert(env.itemWarnings.missingAnointWarning, slotLabel)
901891
end
902892
end
903893

0 commit comments

Comments
 (0)