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
5 changes: 4 additions & 1 deletion 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",

-- Range with plus sign that resolves exactly to zero
[{ "+(-1-1) to Maximum Power Charges", 0.5, 1.0 }] = "0 to Maximum Power Charges",
}

describe("TestItemTools", function()
Expand All @@ -45,4 +48,4 @@ describe("TestItemTools", function()
assert.are.equals(expected, result)
end)
end
end)
end)
4 changes: 2 additions & 2 deletions src/Modules/ItemTools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function itemLib.applyRange(line, range, valueScalar, baseValueScalar)
local strippedLine = line:gsub("([%+-]?)%((%-?%d+%.?%d*)%-(%-?%d+%.?%d*)%)", function(sign, min, max)
local value = min + range * (tonumber(max) - min)
if sign == "-" then value = value * -1 end
return (sign == "+" and value >= 0 ) and sign..tostring(value) or tostring(value)
return (sign == "+" and value > 0) and sign..tostring(value) or tostring(value)
end)
:gsub("%-(%d+%.?%d*%%) (%a+)", antonymFunc)
:gsub("(%-?%d+%.?%d*)", function(value)
Expand Down Expand Up @@ -366,4 +366,4 @@ itemLib.wiki = {
return key == itemLib.wiki.key
end,
triggered = false
}
}
Loading