Skip to content

Commit 8226226

Browse files
vaisestLocalIdentity
andauthored
Port Volatile Vaal Orb support (#9935)
* Port Volatile Vaal Orb support * Fix scourge dropdowns not omitting selected value * Various fixes Corrected fallback scalar argument handling. Preserved existing volatile rolls when editing implicits. Correctly filters unscalable ranged modifiers. Displays scaled fixed-value modifiers correctly. Consolidated duplicated label and implicit-control logic. Found and fixed an additional tab-state bug for items whose implicits cannot be changed. --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent c225a6c commit 8226226

11 files changed

Lines changed: 15701 additions & 260 deletions

File tree

spec/System/TestItemTools_spec.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ local applyRangeTests = {
3636
[{ "+(-25-50)% to Fire Resistance", 1.0, 1.5 }] = "+75% to Fire Resistance",
3737
[{ "+(-25-50)% to Fire Resistance", 0.0, 1.0 }] = "-25% to Fire Resistance",
3838
[{ "+(-25-50)% to Fire Resistance", 0.0, 1.5 }] = "-37% to Fire Resistance",
39+
-- Fallback scaling
40+
[{ "+(10-20) to unsupported value", 1.0, 1.0, 1.22 }] = "+24 to unsupported value",
41+
[{ "+(10-20) to unsupported value", 1.0, 1.5, 1.22 }] = "+36 to unsupported value",
3942
}
4043

4144
describe("TestItemTools", function()
@@ -46,6 +49,16 @@ describe("TestItemTools", function()
4649
end)
4750
end
4851

52+
it("detects scalability after resolving ranges", function()
53+
assert.is_true(itemLib.isModLineScalable("+(10-20) to maximum Life", 1, 1))
54+
assert.is_false(itemLib.isModLineScalable("Your Maximum Resistances are (76-80)%", 1, 1))
55+
end)
56+
57+
it("formats corrupted fixed-value modifiers", function()
58+
local modLine = { line = "Adds 1 to 59 Chaos Damage", corruptedRange = 1.22 }
59+
assert.are.equals(colorCodes.MAGIC .. "Adds 1 to 72 Chaos Damage", itemLib.formatModLine(modLine))
60+
end)
61+
4962
it("uses the displayed item slot for anoint comparison tooltips", function()
5063
if not common.classes.ItemsTab then
5164
LoadModule("Classes/ItemsTab")

src/Classes/Control.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ local rect = {
3535
local ControlClass = newClass("Control", function(self, anchor, rect)
3636
self.rectStart = rect or {0, 0, 0, 0}
3737
self.x, self.y, self.width, self.height = unpack(self.rectStart)
38+
---@type (fun(): boolean) | boolean
3839
self.shown = true
3940
self.enabled = true
4041
self.anchor = { }

src/Classes/Item.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
697697
end
698698
elseif k == "range" then
699699
modLine.range = tonumber(val)
700+
elseif k == "corruptedRange" then
701+
modLine.corruptedRange = tonumber(val)
700702
elseif lineFlags[k] then
701703
modLine[k] = true
702704
end
@@ -888,13 +890,13 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
888890
modLine.range = bestPrecisionRange
889891
end
890892
end
891-
local rangedLine = itemLib.applyRange(line, 1, catalystScalar)
893+
local rangedLine = itemLib.applyRange(line, 1, catalystScalar, modLine.corruptedRange)
892894
local modList, extra = modLib.parseMod(rangedLine)
893895
if (not modList or extra) and self.rawLines[l+1] then
894896
-- Try to combine it with the next line
895897
local nextLine = self.rawLines[l+1]:gsub("%b{}", ""):gsub(" ?%(%l+%)","")
896898
local combLine = line.." "..nextLine
897-
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar)
899+
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar, modLine.corruptedRange)
898900
modList, extra = modLib.parseMod(rangedLine, true)
899901
if modList and not extra then
900902
line = line.."\n"..nextLine
@@ -1262,6 +1264,9 @@ function ItemClass:BuildRaw()
12621264
if modLine.range and line:match("%(%-?[%d%.]+%-%-?[%d%.]+%)") then
12631265
line = "{range:" .. round(modLine.range, 3) .. "}" .. line
12641266
end
1267+
if modLine.corruptedRange then
1268+
line = "{corruptedRange:" .. round(modLine.corruptedRange, 2) .. "}" .. line
1269+
end
12651270
if modLine.crafted then
12661271
line = "{crafted}" .. line
12671272
end
@@ -1863,7 +1868,7 @@ function ItemClass:BuildModList()
18631868
local strippedModeLine = modLine.line:gsub("\n"," ")
18641869
local catalystScalar = getCatalystScalar(self.catalyst, modLine, self.catalystQuality)
18651870
-- Put the modified value into the string
1866-
local line = itemLib.applyRange(strippedModeLine, modLine.range, catalystScalar)
1871+
local line = itemLib.applyRange(strippedModeLine, modLine.range, catalystScalar, modLine.corruptedRange)
18671872
-- Check if we can parse it before adding the mods
18681873
local list, extra = modLib.parseMod(line)
18691874
if list and not extra then

0 commit comments

Comments
 (0)