diff --git a/spec/System/TestCalcSections_spec.lua b/spec/System/TestCalcSections_spec.lua new file mode 100644 index 00000000000..814b0b7c20d --- /dev/null +++ b/spec/System/TestCalcSections_spec.lua @@ -0,0 +1,92 @@ +describe("TestCalcSections", function() + -- Collect every hit "Effective DPS Mod" cell: the breakdown cells whose enemy rows list the hit taken mods + local function collectEffMultCells(sections) + local cells = { } + for _, section in ipairs(sections) do + for _, subSection in ipairs(section[5] or { }) do + for _, row in ipairs(subSection.data or { }) do + if type(row) == "table" then + for _, cell in ipairs(row) do + if type(cell) == "table" and cell[1] and type(cell[1].breakdown) == "string" and cell[1].breakdown:match("EffMult$") then + for _, entry in ipairs(cell) do + if entry.label == "Enemy modifiers" and type(entry.modName) == "table" and entry.modName[#entry.modName] == "CurseEffectOnSelf" then + table.insert(cells, cell) + break + end + end + end + end + end + end + end + end + return cells + end + + local function findRow(cell, modName) + for _, entry in ipairs(cell) do + if entry.enemy and entry.modName == modName then + return entry + end + end + end + + it("lists damage taken from projectiles, projectile attacks and traps/mines in the effective DPS mod breakdown", function() + local cells = collectEffMultCells(LoadModule("Modules/CalcSections")) + -- 5 damage types for the skill, weapon 1 and weapon 2 sections + assert.are.equals(15, #cells) + for _, cell in ipairs(cells) do + local name = cell[1].breakdown + local projectile = findRow(cell, "ProjectileDamageTaken") + assert.is_not_nil(projectile, name.." is missing ProjectileDamageTaken") + assert.are.equals("projectile", projectile.flag) + local projectileAttack = findRow(cell, "ProjectileAttackDamageTaken") + assert.is_not_nil(projectileAttack, name.." is missing ProjectileAttackDamageTaken") + assert.are.same({ "projectile", "attack" }, projectileAttack.flagList) + local trapMine = findRow(cell, "TrapMineDamageTaken") + assert.is_not_nil(trapMine, name.." is missing TrapMineDamageTaken") + assert.are.same({ "trap", "mine" }, trapMine.anyFlagList) + end + end) + + it("shows Sniper's Mark in the effective DPS mod breakdown only for projectile skills", function() + local fireCell + for _, cell in ipairs(collectEffMultCells(LoadModule("Modules/CalcSections"))) do + if cell[1].breakdown == "FireEffMult" then + fireCell = cell + end + end + -- Sources listed in the Fire Effective DPS Mod breakdown, as the Calcs tab builds it + local function breakdownSources(skill) + newBuild() + build.skillsTab:PasteSocketGroup(skill.." 20/0 1\n") + build.skillsTab:PasteSocketGroup("Sniper's Mark 20/0 1\n") + runCallback("OnFrame") + local breakdown = build.calcsTab.controls.breakdown + breakdown:SetBreakdownData(fireCell) + local sources = { } + for _, section in ipairs(breakdown.sectionList) do + for _, row in ipairs(section.rowList or { }) do + sources[row.mod.name] = row.sourceName + end + end + return sources + end + + local fireball = breakdownSources("Fireball") + assert.are.equals("Sniper's Mark", fireball.ProjectileDamageTaken) + local arc = breakdownSources("Arc") + assert.is_nil(arc.ProjectileDamageTaken) + end) + + it("shows trap and mine damage taken for either a trap or a mine skill", function() + local calcsTab = { calcsEnv = { player = { mainSkill = { skillFlags = { } } } }, input = { } } + local check = function(flags) + calcsTab.calcsEnv.player.mainSkill.skillFlags = flags + return build.calcsTab.CheckFlag(calcsTab, { anyFlagList = { "trap", "mine" } }) + end + assert.is_true(check({ trap = true })) + assert.is_true(check({ mine = true })) + assert.is_nil(check({ projectile = true })) + end) +end) diff --git a/src/Classes/CalcsTab.lua b/src/Classes/CalcsTab.lua index 95386e5f20f..47eb015f89f 100644 --- a/src/Classes/CalcsTab.lua +++ b/src/Classes/CalcsTab.lua @@ -406,6 +406,18 @@ function CalcsTabClass:CheckFlag(obj, actor, player) end end end + if obj.anyFlagList then + local found = false + for _, flag in ipairs(obj.anyFlagList) do + if skillFlags[flag] then + found = true + break + end + end + if not found then + return + end + end if obj.playerFlag and not (player or self.calcsEnv.player).mainSkill.skillFlags[obj.playerFlag] then return end diff --git a/src/Modules/CalcSections.lua b/src/Modules/CalcSections.lua index dbf9dfbc613..f5a738daec0 100644 --- a/src/Modules/CalcSections.lua +++ b/src/Modules/CalcSections.lua @@ -20,6 +20,14 @@ local fireHitTaken = { local chaosHitTaken = { "DamageTaken", "ChaosDamageTaken", "ChaosResist", "CurseEffectOnSelf" } +-- Damage taken from a hit source, summed unfiltered by CalcOffence when the skill has the matching flags +local function sourceDamageTakenRows() + return { + { label = "Enemy modifiers", modName = "ProjectileDamageTaken", enemy = true, flag = "projectile" }, + { label = "Enemy modifiers", modName = "ProjectileAttackDamageTaken", enemy = true, flagList = { "projectile", "attack" } }, + { label = "Enemy modifiers", modName = "TrapMineDamageTaken", enemy = true, anyFlagList = { "trap", "mine" } }, + } +end local physicalConvert = { "SkillPhysicalDamageConvertToLightning", "SkillPhysicalDamageConvertToCold", "SkillPhysicalDamageConvertToFire", "SkillPhysicalDamageConvertToChaos", "PhysicalDamageConvertToLightning", "PhysicalDamageConvertToCold", "PhysicalDamageConvertToFire", "PhysicalDamageConvertToChaos", "NonChaosDamageConvertToChaos", @@ -182,26 +190,31 @@ return { { format = "x {3:output:PhysicalEffMult}", { breakdown = "PhysicalEffMult" }, { label = "Enemy modifiers", modName = physicalHitTaken, enemy = true, cfg = "skill" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:LightningEffMult}", { breakdown = "LightningEffMult" }, { label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration", "IgnoreLightningResistance" }, cfg = "skill" }, { label = "Enemy modifiers", modName = lightningHitTaken, enemy = true, cfg = "skill" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:ColdEffMult}", { breakdown = "ColdEffMult" }, { label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration", "IgnoreColdResistance" }, cfg = "skill" }, { label = "Enemy modifiers", modName = coldHitTaken, enemy = true, cfg = "skill" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:FireEffMult}", { breakdown = "FireEffMult" }, { label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration", "IgnoreFireResistance" }, cfg = "skill" }, { label = "Enemy modifiers", modName = fireHitTaken, enemy = true, cfg = "skill" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:ChaosEffMult}", { breakdown = "ChaosEffMult" }, { label = "Player modifiers", modName = {"ChaosPenetration", "IgnoreChaosResistance"}, cfg = "skill" }, { label = "Enemy modifiers", modName = chaosHitTaken, enemy = true, cfg = "skill" }, + unpack(sourceDamageTakenRows()), }, }, { label = "Skill Hit Damage", textSize = 12, notFlag = "attack", @@ -253,26 +266,31 @@ return { { format = "x {3:output:MainHand.PhysicalEffMult}", { breakdown = "MainHand.PhysicalEffMult" }, { label = "Enemy modifiers", modName = physicalHitTaken, enemy = true, cfg = "weapon1" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:MainHand.LightningEffMult}", { breakdown = "MainHand.LightningEffMult" }, { label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration" }, cfg = "weapon1" }, { label = "Enemy modifiers", modName = lightningHitTaken, enemy = true, cfg = "weapon1" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:MainHand.ColdEffMult}", { breakdown = "MainHand.ColdEffMult" }, { label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration" }, cfg = "weapon1" }, { label = "Enemy modifiers", modName = coldHitTaken, enemy = true, cfg = "weapon1" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:MainHand.FireEffMult}", { breakdown = "MainHand.FireEffMult" }, { label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration" }, cfg = "weapon1" }, { label = "Enemy modifiers", modName = fireHitTaken, enemy = true, cfg = "weapon1" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:MainHand.ChaosEffMult}", { breakdown = "MainHand.ChaosEffMult" }, { label = "Player modifiers", modName = "ChaosPenetration", cfg = "weapon1" }, { label = "Enemy modifiers", modName = chaosHitTaken, enemy = true, cfg = "weapon1" }, + unpack(sourceDamageTakenRows()), }, }, { label = "MH Hit Damage", bgCol = colorCodes.MAINHANDBG, textSize = 12, flag = "weapon1Attack", @@ -324,26 +342,31 @@ return { { format = "x {3:output:OffHand.PhysicalEffMult}", { breakdown = "OffHand.PhysicalEffMult" }, { label = "Enemy modifiers", modName = physicalHitTaken, enemy = true, cfg = "weapon2" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:OffHand.LightningEffMult}", { breakdown = "OffHand.LightningEffMult" }, { label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration" }, cfg = "weapon2" }, { label = "Enemy modifiers", modName = lightningHitTaken, enemy = true, cfg = "weapon2" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:OffHand.ColdEffMult}", { breakdown = "OffHand.ColdEffMult" }, { label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration" }, cfg = "weapon2" }, { label = "Enemy modifiers", modName = coldHitTaken, enemy = true, cfg = "weapon2" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:OffHand.FireEffMult}", { breakdown = "OffHand.FireEffMult" }, { label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration" }, cfg = "weapon2" }, { label = "Enemy modifiers", modName = fireHitTaken, enemy = true, cfg = "weapon2" }, + unpack(sourceDamageTakenRows()), }, { format = "x {3:output:OffHand.ChaosEffMult}", { breakdown = "OffHand.ChaosEffMult" }, { label = "Player modifiers", modName = "ChaosPenetration", cfg = "weapon2" }, { label = "Enemy modifiers", modName = chaosHitTaken, enemy = true, cfg = "weapon2" }, + unpack(sourceDamageTakenRows()), }, }, { label = "OH Hit Damage", bgCol = colorCodes.OFFHANDBG, textSize = 12, flag = "weapon2Attack",