// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable disable using System; using System.Linq; using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Difficulty.Evaluators; using osu.Game.Rulesets.Osu.Mods; namespace osu.Game.Rulesets.Osu.Difficulty.Skills { /// /// Represents the skill required to memorise and hit every object in a map with the Flashlight mod enabled. /// public class Flashlight : StrainSkill { private readonly bool hasHiddenMod; public Flashlight(Mod[] mods) : base(mods) { hasHiddenMod = mods.Any(m => m is OsuModHidden); } private double skillMultiplier => 0.05; private double strainDecayBase => 0.15; private double currentStrain; private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000); protected override double CalculateInitialStrain(double time, DifficultyHitObject current) => currentStrain * strainDecay(time - current.Previous(0).StartTime); protected override double StrainValueAt(DifficultyHitObject current) { currentStrain *= strainDecay(current.DeltaTime); currentStrain += FlashlightEvaluator.EvaluateDifficultyOf(current, hasHiddenMod) * skillMultiplier; return currentStrain; } public override double DifficultyValue() { double difficulty = GetCurrentStrainPeaks().Sum(); // 1.06 comes from the default DifficultyMultiplier field in OsuStrainSkill, // and it's added here to keep values the same after Flashlight was converted from OsuStrainSkill. return difficulty * 1.06; } } }