Skip to content

Commit 6828bb3

Browse files
committed
1 parent 7e83288 commit 6828bb3

5 files changed

Lines changed: 101 additions & 2 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff a/spec/System/TestItemParse_spec.lua b/spec/System/TestItemParse_spec.lua (rejected hunks)
2+
@@ -525,6 +525,16 @@ describe("TestAdvancedItemParse #item", function()
3+
assert.are_not.equals("mana", item.explicitModLines[3].modTags[1])
4+
end)
5+
6+
+ it("resets linePostfix", function()
7+
+ local item = new("Item", raw([[
8+
+ { Corruption Enhancement — Mana }
9+
+ 24(20-30)% increased Mana Regeneration Rate
10+
+ --------
11+
+ +15 to maximum life
12+
+ ]]))
13+
+ assert.falsy(item.explicitModLines[1].enchant)
14+
+ end)
15+
+
16+
it("parses vaaled catalyst", function()
17+
local item = new("Item", raw([[
18+
Quality (Attribute Modifiers): +19% (augmented)
19+
@@ -571,6 +581,23 @@ describe("TestAdvancedItemParse #item", function()
20+
-- assert.are.equals(1, item.explicitModLines[1].range) -- Not sure why this is returning 0.5
21+
end)
22+
23+
+ it("parses enchant correctly #enchant", function()
24+
+ local item = new("Item", raw([[
25+
+ { Corrupted Enhancement }
26+
+ +8(6-10)% to Fire Resistance
27+
+ ]]))
28+
+ assert.are.equals(8, item.enchantModLines[1].modList[1].value)
29+
+ end)
30+
+
31+
+ it("parses enchant with tags correctly #enchant", function()
32+
+ local item = new("Item", raw([[
33+
+ { Corrupted Enhancement - Energy Shield }
34+
+ +8(6-10)% to Fire Resistance
35+
+ ]]))
36+
+ assert.are.equals(8, item.enchantModLines[1].modList[1].value)
37+
+ assert.are.equals("energyshield", item.enchantModLines[1].modTags[1])
38+
+ end)
39+
+
40+
it("parses junk", function()
41+
local godTestItem = new("Item", [[
42+
Item Class: Sceptres

src/Classes/Item.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
383383
local deferJewelRadiusIndexAssignment
384384
local gameModeStage = "FINDIMPLICIT"
385385
local foundExplicit, foundImplicit
386+
local linePrefix = ""
387+
local linePostfix = ""
386388

387389
while self.rawLines[l] do
388390
local line = self.rawLines[l]
@@ -426,7 +428,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
426428
end
427429
self.checkSection = false
428430
end
429-
local specName, specVal = line:match("^([%a ]+:?): (.+)$")
431+
local specName, specVal = line:match("^([%a %(%)]+:?): (.+)$")
430432
if specName then
431433
if specName == "Class:" then
432434
specName = "Requires Class"

src/Classes/Item.lua.rej

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff a/src/Classes/Item.lua b/src/Classes/Item.lua (rejected hunks)
2+
@@ -838,8 +838,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
3+
end
4+
end
5+
-- Use rolling Delta/Range in case one range is 1-3 and another is 1-100 so we get the finest precision possible
6+
- local bestPrecisionDelta = 0
7+
- local bestPrecisionRange = 0
8+
+ local bestPrecisionDelta = -1
9+
+ local bestPrecisionRange = -1
10+
for value, range in line:gmatch("(%-?%d+%.?%d*)%((%-?%d+%.?%d*%-%-?%d+%.?%d*)%)") do
11+
-- Find advanced copy paste format: 45(40-50)
12+
local min, max = range:match("(%-?%d+%.?%d*)%-(%-?%d+%.?%d*)")
13+
@@ -857,8 +857,12 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
14+
self.pendingAffixList = {}
15+
else
16+
-- Use rolling Delta/Range in case one range is 1-3 and another is 1-100 so we get the finest precision possible
17+
- local bestPrecisionDelta = 0
18+
- local bestPrecisionRange = 0
19+
+ local bestPrecisionDelta = -1
20+
+ local bestPrecisionRange = -1
21+
+
22+
+ -- Replace non-number ranges as unsupported
23+
+ line = line:gsub("(%a+)%([%a%s]+%-[%a%s]+%)", "%1")
24+
+
25+
for value, range in line:gmatch("(%-?%d+%.?%d*)%((%-?%d+%.?%d*%-%-?%d+%.?%d*)%)") do
26+
local min, max = range:match("(%-?%d+%.?%d*)%-(%-?%d+%.?%d*)")
27+
local delta = tonumber(max) - min
28+
@@ -869,7 +873,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
29+
if bestPrecisionRange > 1 or bestPrecisionRange < 0 then
30+
line = line:gsub(value .. "%(" .. range:gsub("%-", "%%-") .. "%)", value)
31+
else
32+
- line = line:gsub(value .. "%(" .. range:gsub("%-", "%%-") .. "%)", "(" .. range .. ")")
33+
+ line = line:gsub(value .. "%(" .. range:gsub("%-", "%%-") .. "%)", (tonumber(value) < 0 and "+" or "") .. "(" .. range .. ")")
34+
end
35+
end
36+
if bestPrecisionRange <= 1 and bestPrecisionRange >= 0 then

src/Classes/ItemsTab.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,13 @@ function ItemsTabClass:UpdateAffixControl(control, item, type, outputTable, outp
19411941
end
19421942
if control.list[control.selIndex].haveRange then
19431943
control.slider.divCount = #control.list[control.selIndex].modList
1944-
control.slider.val = (isValueInArray(control.list[control.selIndex].modList, selAffix) - 1 + (item[outputTable][outputIndex].range or 0.5)) / control.slider.divCount
1944+
local index = isValueInArray(control.list[control.selIndex].modList, selAffix)
1945+
local range = item[outputTable][outputIndex].range or 0.5
1946+
-- Avoid exact integer boundary that slider:GetDivVal's ceil would assign to the previous segment
1947+
if range == 0 and index > 1 then
1948+
range = 1e-4
1949+
end
1950+
control.slider.val = (index - 1 + range) / control.slider.divCount
19451951
if control.slider.divCount == 1 then
19461952
control.slider.divCount = nil
19471953
end

src/Classes/ItemsTab.lua.rej

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff a/src/Classes/ItemsTab.lua b/src/Classes/ItemsTab.lua (rejected hunks)
2+
@@ -1242,11 +1242,6 @@ function ItemsTabClass:Draw(viewPort, inputEvents)
3+
if event.type == "KeyDown" then
4+
if event.key == "v" and IsKeyDown("CTRL") then
5+
local newItem = Paste()
6+
- if newItem:find("{ ", 0, true) then
7+
- main:OpenConfirmPopup("Warning", "\"Advanced Item Descriptions\" (Ctrl+Alt+c) are unsupported.\n\nAbort paste?", "OK", function()
8+
- self:SetDisplayItem()
9+
- end)
10+
- end
11+
if newItem then
12+
self:CreateDisplayItemFromRaw(newItem, true)
13+
end

0 commit comments

Comments
 (0)