1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 12:47:24 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs

110 lines
4.4 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2020-05-11 13:50:02 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
2019-09-06 14:24:00 +08:00
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Difficulty.Skills;
using osu.Game.Rulesets.Taiko.Mods;
using osu.Game.Rulesets.Taiko.Objects;
2019-09-06 14:24:00 +08:00
using osu.Game.Rulesets.Taiko.Scoring;
namespace osu.Game.Rulesets.Taiko.Difficulty
{
public class TaikoDifficultyCalculator : DifficultyCalculator
{
2022-06-09 17:22:55 +08:00
private const double difficulty_multiplier = 1.9;
public TaikoDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
: base(ruleset, beatmap)
{
}
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate)
2020-05-11 13:50:02 +08:00
{
return new Skill[]
{
2022-06-09 17:22:55 +08:00
new Peaks(mods)
};
}
2020-05-11 13:50:02 +08:00
2020-08-22 23:51:35 +08:00
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
2020-05-11 13:50:02 +08:00
{
2020-08-22 23:51:35 +08:00
new TaikoModDoubleTime(),
new TaikoModHalfTime(),
new TaikoModEasy(),
new TaikoModHardRock(),
};
2020-05-11 13:50:02 +08:00
2020-08-22 23:51:35 +08:00
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
2020-05-11 13:50:02 +08:00
{
List<DifficultyHitObject> difficultyHitObject = new List<DifficultyHitObject>();
2022-06-06 16:11:26 +08:00
List<TaikoDifficultyHitObject> centreObjects = new List<TaikoDifficultyHitObject>();
List<TaikoDifficultyHitObject> rimObjects = new List<TaikoDifficultyHitObject>();
List<TaikoDifficultyHitObject> noteObjects = new List<TaikoDifficultyHitObject>();
2020-05-11 13:53:42 +08:00
2020-08-22 23:51:35 +08:00
for (int i = 2; i < beatmap.HitObjects.Count; i++)
2020-05-11 13:50:02 +08:00
{
difficultyHitObject.Add(
new TaikoDifficultyHitObject(
2022-06-06 16:11:26 +08:00
beatmap.HitObjects[i], beatmap.HitObjects[i - 1], beatmap.HitObjects[i - 2], clockRate, difficultyHitObject,
centreObjects, rimObjects, noteObjects, difficultyHitObject.Count)
);
2020-05-11 13:50:02 +08:00
}
2022-05-26 18:04:25 +08:00
// Find repetition interval for the final TaikoDifficultyHitObjectColour
// TODO: Might be a good idea to refactor this
2022-06-06 12:42:49 +08:00
((TaikoDifficultyHitObject)difficultyHitObject.Last()).Colour?.FindRepetitionInterval();
return difficultyHitObject;
2020-05-11 13:50:02 +08:00
}
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
{
if (beatmap.HitObjects.Count == 0)
return new TaikoDifficultyAttributes { Mods = mods };
2022-06-09 17:22:55 +08:00
var combined = (Peaks)skills[0];
2020-05-22 19:50:21 +08:00
2022-06-09 17:22:55 +08:00
double colourRating = Math.Sqrt(combined.ColourDifficultyValue * difficulty_multiplier);
double rhythmRating = Math.Sqrt(combined.RhythmDifficultyValue * difficulty_multiplier);
double staminaRating = Math.Sqrt(combined.StaminaDifficultyValue * difficulty_multiplier);
2020-05-22 19:50:21 +08:00
2022-06-09 17:22:55 +08:00
double combinedRating = combined.DifficultyValue();
double starRating = rescale(combinedRating * difficulty_multiplier);
2020-05-11 13:50:02 +08:00
HitWindows hitWindows = new TaikoHitWindows();
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty);
return new TaikoDifficultyAttributes
{
2020-05-11 13:50:02 +08:00
StarRating = starRating,
Mods = mods,
StaminaDifficulty = staminaRating,
RhythmDifficulty = rhythmRating,
ColourDifficulty = colourRating,
2022-06-09 17:22:55 +08:00
PeakDifficulty = combinedRating,
2021-10-10 15:23:35 +08:00
GreatHitWindow = hitWindows.WindowFor(HitResult.Great) / clockRate,
MaxCombo = beatmap.HitObjects.Count(h => h is Hit),
};
}
/// <summary>
/// Applies a final re-scaling of the star rating to bring maps with recorded full combos below 9.5 stars.
/// </summary>
/// <param name="sr">The raw star rating value before re-scaling.</param>
private double rescale(double sr)
{
if (sr < 0) return sr;
return 10.43 * Math.Log(sr / 8 + 1);
}
}
}