Skip to content
Open
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
56 changes: 56 additions & 0 deletions spec/System/TestPowerReport_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,59 @@ describe("PowerReportListControl", function()
assert.are.equal("allocated", list[1].name)
end)
end)

describe("Full DPS passive comparisons", function()
it("matches the ordinary calculator across successive damage and no-change overrides", function()
newBuild()
build.skillsTab:PasteSocketGroup("Fireball 20/0 1")
build.skillsTab.socketGroupList[1].includeInFullDPS = true
build.buildFlag = true
runCallback("OnFrame")

local calcs = build.calcsTab.calcs
local ordinary = calcs.getMiscCalculator(build)
local report = calcs.getFullDPSPowerCalculator(build, ordinary)
assert.are_not.equal(ordinary, report)
local node = build.spec.nodes[build.spec.tree.notableMap["heart of flame"].id]
local base = ordinary({ }, true).FullDPS
local withNode = ordinary({ addNodes = { [node] = true } }, true).FullDPS
assert.is_true(withNode > base)
assert.are.equal(base, report({ }).FullDPS)
assert.are.equal(withNode, report({ addNodes = { [node] = true } }).FullDPS)
assert.are.equal(base, report({ }).FullDPS)
end)

it("keeps the ordinary calculator when the selected Vaal gem effect comes second", function()
newBuild()
build.skillsTab:PasteSocketGroup("Vaal Reap of Butchery 20/0 1")
local group = build.skillsTab.socketGroupList[1]
group.includeInFullDPS = true
group.mainActiveSkill = 2
build.buildFlag = true
runCallback("OnFrame")

local calcs = build.calcsTab.calcs
local ordinary, base = calcs.getMiscCalculator(build)
assert.is_true(base.FullDPS > 0)
assert.are.equal(ordinary, calcs.getFullDPSPowerCalculator(build, ordinary))
end)

it("keeps the selected attack calculation when only Reflection contributes", function()
newBuild()
build.itemsTab:CreateDisplayItemFromRaw("Rarity: UNIQUE\nThe Saviour\nLegion Sword\nImplicits: 0\nTriggers Level 20 Reflection when Equipped")
build.itemsTab:AddDisplayItem()
build.skillsTab:PasteSocketGroup("Heavy Strike 20/0 1")
build.mainSocketGroup = 1
runCallback("OnFrame")
for _, group in ipairs(build.skillsTab.socketGroupList) do
group.includeInFullDPS = group.gemList[1].skillId == "UniqueMirageWarriors"
end
build.buildFlag = true
runCallback("OnFrame")

local calcs = build.calcsTab.calcs
local ordinary, base = calcs.getMiscCalculator(build)
assert.is_true(base.FullDPS > 0)
assert.are.equal(ordinary, calcs.getFullDPSPowerCalculator(build, ordinary))
end)
end)
3 changes: 3 additions & 0 deletions src/Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ function CalcsTabClass:PowerBuilder()
-- local timer_start = GetTime()
local useFullDPS = self.powerStat and self.powerStat.stat == "FullDPS"
local calcFunc, calcBase = self:GetMiscCalculator()
if useFullDPS and calcBase.FullDPS ~= nil then
calcFunc = self.calcs.getFullDPSPowerCalculator(self.build, calcFunc)
end
local cache = { }
local distanceMap = { }
local distanceList = { }
Expand Down
40 changes: 40 additions & 0 deletions src/Modules/Calcs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,46 @@ local function getActiveSkillCount(activeSkill)
return 1, true
end

-- The first Full DPS pass must calculate the selected skill before any other
-- skill can read its output. Keep the ordinary pass for source-dependent skills.
local function canSkipPowerReportMainSkill(env)
local foundMain = false
for _, skill in ipairs(env.player.activeSkillList) do
if skill.socketGroup and skill.socketGroup.includeInFullDPS then
local _, enabled = getActiveSkillCount(skill)
if enabled then
if not foundMain then
if skill ~= env.player.mainSkill then
return false
end
foundMain = true
end
if skill.minion or skill.triggeredBy or isTriggered(skill) or skill.activeEffect.grantedEffect.fromItem then
return false
end
end
end
end
return foundMain
end

function calcs.getFullDPSPowerCalculator(build, calculate)
if not canSkipPowerReportMainSkill(calcs.initEnv(build, "CALCULATOR")) then
return calculate
end
return function(override)
local env, cachedPlayerDB, cachedEnemyDB, cachedMinionDB = calcs.initEnv(build, "CALCULATOR", override)
-- A passive change may alter which skills contribute.
if not canSkipPowerReportMainSkill(env) then
return calculate(override, true)
end
local fullDPS = calcs.calcFullDPS(build, "CALCULATOR", override, {
cachedPlayerDB = cachedPlayerDB, cachedEnemyDB = cachedEnemyDB, cachedMinionDB = cachedMinionDB,
})
return { FullDPS = fullDPS.combinedDPS }
end
end

function calcs.calcFullDPS(build, mode, override, specEnv)
local fullEnv, cachedPlayerDB, cachedEnemyDB, cachedMinionDB = calcs.initEnv(build, mode, override, specEnv)
fullEnv.triggerSourceCache = mode == "CALCULATOR" and (specEnv and specEnv.triggerSourceCache or { }) or nil
Expand Down
Loading