1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-30 09:07:25 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Skills/OsuStrainSkill.cs

47 lines
1.5 KiB
C#
Raw Normal View History

2021-06-13 21:18:35 +08:00
using System;
using System.Collections.Generic;
using System.Text;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
using System.Linq;
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
2021-06-15 01:18:49 +08:00
public abstract class OsuStrainSkill : StrainSkill
2021-06-13 21:18:35 +08:00
{
2021-06-15 01:22:35 +08:00
protected virtual int ReducedSectionCount => 10;
protected virtual double ReducedStrainBaseline => 0.7;
protected virtual double DifficultyMultiplier => 1.08;
2021-06-15 01:18:49 +08:00
public OsuStrainSkill(Mod[] mods) : base(mods)
2021-06-13 21:18:35 +08:00
{
}
public double OsuDifficultyValue()
{
double difficulty = 0;
double weight = 1;
double strainMultiplier;
List<double> strains = GetCurrentStrainPeaks().OrderByDescending(d => d).ToList();
2021-06-15 01:18:49 +08:00
for (int i = 0; i < ReducedSectionCount; i++)
2021-06-13 21:18:35 +08:00
{
2021-06-15 01:18:49 +08:00
strainMultiplier = ReducedStrainBaseline + Math.Log10(i * 9.0 / ReducedSectionCount + 1) * (1.0 - ReducedStrainBaseline);
2021-06-13 21:18:35 +08:00
strains[i] = strains[i] * strainMultiplier;
}
// Difficulty is the weighted sum of the highest strains from every section.
// We're sorting from highest to lowest strain.
foreach (double strain in strains.OrderByDescending(d => d))
{
difficulty += strain * weight;
weight *= DecayWeight;
}
2021-06-15 01:18:49 +08:00
return difficulty * DifficultyMultiplier;
2021-06-13 21:18:35 +08:00
}
}
}