Skip to content

Commit 6d7773f

Browse files
PeecheyLocalIdentity
andauthored
Update nodes to show Against the Darkness stats (#170)
* update nodes affected by Against the Darkness jewel to show the stats applied * Fix merge issue --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 997b856 commit 6d7773f

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

src/Modules/CalcSetup.lua

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,57 @@ function calcs.initModDB(env, modDB)
9090
modDB.conditions["Effective"] = env.mode_effective
9191
end
9292

93+
-- grab the stat lines from the selected variants on the jewel to add to the nodes
94+
-- e.g. Against the Darkness
95+
local function setRadiusJewelStats(radiusJewel, radiusJewelStats)
96+
local jewel = radiusJewel.item
97+
if jewel.title == "Against the Darkness" then
98+
radiusJewelStats.source = radiusJewel.data.modSource
99+
local range = jewel.explicitModLines[jewel.variant].range
100+
local value = 0
101+
jewel.explicitModLines[jewel.variant].line:gsub("%((%d+)%-(%d+)%)",
102+
function(num1, num2)
103+
value = round((num1+num2)*range)
104+
end
105+
)
106+
radiusJewelStats[1] = {
107+
isNotable = (jewel.explicitModLines[jewel.variant].line:match("^(%S+)") == "Notable"),
108+
sd = jewel.explicitModLines[jewel.variant].line:gsub(".*grant ", ""):gsub("%(.-%)", value)
109+
}
110+
111+
local rangeAlt = jewel.explicitModLines[jewel.variant].range
112+
local valueAlt = 0
113+
jewel.explicitModLines[jewel.variantAlt].line:gsub("%((%d+)%-(%d+)%)",
114+
function(num1, num2)
115+
valueAlt = round((num1+num2)*rangeAlt)
116+
end
117+
)
118+
radiusJewelStats[2] = {
119+
isNotable = (jewel.explicitModLines[jewel.variantAlt].line:match("^(%S+)") == "Notable"),
120+
sd = jewel.explicitModLines[jewel.variantAlt].line:gsub(".*grant ", ""):gsub("%(.-%)", valueAlt)
121+
}
122+
end
123+
end
124+
125+
local function addStatsFromJewelToNode(jewel, node, spec)
126+
-- reset node stats to base or override for attributes
127+
if spec.hashOverrides and spec.hashOverrides[node.id] then
128+
node.sd = copyTable(spec.hashOverrides[node.id].sd, true)
129+
else
130+
node.sd = copyTable(spec.tree.nodes[node.id].sd, true)
131+
end
132+
133+
local radiusJewelStats = { }
134+
setRadiusJewelStats(jewel, radiusJewelStats)
135+
for _, stat in ipairs(radiusJewelStats) do
136+
-- the node and jewelStat types match, add sd to node if it's not already there
137+
if not isValueInTable(node.sd, stat.sd) and ((node.type == "Notable" and stat.isNotable) or (node.type ~= "Notable" and not stat.isNotable)) then
138+
t_insert(node.sd, stat.sd)
139+
end
140+
end
141+
spec.tree:ProcessStats(node)
142+
end
143+
93144
function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
94145
local modList = new("ModList")
95146
if node.type == "Keystone" then
@@ -118,7 +169,11 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
118169
-- Run first pass radius jewels
119170
for _, rad in pairs(env.radiusJewelList) do
120171
if rad.type == "Other" and rad.nodes[node.id] and rad.nodes[node.id].type ~= "Mastery" then
121-
rad.func(node, modList, rad.data)
172+
if rad.item.title ~= "Against the Darkness" then
173+
rad.func(node, modList, rad.data)
174+
else
175+
addStatsFromJewelToNode(rad, node, env.build.spec)
176+
end
122177
end
123178
end
124179

@@ -137,7 +192,11 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
137192
-- Run second pass radius jewels
138193
for _, rad in pairs(env.radiusJewelList) do
139194
if rad.nodes[node.id] and rad.nodes[node.id].type ~= "Mastery" and (rad.type == "Threshold" or (rad.type == "Self" and env.allocNodes[node.id]) or (rad.type == "SelfUnalloc" and not env.allocNodes[node.id])) then
140-
rad.func(node, modList, rad.data)
195+
if rad.item.title ~= "Against the Darkness" then
196+
rad.func(node, modList, rad.data)
197+
else
198+
addStatsFromJewelToNode(rad, node, env.build.spec)
199+
end
141200
end
142201
end
143202

0 commit comments

Comments
 (0)