Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions spec/System/TestItemMods_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,74 @@ describe("TetsItemMods", function()
assert.are_not.equals(baseColdAvg, round(build.calcsTab.mainOutput.ColdStoredCombinedAvg))
assert.equals(0, round(build.calcsTab.mainOutput.FireStoredCombinedAvg))
end)

it("Timeless jewels grant conquered attribute passive bonuses", function()
local calcs = build.calcsTab.calcs
local jewelSocketNodeId = 999
local attributeNode = {
id = 1,
type = "Normal",
isAttribute = true,
allocMode = 0,
modList = new("ModList"),
}
local smallNode = {
id = 2,
type = "Normal",
allocMode = 0,
modList = new("ModList"),
}
local envMode = "SPEC_TIMELESS_ATTRIBUTE"
GlobalCache.cachedData[envMode] = { }
local env = {
mode = envMode,
radiusJewelList = { },
allocNodes = { },
build = {
itemsTab = {
activeItemSet = {
useSecondWeaponSet = false,
},
},
spec = {
nodes = {
[jewelSocketNodeId] = {
allocMode = 0,
},
},
},
},
}
table.insert(env.radiusJewelList, {
type = "Other",
nodes = {
[attributeNode.id] = { type = "Normal" },
[smallNode.id] = { type = "Normal" },
},
item = {
baseName = "Timeless Jewel",
},
nodeId = jewelSocketNodeId,
jewelHash = "undying-hate-spec",
data = {
modSource = "Tree:" .. jewelSocketNodeId,
},
func = function(node, out, data)
if node and node.type == "Normal" and node.isAttribute then
out:NewMod("Str", "BASE", 7, data.modSource)
elseif node and node.type == "Normal" and not node.isAttribute then
out:NewMod("Dex", "BASE", 11, data.modSource)
end
end,
})

local attributeModList = calcs.buildModListForNode(env, attributeNode, 0, false)
local smallModList = calcs.buildModListForNode(env, smallNode, 0, false)
GlobalCache.cachedData[envMode] = nil

assert.are.equals(7, attributeModList:Sum("BASE", nil, "Str"))
assert.are.equals(0, attributeModList:Sum("BASE", nil, "Dex"))
assert.are.equals(0, smallModList:Sum("BASE", nil, "Str"))
assert.are.equals(11, smallModList:Sum("BASE", nil, "Dex"))
end)
end)
9 changes: 7 additions & 2 deletions src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ end

local function refreshJewelStatCache(env)
local normalNode = { type = "Normal" }
local attributeNode = { type = "Normal", isAttribute = true }
local notableNode = { type = "Notable" }
GlobalCache.cachedData[env.mode].radiusJewelData = { }

Expand All @@ -110,9 +111,11 @@ local function refreshJewelStatCache(env)
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId] = { }
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].hash = rad.jewelHash
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].smallModList = new("ModList")
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].attributeModList = new("ModList")
GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].notableModList = new("ModList")
end
rad.func(normalNode, GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].smallModList, rad.data)
rad.func(attributeNode, GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].attributeModList, rad.data)
rad.func(notableNode, GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId].notableModList, rad.data)
end
end
Expand Down Expand Up @@ -140,12 +143,14 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill, includeKeyst
if rad.type == "Other" and rad.nodes[node.id] and rad.nodes[node.id].type ~= "Mastery" then
if rad.item.baseName:find("Time%-Lost") == nil and rad.item.baseName:find("Timeless Jewel") == nil then
rad.func(node, modList, rad.data)
elseif not node.isAttribute and (node.type == "Normal" or node.type == "Notable") then
elseif node.type == "Normal" or node.type == "Notable" then
local cache = GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId]
if not cache or (cache.hash ~= rad.jewelHash) then
refreshJewelStatCache(env)
end
if node.type == "Normal" and cache and #cache.smallModList > 0 then
if node.type == "Normal" and node.isAttribute and cache and #cache.attributeModList > 0 then
modList:AddList(cache.attributeModList)
elseif node.type == "Normal" and not node.isAttribute and cache and #cache.smallModList > 0 then
modList:AddList(cache.smallModList)
elseif node.type == "Notable" and cache and #cache.notableModList > 0 then
modList:AddList(cache.notableModList)
Expand Down
Loading