Skip to content

Commit 8ea193d

Browse files
OursCodeurLocalIdentity
andauthored
Add warning for eligible items missing an anoint (#9727)
* Add warning for eligible items missing an anoint * 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 --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent ddd0a0b commit 8ea193d

3 files changed

Lines changed: 28 additions & 0 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/Build.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,9 @@ function buildMode:InsertItemWarnings()
17011701
InsertIfNew(self.controls.warnings.lines, "You have too many gems in your "..warning.." slot")
17021702
end
17031703
end
1704+
if self.calcsTab.mainEnv.itemWarnings.missingAnointWarning then
1705+
InsertIfNew(self.controls.warnings.lines, "You have eligible items missing an anoint: "..table.concat(self.calcsTab.mainEnv.itemWarnings.missingAnointWarning, ", "))
1706+
end
17041707
end
17051708

17061709
-- Build list of side bar stats

src/Modules/CalcSetup.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,19 @@ function calcs.initEnv(build, mode, override, specEnv)
878878
end
879879
end
880880

881+
for _, slot in ipairs(build.itemsTab.orderedSlots) do
882+
local item = items[slot.slotName]
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
889+
env.itemWarnings.missingAnointWarning = env.itemWarnings.missingAnointWarning or { }
890+
t_insert(env.itemWarnings.missingAnointWarning, slotLabel)
891+
end
892+
end
893+
881894
-- Track which flask slot (1-5) each flask is in, for adjacency checks
882895
env.flaskSlotMap = { }
883896
env.flaskSlotOccupied = { }

0 commit comments

Comments
 (0)