Fix catalyst scaling bug. (#4603)

This commit is contained in:
QuickStick
2022-07-18 13:28:54 +10:00
committed by GitHub
parent 40fc4e929a
commit 37c3f70574
2 changed files with 7 additions and 12 deletions

View File

@@ -468,22 +468,13 @@ function ItemClass:ParseRaw(raw)
end
line = line:gsub("%b{}", ""):gsub(" %(fractured%)",""):gsub(" %(crafted%)",""):gsub(" %(implicit%)",""):gsub(" %(enchant%)",""):gsub(" %(scourge%)","")
local catalystScalar = getCatalystScalar(self.catalyst, modTags, self.catalystQuality)
local rangedLine
if line:match("%(%d+%-%d+ to %d+%-%d+%)") or line:match("%(%-?[%d%.]+ to %-?[%d%.]+%)") or line:match("%(%-?[%d%.]+%-[%d%.]+%)") then
rangedLine = itemLib.applyRange(line, 1, catalystScalar)
elseif catalystScalar ~= 1 then
rangedLine = itemLib.applyValueScalar(line, catalystScalar, 1)
end
local rangedLine = itemLib.applyRange(line, 1, catalystScalar)
local modList, extra = modLib.parseMod(rangedLine or line)
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(" ?%(fractured%)",""):gsub(" ?%(crafted%)",""):gsub(" ?%(implicit%)",""):gsub(" ?%(enchant%)",""):gsub(" ?%(scourge%)","")
local combLine = line.." "..nextLine
if combLine:match("%(%d+%-%d+ to %d+%-%d+%)") or combLine:match("%(%-?[%d%.]+ to %-?[%d%.]+%)") or combLine:match("%(%-?[%d%.]+%-[%d%.]+%)") then
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar)
elseif catalystScalar ~= 1 then
rangedLine = itemLib.applyValueScalar(combLine, catalystScalar, 1)
end
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar)
modList, extra = modLib.parseMod(rangedLine or combLine, true)
if modList and not extra then
line = line.."\n"..nextLine

View File

@@ -66,7 +66,7 @@ end
-- Apply range value (0 to 1) to a modifier that has a range: (x to x) or (x-x to x-x)
function itemLib.applyRange(line, range, valueScalar)
numbers = 0
local numbers = 0
line = line:gsub("%((%d+)%-(%d+) to (%d+)%-(%d+)%)", "(%1-%2) to (%3-%4)")
:gsub("(%+?)%((%-?%d+) to (%d+)%)", "%1(%2-%3)")
:gsub("(%+?)%((%-?%d+)%-(%d+)%)",
@@ -87,6 +87,10 @@ function itemLib.applyRange(line, range, valueScalar)
return tostring(numVal)
end)
:gsub("%-(%d+%%) increased", function(num) return num.." reduced" end)
:gsub("%-(%d+%%) more", function(num) return num.." less" end)
if numbers == 0 and line:match("(%d+)%%? ") then --If a mod contains x or x% and is not already a ranged value, then only the first number will be scalable as any following numbers will always be conditions or unscalable values.
numbers = 1
end
return itemLib.applyValueScalar(line, valueScalar, numbers)
end