Skip to content
Closed
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
72 changes: 72 additions & 0 deletions spec/System/TestRadiusJewels_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
describe("TestRadiusJewels", function()
before_each(function()
newBuild()
end)

it("copies cached Time-Lost radius mods before adding weapon set conditions", function()
GlobalCache.cachedData.MAIN.radiusJewelData = nil

local function addTimeLostMana(node, modList)
if node.type == "Normal" then
modList:NewMod("Mana", "INC", 1, "Tree:500")
end
end

local env = {
mode = "MAIN",
radiusJewelList = {
{
type = "Other",
nodeId = 500,
jewelHash = "time-lost-mana",
item = { baseName = "Time-Lost Diamond" },
nodes = {
[100] = { type = "Normal" },
[101] = { type = "Normal" },
},
func = addTimeLostMana,
data = { },
},
},
allocNodes = {
[100] = true,
[101] = true,
},
build = {
spec = {
nodes = {
[500] = { allocMode = 0 },
},
},
itemsTab = {
activeItemSet = {
useSecondWeaponSet = false,
},
},
},
explodeSources = { },
}
local weaponSetNode = {
id = 100,
type = "Normal",
allocMode = 2,
modList = new("ModList"),
}
local globalNode = {
id = 101,
type = "Normal",
allocMode = 0,
modList = new("ModList"),
}

local weaponSetModList = build.calcsTab.calcs.buildModListForNode(env, weaponSetNode, 0)
assert.is_not_nil(weaponSetModList[1][1])
assert.equals("WeaponSet2", weaponSetModList[1][1].var)

local globalModList = build.calcsTab.calcs.buildModListForNode(env, globalNode, 0)
assert.is_nil(globalModList[1][1])

assert.is_not_nil(weaponSetModList[1][1])
assert.equals("WeaponSet2", weaponSetModList[1][1].var)
end)
end)
11 changes: 9 additions & 2 deletions src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ local function refreshJewelStatCache(env)
end
end

local function addCopiedModList(modList, cachedList)
for i = 1, #cachedList do
modList:AddMod(copyTable(cachedList[i], true))
end
end

function calcs.buildModListForNode(env, node, incSmallPassiveSkill, includeKeystoneMods)
local localSmallIncEffect = 0
local localNotableIncEffect = 0
Expand Down Expand Up @@ -144,11 +150,12 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill, includeKeyst
local cache = GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId]
if not cache or (cache.hash ~= rad.jewelHash) then
refreshJewelStatCache(env)
cache = GlobalCache.cachedData[env.mode].radiusJewelData[rad.nodeId]
end
if node.type == "Normal" and cache and #cache.smallModList > 0 then
modList:AddList(cache.smallModList)
addCopiedModList(modList, cache.smallModList)
elseif node.type == "Notable" and cache and #cache.notableModList > 0 then
modList:AddList(cache.notableModList)
addCopiedModList(modList, cache.notableModList)
end
break
end
Expand Down