2019-02-12 07:03:28 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
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;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-09-06 06:24:00 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-02-12 07:03:28 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty
|
|
|
|
{
|
|
|
|
public class OsuDifficultyCalculator : DifficultyCalculator
|
|
|
|
{
|
|
|
|
private const double difficulty_multiplier = 0.0675;
|
|
|
|
|
|
|
|
public OsuDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
|
|
|
: base(ruleset, beatmap)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-19 08:38:33 +00:00
|
|
|
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
2019-02-12 07:03:28 +00:00
|
|
|
{
|
2019-02-19 08:38:33 +00:00
|
|
|
if (beatmap.HitObjects.Count == 0)
|
2019-05-29 09:22:51 +00:00
|
|
|
return new OsuDifficultyAttributes { Mods = mods, Skills = skills };
|
2019-02-12 07:03:28 +00:00
|
|
|
|
|
|
|
double aimRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier;
|
|
|
|
double speedRating = Math.Sqrt(skills[1].DifficultyValue()) * difficulty_multiplier;
|
|
|
|
double starRating = aimRating + speedRating + Math.Abs(aimRating - speedRating) / 2;
|
|
|
|
|
2019-09-02 08:38:52 +00:00
|
|
|
HitWindows hitWindows = new OsuHitWindows();
|
|
|
|
hitWindows.SetDifficulty(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty);
|
|
|
|
|
2019-02-12 07:03:28 +00:00
|
|
|
// Todo: These int casts are temporary to achieve 1:1 results with osu!stable, and should be removed in the future
|
2019-09-06 06:24:00 +00:00
|
|
|
double hitWindowGreat = (int)(hitWindows.WindowFor(HitResult.Great)) / clockRate;
|
2019-02-19 08:38:33 +00:00
|
|
|
double preempt = (int)BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
2019-02-12 07:03:28 +00:00
|
|
|
|
|
|
|
int maxCombo = beatmap.HitObjects.Count;
|
|
|
|
// Add the ticks + tail of the slider. 1 is subtracted because the head circle would be counted twice (once for the slider itself in the line above)
|
|
|
|
maxCombo += beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count - 1);
|
|
|
|
|
2020-10-02 17:34:41 +00:00
|
|
|
int hitCirclesCount = beatmap.HitObjects.Count(h => h is HitCircle);
|
2020-12-08 13:09:48 +00:00
|
|
|
int spinnerCount = beatmap.HitObjects.Count(h => h is Spinner);
|
2020-10-02 17:34:41 +00:00
|
|
|
|
2019-02-19 08:38:33 +00:00
|
|
|
return new OsuDifficultyAttributes
|
|
|
|
{
|
|
|
|
StarRating = starRating,
|
2019-02-19 08:39:30 +00:00
|
|
|
Mods = mods,
|
2019-02-19 08:38:33 +00:00
|
|
|
AimStrain = aimRating,
|
|
|
|
SpeedStrain = speedRating,
|
|
|
|
ApproachRate = preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5,
|
|
|
|
OverallDifficulty = (80 - hitWindowGreat) / 6,
|
2019-05-29 09:22:51 +00:00
|
|
|
MaxCombo = maxCombo,
|
2020-10-03 14:52:33 +00:00
|
|
|
HitCircleCount = hitCirclesCount,
|
2020-12-08 13:09:48 +00:00
|
|
|
SpinnerCount = spinnerCount,
|
2019-05-29 09:22:51 +00:00
|
|
|
Skills = skills
|
2019-02-19 08:38:33 +00:00
|
|
|
};
|
2019-02-12 07:03:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-19 08:40:35 +00:00
|
|
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
2019-02-12 07:03:28 +00:00
|
|
|
{
|
|
|
|
// The first jump is formed by the first two hitobjects of the map.
|
|
|
|
// If the map has less than two OsuHitObjects, the enumerator will not return anything.
|
|
|
|
for (int i = 1; i < beatmap.HitObjects.Count; i++)
|
|
|
|
{
|
|
|
|
var lastLast = i > 1 ? beatmap.HitObjects[i - 2] : null;
|
|
|
|
var last = beatmap.HitObjects[i - 1];
|
|
|
|
var current = beatmap.HitObjects[i];
|
|
|
|
|
2019-02-19 08:40:35 +00:00
|
|
|
yield return new OsuDifficultyHitObject(current, lastLast, last, clockRate);
|
2019-02-12 07:03:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-19 08:58:02 +00:00
|
|
|
protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[]
|
2019-02-12 07:03:28 +00:00
|
|
|
{
|
|
|
|
new Aim(),
|
|
|
|
new Speed()
|
|
|
|
};
|
|
|
|
|
|
|
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
|
|
|
{
|
|
|
|
new OsuModDoubleTime(),
|
|
|
|
new OsuModHalfTime(),
|
|
|
|
new OsuModEasy(),
|
|
|
|
new OsuModHardRock(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|