From 00d7307a0a7d02628d533424d8a2e90a50c9496b Mon Sep 17 00:00:00 2001 From: AdamZ Date: Fri, 27 Nov 2026 12:39:05 -0800 Subject: [PATCH] Skip a duplicate skill calculation in Full DPS Power Reports --- spec/System/TestPowerReport_spec.lua | 56 ++++++++++++++++++++++++++++ src/Classes/CalcsTab.lua | 3 ++ src/Modules/Calcs.lua | 40 ++++++++++++++++++++ 3 files changed, 99 insertions(+) diff --git a/spec/System/TestPowerReport_spec.lua b/spec/System/TestPowerReport_spec.lua index a98126e5751..8d49effcd01 100644 --- a/spec/System/TestPowerReport_spec.lua +++ b/spec/System/TestPowerReport_spec.lua @@ -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) diff --git a/src/Classes/CalcsTab.lua b/src/Classes/CalcsTab.lua index 95386e5f20f..51855d27747 100644 --- a/src/Classes/CalcsTab.lua +++ b/src/Classes/CalcsTab.lua @@ -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 = { } diff --git a/src/Modules/Calcs.lua b/src/Modules/Calcs.lua index 9134e1080f3..50b033f3efd 100644 --- a/src/Modules/Calcs.lua +++ b/src/Modules/Calcs.lua @@ -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