diff --git a/spec/System/TestItemParse_spec.lua b/spec/System/TestItemParse_spec.lua index 15df122391c..4776abb3df8 100644 --- a/spec/System/TestItemParse_spec.lua +++ b/spec/System/TestItemParse_spec.lua @@ -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 diff --git a/src/Classes/Item.lua b/src/Classes/Item.lua index 01c44c0bb50..35c5c5dd2c5 100644 --- a/src/Classes/Item.lua +++ b/src/Classes/Item.lua @@ -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] @@ -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) @@ -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