diff --git a/spec/System/TestRadiusJewels_spec.lua b/spec/System/TestRadiusJewels_spec.lua new file mode 100644 index 000000000..312c7ed77 --- /dev/null +++ b/spec/System/TestRadiusJewels_spec.lua @@ -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) diff --git a/src/Modules/CalcSetup.lua b/src/Modules/CalcSetup.lua index 5e24c1339..a6a4e5714 100644 --- a/src/Modules/CalcSetup.lua +++ b/src/Modules/CalcSetup.lua @@ -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 @@ -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