Skip to content

Commit 89772eb

Browse files
authored
Fix Timeless Jewel attribute passive bonuses (#1902)
1 parent d5f5fbd commit 89772eb

2 files changed

Lines changed: 77 additions & 2 deletions

File tree

spec/System/TestItemMods_spec.lua

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,4 +585,74 @@ describe("TetsItemMods", function()
585585
assert.are_not.equals(baseColdAvg, round(build.calcsTab.mainOutput.ColdStoredCombinedAvg))
586586
assert.equals(0, round(build.calcsTab.mainOutput.FireStoredCombinedAvg))
587587
end)
588+
589+
it("Timeless jewels grant conquered attribute passive bonuses", function()
590+
local calcs = build.calcsTab.calcs
591+
local jewelSocketNodeId = 999
592+
local attributeNode = {
593+
id = 1,
594+
type = "Normal",
595+
isAttribute = true,
596+
allocMode = 0,
597+
modList = new("ModList"),
598+
}
599+
local smallNode = {
600+
id = 2,
601+
type = "Normal",
602+
allocMode = 0,
603+
modList = new("ModList"),
604+
}
605+
local envMode = "SPEC_TIMELESS_ATTRIBUTE"
606+
GlobalCache.cachedData[envMode] = { }
607+
local env = {
608+
mode = envMode,
609+
radiusJewelList = { },
610+
allocNodes = { },
611+
build = {
612+
itemsTab = {
613+
activeItemSet = {
614+
useSecondWeaponSet = false,
615+
},
616+
},
617+
spec = {
618+
nodes = {
619+
[jewelSocketNodeId] = {
620+
allocMode = 0,
621+
},
622+
},
623+
},
624+
},
625+
}
626+
table.insert(env.radiusJewelList, {
627+
type = "Other",
628+
nodes = {
629+
[attributeNode.id] = { type = "Normal" },
630+
[smallNode.id] = { type = "Normal" },
631+
},
632+
item = {
633+
baseName = "Timeless Jewel",
634+
},
635+
nodeId = jewelSocketNodeId,
636+
jewelHash = "undying-hate-spec",
637+
data = {
638+
modSource = "Tree:" .. jewelSocketNodeId,
639+
},
640+
func = function(node, out, data)
641+
if node and node.type == "Normal" and node.isAttribute then
642+
out:NewMod("Str", "BASE", 7, data.modSource)
643+
elseif node and node.type == "Normal" and not node.isAttribute then
644+
out:NewMod("Dex", "BASE", 11, data.modSource)
645+
end
646+
end,
647+
})
648+
649+
local attributeModList = calcs.buildModListForNode(env, attributeNode, 0, false)
650+
local smallModList = calcs.buildModListForNode(env, smallNode, 0, false)
651+
GlobalCache.cachedData[envMode] = nil
652+
653+
assert.are.equals(7, attributeModList:Sum("BASE", nil, "Str"))
654+
assert.are.equals(0, attributeModList:Sum("BASE", nil, "Dex"))
655+
assert.are.equals(0, smallModList:Sum("BASE", nil, "Str"))
656+
assert.are.equals(11, smallModList:Sum("BASE", nil, "Dex"))
657+
end)
588658
end)

src/Modules/CalcSetup.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ end
102102

103103
local function refreshJewelStatCache(env)
104104
local normalNode = { type = "Normal" }
105+
local attributeNode = { type = "Normal", isAttribute = true }
105106
local notableNode = { type = "Notable" }
106107
GlobalCache.cachedData[env.mode].radiusJewelData = { }
107108

@@ -110,9 +111,11 @@ local function refreshJewelStatCache(env)
110111
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId] = { }
111112
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].hash = rad.jewelHash
112113
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].smallModList = new("ModList")
114+
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].attributeModList = new("ModList")
113115
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].notableModList = new("ModList")
114116
end
115117
rad.func(normalNode, GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].smallModList, rad.data)
118+
rad.func(attributeNode, GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].attributeModList, rad.data)
116119
rad.func(notableNode, GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].notableModList, rad.data)
117120
end
118121
end
@@ -140,12 +143,14 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill, includeKeyst
140143
if rad.type == "Other" and rad.nodes[node.id] and rad.nodes[node.id].type ~= "Mastery" then
141144
if rad.item.baseName:find("Time%-Lost") == nil and rad.item.baseName:find("Timeless Jewel") == nil then
142145
rad.func(node, modList, rad.data)
143-
elseif not node.isAttribute and (node.type == "Normal" or node.type == "Notable") then
146+
elseif node.type == "Normal" or node.type == "Notable" then
144147
local cache = GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId]
145148
if not cache or (cache.hash ~= rad.jewelHash) then
146149
refreshJewelStatCache(env)
147150
end
148-
if node.type == "Normal" and cache and #cache.smallModList > 0 then
151+
if node.type == "Normal" and node.isAttribute and cache and #cache.attributeModList > 0 then
152+
modList:AddList(cache.attributeModList)
153+
elseif node.type == "Normal" and not node.isAttribute and cache and #cache.smallModList > 0 then
149154
modList:AddList(cache.smallModList)
150155
elseif node.type == "Notable" and cache and #cache.notableModList > 0 then
151156
modList:AddList(cache.notableModList)

0 commit comments

Comments
 (0)