Skip to content

Commit 4b36dea

Browse files
Merge pull request #2 from Peechey/fix/jewel-socket-res-and-displayStats-with-ATD
Fix resistance bug and Against the Darkness displayStats
2 parents f685f69 + be9eccd commit 4b36dea

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

src/Classes/ItemsTab.lua

+7-6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Contro
9595
self.slots = { }
9696
self.orderedSlots = { }
9797
self.slotOrder = { }
98+
self.initSockets = true
9899
self.slotAnchor = new("Control", {"TOPLEFT",self,"TOPLEFT"}, {96, 76, 310, 0})
99100
local prevSlot = self.slotAnchor
100101
local function addSlot(slot)
@@ -1231,27 +1232,28 @@ end
12311232
-- Updates the status and position of the socket controls
12321233
function ItemsTabClass:UpdateSockets()
12331234
-- Build a list of active sockets
1234-
local activeSocketList = { }
1235+
self.activeSocketList = { }
12351236
for nodeId, slot in pairs(self.sockets) do
12361237
if self.build.spec.allocNodes[nodeId] then
1237-
t_insert(activeSocketList, nodeId)
1238+
t_insert(self.activeSocketList, nodeId)
12381239
slot.inactive = false
12391240
else
12401241
slot.inactive = true
12411242
end
12421243
end
1243-
table.sort(activeSocketList)
1244+
table.sort(self.activeSocketList)
12441245

12451246
-- Update the state of the active socket controls
12461247
self.lastSlot = self.slots[baseSlots[#baseSlots]]
1247-
for index, nodeId in ipairs(activeSocketList) do
1248+
for index, nodeId in ipairs(self.activeSocketList) do
12481249
self.sockets[nodeId].label = "Socket #"..index
12491250
self.lastSlot = self.sockets[nodeId]
12501251
end
12511252

12521253
if main.portraitMode then
12531254
self.controls.itemList:SetAnchor("TOPRIGHT",self.lastSlot,"BOTTOMRIGHT", 0, 40)
12541255
end
1256+
self.initSockets = false
12551257
end
12561258

12571259
-- Returns the slot control and equipped jewel for the given node ID
@@ -1726,8 +1728,7 @@ function ItemsTabClass:UpdateDisplayItemRangeLines()
17261728
wipeTable(self.controls.displayItemRangeLine.list)
17271729
for _, modLine in ipairs(self.displayItem.rangeLineList) do
17281730
-- primarily for Against the Darkness // a way to cut down on really long modLines, gsub could be updated for others
1729-
local rangeLine = modLine.line:gsub(" Passive Skills in Radius also grant", ":")
1730-
t_insert(self.controls.displayItemRangeLine.list, rangeLine)
1731+
t_insert(self.controls.displayItemRangeLine.list, (modLine.line:gsub(" Passive Skills in Radius also grant", ":")))
17311732
end
17321733
self.controls.displayItemRangeLine.selIndex = 1
17331734
self.controls.displayItemRangeSlider.val = self.displayItem.rangeLineList[1].range

src/Modules/CalcSetup.lua

+22-5
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ local function setRadiusJewelStats(radiusJewel, radiusJewelStats)
125125
end
126126
end
127127

128-
local function addStatsFromJewelToNode(jewel, node, spec)
128+
local function addStats(jewel, node, spec)
129129
-- reset node stats to base or override for attributes
130130
if spec.hashOverrides and spec.hashOverrides[node.id] then
131131
node.sd = copyTable(spec.hashOverrides[node.id].sd, true)
132132
else
133133
node.sd = copyTable(spec.tree.nodes[node.id].sd, true)
134134
end
135-
135+
136136
local radiusJewelStats = { }
137137
setRadiusJewelStats(jewel, radiusJewelStats)
138138
for _, stat in ipairs(radiusJewelStats) do
@@ -142,8 +142,23 @@ local function addStatsFromJewelToNode(jewel, node, spec)
142142
end
143143
end
144144
spec.tree:ProcessStats(node)
145+
return node.modList
145146
end
146147

148+
local function addStatsFromJewelToNode(jewel, node, spec)
149+
local itemsTab = spec.build.itemsTab
150+
--
151+
if itemsTab.activeSocketList then
152+
for _, nodeId in pairs(itemsTab.activeSocketList) do
153+
local _, socketedJewel = itemsTab:GetSocketAndJewelForNodeID(nodeId)
154+
if socketedJewel and socketedJewel.title == "Against the Darkness" then
155+
return addStats(jewel, node, spec)
156+
end
157+
end
158+
elseif itemsTab.initSockets then
159+
return addStats(jewel, node, spec)
160+
end
161+
end
147162
function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
148163
local modList = new("ModList")
149164
if node.type == "Keystone" then
@@ -175,7 +190,8 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
175190
if rad.item.title ~= "Against the Darkness" then
176191
rad.func(node, modList, rad.data)
177192
else
178-
addStatsFromJewelToNode(rad, node, env.build.spec)
193+
local nodeList = addStatsFromJewelToNode(rad, node, env.build.spec)
194+
if nodeList then modList = nodeList end
179195
end
180196
end
181197
end
@@ -198,11 +214,12 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
198214
if rad.item.title ~= "Against the Darkness" then
199215
rad.func(node, modList, rad.data)
200216
else
201-
addStatsFromJewelToNode(rad, node, env.build.spec)
217+
local nodeList = addStatsFromJewelToNode(rad, node, env.build.spec)
218+
if nodeList then modList = nodeList end
202219
end
203220
end
204221
end
205-
222+
206223
if modList:Flag(nil, "PassiveSkillHasOtherEffect") then
207224
for i, mod in ipairs(modList:List(skillCfg, "NodeModifier")) do
208225
if i == 1 then wipeTable(modList) end

0 commit comments

Comments
 (0)