Skip to content
Closed
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
31 changes: 31 additions & 0 deletions spec/System/TestItemParse_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,37 @@ describe("TestItemParse", function()
assert.truthy(item.explicitModLines[1].exarch)
end)

it("removes Eldritch implicits when influence removed", function()
local eldritchRaw = table.concat({
"Searing Exarch Item",
"Eater of Worlds Item",
"Implicits: 2",
"{exarch}+8 to Strength",
"{eater}+9 to Dexterity",
}, "\n")
local item = new("Item", raw(eldritchRaw))
assert.are.equals(2, #item.implicitModLines)
assert.truthy(item.cleansing)
assert.truthy(item.tangle)

item:ResetInfluence()
item.tangle = true
item:BuildAndParseRaw()

assert.falsy(item.cleansing)
assert.truthy(item.tangle)
assert.are.equals(1, #item.implicitModLines)
assert.truthy(item.implicitModLines[1].eater)
assert.are.equals("+9 to Dexterity", item.implicitModLines[1].line)

item:ResetInfluence()
item:BuildAndParseRaw()

assert.falsy(item.cleansing)
assert.falsy(item.tangle)
assert.are.equals(0, #item.implicitModLines)
end)

it("fractured", function()
local item = new("Item", raw("{fractured}+8 to Strength"))
assert.truthy(item.explicitModLines[1].fractured)
Expand Down
25 changes: 24 additions & 1 deletion src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,19 @@ function ItemClass:BuildRaw()
if self.itemLevel then
t_insert(rawLines, "Item Level: " .. self.itemLevel)
end
local function shouldWriteModLine(modLine)
if modLine.exarch and not self.cleansing then
return false
end
if modLine.eater and not self.tangle then
return false
end
return true
end
local function writeModLine(modLine)
if not shouldWriteModLine(modLine) then
return
end
local line = modLine.line
if modLine.range and line:match("%(%-?[%d%.]+%-%-?[%d%.]+%)") then
line = "{range:" .. round(modLine.range, 3) .. "}" .. line
Expand Down Expand Up @@ -1142,7 +1154,18 @@ function ItemClass:BuildRaw()
if self.classRestriction then
t_insert(rawLines, "Requires Class " .. self.classRestriction)
end
t_insert(rawLines, "Implicits: " .. (#self.enchantModLines + #self.implicitModLines + #self.scourgeModLines))
local implicitLineCount = 0
local function countModLines(list)
for _, modLine in ipairs(list) do
if shouldWriteModLine(modLine) then
implicitLineCount = implicitLineCount + 1
end
end
end
countModLines(self.enchantModLines)
countModLines(self.scourgeModLines)
countModLines(self.implicitModLines)
t_insert(rawLines, "Implicits: " .. implicitLineCount)
for _, modLine in ipairs(self.enchantModLines) do
writeModLine(modLine)
end
Expand Down