Skip to content

Commit

Permalink
fixing sockets (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostrademous authored Dec 17, 2024
1 parent 0f7a581 commit a492261
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
end
self.checkSection = false
self.sockets = { }
self.itemSocketCount = 0
self.classRequirementModLines = { }
self.buffModLines = { }
self.enchantModLines = { }
Expand Down Expand Up @@ -436,10 +437,11 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
local group = 0
for c in specVal:gmatch(".") do
if c:match("[S]") then
t_insert(self.sockets, { })
t_insert(self.sockets, { group = group })
group = group + 1
end
end
self.socketCount = #self.sockets
self.itemSocketCount = #self.sockets
elseif specName == "Radius" and self.type == "Jewel" then
self.jewelRadiusLabel = specVal:match("^%a+")
if specVal:match("^%a+") == "Variable" then
Expand Down Expand Up @@ -885,11 +887,11 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
if self.base and self.base.socketLimit then
if #self.sockets == 0 then
for i = 1, self.base.socketLimit do
t_insert(self.sockets, { })
t_insert(self.sockets, { group = 0 })
end
self.itemSocketCount = #self.sockets
end
end
self.socketCount = 0
if self.variantList then
self.variant = m_min(#self.variantList, self.variant or #self.variantList)
if self.hasAltVariant then
Expand Down Expand Up @@ -1122,9 +1124,9 @@ function ItemClass:BuildRaw()
if self.quality then
t_insert(rawLines, "Quality: " .. self.quality)
end
if self.sockets then
if self.itemSocketCount and self.itemSocketCount > 0 then
local socketString = ""
for _, socket in ipairs(self.sockets) do
for _ = 1, self.itemSocketCount do
socketString = socketString .. "S "
end
socketString = socketString:gsub(" $", "")
Expand Down Expand Up @@ -1647,15 +1649,13 @@ function ItemClass:BuildModList()
end
end

self.socketCount = #self.sockets
if calcLocal(baseList, "NoSockets", "FLAG", 0) then
-- Remove all sockets
wipeTable(self.sockets)
elseif self.socketCount > 0 then
if self.itemSocketCount > 0 then
-- Ensure that there are the correct number of abyssal sockets present
local newSockets = { }
for i = 1, self.socketCount do
t_insert(newSockets, {})
local group = 0
for i = 1, self.itemSocketCount do
group = group + 1
t_insert(newSockets, {group = group})
end
self.sockets = newSockets
end
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ItemSlotControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function ItemSlotClass:Populate()
local socketCount = 0
if self.selItemId > 0 then
local selItem = self.itemsTab.items[self.selItemId]
socketCount = selItem.socketCount or 0
socketCount = selItem.itemSocketCount or 0
end
for i, socket in ipairs(self.socketList) do
socket.inactive = i > socketCount
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3321,9 +3321,9 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
tooltip:AddSeparator(10)
end

if #item.sockets > 0 then
if item.itemSocketCount > 0 then
local socketString = ""
for _, socket in ipairs(item.sockets) do
for _ = 1, item.itemSocketCount do
socketString = socketString .. "S "
end
socketString = socketString:gsub(" $", "")
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ function calcs.initEnv(build, mode, override, specEnv)
item:NormaliseQuality()
item:BuildAndParseRaw()
item.sockets = previousItem.sockets
item.socketCount = previousItem.socketCount
item.itemSocketCount = previousItem.itemSocketCount
env.player.itemList[slotName] = item
else
env.itemModDB:ScaleAddList(srcList, scale)
Expand Down

0 comments on commit a492261

Please sign in to comment.