Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions spec/System/TestItemParse_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,68 @@ describe("TestAdvancedItemParse #item", function()
assert.are.same(expectedLines, lines(item.explicitModLines))
end)

it("keeps different granted supports on a crafted item separate", function()
newBuild()
local item = new("Item"):Item([[
Rarity: RARE
Test Helmet
Hubris Circlet
Sockets: B
Crafted: true
Item Level: 85
Shaper Item
Elder Item
Implicits: 0]])
item.prefixes[1] = { modId = "AreaDamageSupportedUber1", range = 0.5 }
item.suffixes[1] = { modId = "IncreasedChillEffectSupportedUber2", range = 0.5 }
item:Craft()
item:Craft()

local expected = {
["Socketed Gems are Supported by Level 16 Concentrated Effect Support"] = true,
["Socketed Gems are Supported by Level 18 Hypothermia Support"] = true,
}
for _, mod in ipairs(item.explicitModLines) do
expected[mod.line] = nil
end
assert.are.same({ }, expected)

build.itemsTab:AddItem(item)
build.skillsTab:PasteSocketGroup("Slot: Helmet\nIce Nova 20/0 1\n")
runCallback("OnFrame")
local appliedSupports = { }
for _, effect in ipairs(build.calcsTab.mainEnv.player.mainSkill.effectList) do
if effect.grantedEffect.support then
appliedSupports[effect.grantedEffect.id] = effect.level
end
end
assert.are.same({ SupportConcentratedEffect = 16, SupportHypothermia = 18 }, appliedSupports)
end)

it("still combines crafted affixes that grant the same stat", function()
local item = new("Item"):Item([[
Rarity: RARE
Test Helmet
Eternal Burgonet
Crafted: true
Item Level: 85
Implicits: 0]])
item.prefixes[1] = { modId = "IncreasedLife7", range = 0.5 }
item.prefixes[2] = { modId = "LocalBaseArmourAndLife4", range = 0.5 }
item:Craft()
item:Craft()

local lifeLines = { }
for _, mod in ipairs(item.explicitModLines) do
if mod.line:match("to maximum Life$") then
table.insert(lifeLines, mod.line)
end
end
-- +(100-114) and +(34-38) to maximum Life at the middle of their ranges
assert.are.same({ "+143 to maximum Life" }, lifeLines)
assert.are.equals(143, item.baseModList:Sum("BASE", nil, "Life"))
end)

it("matches same-name affixes using their advanced-copy ranges", function()
local item = new("Item"):Item(raw([[
Item Level: 85
Expand Down
11 changes: 7 additions & 4 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,7 @@ function ItemClass:Craft()
self.namePrefix = ""
self.nameSuffix = ""
self.requirements.level = self.base.req.level
local statOrder = { }
local combinedLines = { }
for _, list in ipairs({ self.prefixes, self.suffixes }) do
for i = 1, (list.limit or (self.affixLimit / 2)) do
local affix = list[i]
Expand All @@ -2112,10 +2112,13 @@ function ItemClass:Craft()
for i, line in ipairs(mod) do
line = itemLib.applyRange(line, affix.range or 0.5)
local order = mod.statOrder[i]
if statOrder[order] then
-- Different stats can share a display order, such as granted supports.
local key = order .. ":" .. normaliseModLine(line)
local combined = combinedLines[key]
if combined then
-- Combine stats
local start = 1
statOrder[order].line = statOrder[order].line:gsub("%d+", function(num)
combined.line = combined.line:gsub("%d+", function(num)
local s, e, other = line:find("(%d+)", start)
start = e + 1
return tonumber(num) + tonumber(other)
Expand All @@ -2128,7 +2131,7 @@ function ItemClass:Craft()
modLine.suffix = true
end
t_insert(self.explicitModLines, modLine)
statOrder[order] = modLine
combinedLines[key] = modLine
end
end
end
Expand Down