Skip to content
Merged
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
13 changes: 13 additions & 0 deletions spec/System/TestItemTools_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ local applyRangeTests = {
[{ "+(-25-50)% to Fire Resistance", 1.0, 1.5 }] = "+75% to Fire Resistance",
[{ "+(-25-50)% to Fire Resistance", 0.0, 1.0 }] = "-25% to Fire Resistance",
[{ "+(-25-50)% to Fire Resistance", 0.0, 1.5 }] = "-37% to Fire Resistance",
-- Fallback scaling
[{ "+(10-20) to unsupported value", 1.0, 1.0, 1.22 }] = "+24 to unsupported value",
[{ "+(10-20) to unsupported value", 1.0, 1.5, 1.22 }] = "+36 to unsupported value",
}

describe("TestItemTools", function()
Expand All @@ -46,6 +49,16 @@ describe("TestItemTools", function()
end)
end

it("detects scalability after resolving ranges", function()
assert.is_true(itemLib.isModLineScalable("+(10-20) to maximum Life", 1, 1))
assert.is_false(itemLib.isModLineScalable("Your Maximum Resistances are (76-80)%", 1, 1))
end)

it("formats corrupted fixed-value modifiers", function()
local modLine = { line = "Adds 1 to 59 Chaos Damage", corruptedRange = 1.22 }
assert.are.equals(colorCodes.MAGIC .. "Adds 1 to 72 Chaos Damage", itemLib.formatModLine(modLine))
end)

it("uses the displayed item slot for anoint comparison tooltips", function()
if not common.classes.ItemsTab then
LoadModule("Classes/ItemsTab")
Expand Down
1 change: 1 addition & 0 deletions src/Classes/Control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local rect = {
local ControlClass = newClass("Control", function(self, anchor, rect)
self.rectStart = rect or {0, 0, 0, 0}
self.x, self.y, self.width, self.height = unpack(self.rectStart)
---@type (fun(): boolean) | boolean
self.shown = true
self.enabled = true
self.anchor = { }
Expand Down
11 changes: 8 additions & 3 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
end
elseif k == "range" then
modLine.range = tonumber(val)
elseif k == "corruptedRange" then
modLine.corruptedRange = tonumber(val)
elseif lineFlags[k] then
modLine[k] = true
end
Expand Down Expand Up @@ -888,13 +890,13 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
modLine.range = bestPrecisionRange
end
end
local rangedLine = itemLib.applyRange(line, 1, catalystScalar)
local rangedLine = itemLib.applyRange(line, 1, catalystScalar, modLine.corruptedRange)
local modList, extra = modLib.parseMod(rangedLine)
if (not modList or extra) and self.rawLines[l+1] then
-- Try to combine it with the next line
local nextLine = self.rawLines[l+1]:gsub("%b{}", ""):gsub(" ?%(%l+%)","")
local combLine = line.." "..nextLine
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar)
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar, modLine.corruptedRange)
modList, extra = modLib.parseMod(rangedLine, true)
if modList and not extra then
line = line.."\n"..nextLine
Expand Down Expand Up @@ -1262,6 +1264,9 @@ function ItemClass:BuildRaw()
if modLine.range and line:match("%(%-?[%d%.]+%-%-?[%d%.]+%)") then
line = "{range:" .. round(modLine.range, 3) .. "}" .. line
end
if modLine.corruptedRange then
line = "{corruptedRange:" .. round(modLine.corruptedRange, 2) .. "}" .. line
end
if modLine.crafted then
line = "{crafted}" .. line
end
Expand Down Expand Up @@ -1863,7 +1868,7 @@ function ItemClass:BuildModList()
local strippedModeLine = modLine.line:gsub("\n"," ")
local catalystScalar = getCatalystScalar(self.catalyst, modLine, self.catalystQuality)
-- Put the modified value into the string
local line = itemLib.applyRange(strippedModeLine, modLine.range, catalystScalar)
local line = itemLib.applyRange(strippedModeLine, modLine.range, catalystScalar, modLine.corruptedRange)
-- Check if we can parse it before adding the mods
local list, extra = modLib.parseMod(line)
if list and not extra then
Expand Down
Loading
Loading