Skip to content

Commit a315af3

Browse files
vaisestLocalIdentity
andauthored
Fix keystone clusters not importing and unallocated subgraphs existing (#10272)
* Fix keystone clusters not importing and unallocated subgraphs existing * Fix cluster behaviour There were issues with nester cluster sockets and also reallocating sockets not making the cluster nodes appear / disappear --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent dd25052 commit a315af3

2 files changed

Lines changed: 138 additions & 7 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
describe("Cluster jewel subgraphs", function()
2+
local function countSubgraphs(spec)
3+
local count = 0
4+
for _ in pairs(spec.subGraphs) do
5+
count = count + 1
6+
end
7+
return count
8+
end
9+
10+
local function getOuterSocket(spec)
11+
for nodeId in pairs(spec.tree.sockets) do
12+
local node = spec.nodes[nodeId]
13+
if node and node.expansionJewel and node.expansionJewel.size == 2 then
14+
return node
15+
end
16+
end
17+
end
18+
19+
local function addItem(raw)
20+
local item = new("Item"):Item(raw)
21+
build.itemsTab:AddItem(item, true)
22+
return item
23+
end
24+
25+
local function addKeystoneCluster()
26+
return addItem([[Rarity: UNIQUE
27+
One With Nothing
28+
Small Cluster Jewel
29+
Implicits: 0
30+
Adds Hollow Palm Technique]])
31+
end
32+
33+
before_each(function()
34+
newBuild()
35+
end)
36+
37+
it("updates the graph when an outer socket allocation changes", function()
38+
local spec = build.spec
39+
local socket = getOuterSocket(spec)
40+
local jewel = addKeystoneCluster()
41+
spec.jewels[socket.id] = jewel.id
42+
spec.extended_hashes = { 123 }
43+
spec.jewel_data = {
44+
[socket.id] = {
45+
subgraph = {
46+
groups = {
47+
keystone = { proxy = socket.expansionJewel.proxy, nodes = { "123" } },
48+
},
49+
nodes = {
50+
["123"] = { group = "keystone", isKeystone = true, orbitIndex = 0 },
51+
},
52+
},
53+
},
54+
}
55+
56+
spec:BuildClusterJewelGraphs()
57+
assert.are.equal(0, countSubgraphs(spec))
58+
59+
spec:AllocNode(socket)
60+
assert.are.equal(1, countSubgraphs(spec))
61+
local _, subgraph = next(spec.subGraphs)
62+
assert.is_true(subgraph.nodes[1].alloc)
63+
64+
spec:DeallocNode(socket)
65+
assert.are.equal(0, countSubgraphs(spec))
66+
end)
67+
68+
it("only builds nested graphs for allocated cluster sockets", function()
69+
local spec = build.spec
70+
local outerSocket = getOuterSocket(spec)
71+
spec:AllocNode(outerSocket)
72+
73+
local largeCluster = addItem([[Rarity: RARE
74+
New Item
75+
Large Cluster Jewel
76+
Cluster Jewel Skill: affliction_chaos_damage
77+
Cluster Jewel Node Count: 8
78+
Implicits: 3
79+
Adds 8 Passive Skills
80+
2 Added Passive Skills are Jewel Sockets
81+
Added Small Passive Skills grant: 12% increased Chaos Damage]])
82+
spec.jewels[outerSocket.id] = largeCluster.id
83+
spec:BuildClusterJewelGraphs()
84+
85+
local nestedSocket
86+
for _, subgraph in pairs(spec.subGraphs) do
87+
for _, node in ipairs(subgraph.nodes) do
88+
if node.type == "Socket" then
89+
nestedSocket = node
90+
break
91+
end
92+
end
93+
if nestedSocket then
94+
break
95+
end
96+
end
97+
assert.is_truthy(nestedSocket)
98+
99+
local nestedJewel = addKeystoneCluster()
100+
spec.jewels[nestedSocket.id] = nestedJewel.id
101+
spec:BuildClusterJewelGraphs()
102+
assert.are.equal(1, countSubgraphs(spec))
103+
104+
nestedSocket = spec.nodes[nestedSocket.id]
105+
spec:AllocNode(nestedSocket)
106+
assert.are.equal(2, countSubgraphs(spec))
107+
108+
spec:BuildClusterJewelGraphs()
109+
assert.are.equal(2, countSubgraphs(spec))
110+
111+
nestedSocket = spec.nodes[nestedSocket.id]
112+
spec:DeallocNode(nestedSocket)
113+
assert.are.equal(1, countSubgraphs(spec))
114+
end)
115+
end)

‎src/Classes/PassiveSpec.lua‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,14 @@ function PassiveSpecClass:AllocNode(node, altPath)
778778
end
779779

780780
-- Allocate all nodes along the path
781+
local rebuildClusterJewelGraphs = false
781782
if #node.intuitiveLeapLikesAffecting > 0 then
783+
rebuildClusterJewelGraphs = not node.alloc and node.expansionJewel ~= nil
782784
node.alloc = true
783785
self.allocNodes[node.id] = node
784786
else
785787
for _, pathNode in ipairs(altPath or node.path) do
788+
rebuildClusterJewelGraphs = rebuildClusterJewelGraphs or not pathNode.alloc and pathNode.expansionJewel ~= nil
786789
pathNode.alloc = true
787790
self.allocNodes[pathNode.id] = pathNode
788791
end
@@ -799,8 +802,12 @@ function PassiveSpecClass:AllocNode(node, altPath)
799802
end
800803
end
801804

802-
-- Rebuild all dependencies and paths for all allocated nodes
803-
self:BuildAllDependsAndPaths()
805+
if rebuildClusterJewelGraphs then
806+
self:BuildClusterJewelGraphs()
807+
else
808+
-- Rebuild all dependencies and paths for all allocated nodes
809+
self:BuildAllDependsAndPaths()
810+
end
804811
end
805812

806813
function PassiveSpecClass:DeallocSingleNode(node)
@@ -814,12 +821,18 @@ end
814821

815822
-- Deallocate the given node, and all nodes which depend on it (i.e. which are only connected to the tree through this node)
816823
function PassiveSpecClass:DeallocNode(node)
824+
local rebuildClusterJewelGraphs = false
817825
for _, depNode in ipairs(node.depends) do
826+
rebuildClusterJewelGraphs = rebuildClusterJewelGraphs or depNode.alloc and depNode.expansionJewel ~= nil
818827
self:DeallocSingleNode(depNode)
819828
end
820829

821-
-- Rebuild all paths and dependencies for all allocated nodes
822-
self:BuildAllDependsAndPaths()
830+
if rebuildClusterJewelGraphs then
831+
self:BuildClusterJewelGraphs()
832+
else
833+
-- Rebuild all paths and dependencies for all allocated nodes
834+
self:BuildAllDependsAndPaths()
835+
end
823836
end
824837

825838
-- Count the number of allocated nodes and allocated ascendancy nodes
@@ -1765,7 +1778,7 @@ function PassiveSpecClass:BuildClusterJewelGraphs()
17651778
for nodeId in pairs(self.tree.sockets) do
17661779
local node = self.tree.nodes[nodeId]
17671780
local jewel = self:GetSocketedJewel(nodeId)
1768-
if node and node.expansionJewel and node.expansionJewel.size == 2 and jewel and jewel.jewelData.clusterJewelValid then
1781+
if node and self.allocNodes[node.id] and node.expansionJewel and node.expansionJewel.size == 2 and jewel and jewel.jewelData.clusterJewelValid then
17691782
-- This is a Large Jewel Socket, and it has a cluster jewel in it
17701783
self:BuildSubgraph(jewel, self.nodes[nodeId], nil, nil, importedNodes, importedGroups)
17711784
end
@@ -1971,7 +1984,9 @@ function PassiveSpecClass:BuildSubgraph(jewel, parentSocket, id, upSize, importe
19711984
if proxyGroup then
19721985
for id, data in pairs(importedNodes) do
19731986
if proxyGroup == data.group then
1974-
if node.oidx == data.orbitIndex and not data.isMastery then
1987+
local matches = node.type == "Keystone" and data.isKeystone
1988+
or (node.oidx == data.orbitIndex and not data.isMastery)
1989+
if matches then
19751990
for _, extendedId in ipairs(importedGroups[proxyGroup].nodes) do
19761991
if id == extendedId and inExtendedHashes(tonumber(id)) then
19771992
return true
@@ -2265,7 +2280,8 @@ function PassiveSpecClass:BuildSubgraph(jewel, parentSocket, id, upSize, importe
22652280
if node.type == "Socket" then
22662281
-- Recurse to smaller jewels
22672282
local jewel = self:GetSocketedJewel(node.id)
2268-
if jewel and jewel.jewelData.clusterJewelValid then
2283+
-- Allocated subgraph nodes are temporarily preserved outside allocNodes while rebuilding.
2284+
if (self.allocNodes[node.id] or isValueInArray(self.allocSubgraphNodes, node.id)) and jewel and jewel.jewelData.clusterJewelValid then
22692285
self:BuildSubgraph(jewel, node, id, upSize, importedNodes, importedGroups)
22702286
end
22712287
end

0 commit comments

Comments
 (0)