Skip to content
Draft
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
28 changes: 28 additions & 0 deletions spec/System/TestItemParse_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,34 @@ describe("TestItemParse", function()
assert.are.equals(65, item.requirements.level)
end)

it("does not duplicate socket lines when rebuilding pasted game items", function()
local item = new("Item", [[
Rarity: Rare
Rage Mast
Razor Quarterstaff
--------
Item Level: 81
--------
Sockets: S S
]])

assert.are.equals(2, item.itemSocketCount)
assert.are.equals(2, #item.sockets)

local rawItem = item:BuildRaw()
local socketLineCount = 0
for line in rawItem:gmatch("[^\n]+") do
if line:match("^Sockets:") then
socketLineCount = socketLineCount + 1
end
end
assert.are.equals(1, socketLineCount)

item = new("Item", rawItem)
assert.are.equals(2, item.itemSocketCount)
assert.are.equals(2, #item.sockets)
end)

it("multi-line rune mod", function()
-- Thruldana is Bow-only as well
local item = new("Item", [[
Expand Down
16 changes: 13 additions & 3 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -565,18 +565,28 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
elseif specName == "Quality" then
self.quality = specToNumber(specVal)
elseif specName == "Sockets" then
local itemSockets = { }
local jewelSocketCount = 0
local group = 0
for c in specVal:gmatch(".") do
if c:match("[S]") then
t_insert(self.sockets, { group = group })
t_insert(itemSockets, { group = group })
group = group + 1
elseif c:match("[J]") then -- e.g. specVal = "Sockets: J J J J J J"
self.jewelSocketCount = self.jewelSocketCount + 1
jewelSocketCount = jewelSocketCount + 1
end
end
self.itemSocketCount = #self.sockets
if #itemSockets > 0 and #self.sockets == 0 then
self.sockets = itemSockets
self.itemSocketCount = #self.sockets
end
if jewelSocketCount > 0 and self.jewelSocketCount == 0 then
self.jewelSocketCount = jewelSocketCount
end
goto continue
elseif specName == "Rune" then
t_insert(self.runes, specVal)
goto continue
elseif specName == "Radius" and self.type == "Jewel" then
self.jewelRadiusLabel = specVal:match("^[%a ]+")
if specVal:match("^%a+") == "Variable" then
Expand Down
Loading