2018-04-13 17:19:50 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-06-14 14:36:49 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-05-15 16:38:04 +08:00
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-05-15 16:36:29 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
2018-06-06 15:20:17 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
|
2018-05-15 16:36:29 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Difficulty
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
public class OsuDifficultyCalculator : DifficultyCalculator
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private const int section_length = 400;
|
|
|
|
|
private const double difficulty_multiplier = 0.0675;
|
|
|
|
|
|
2018-06-14 14:36:49 +08:00
|
|
|
|
public OsuDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
|
|
|
|
: base(ruleset, beatmap)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 14:36:49 +08:00
|
|
|
|
protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-14 14:36:49 +08:00
|
|
|
|
OsuDifficultyBeatmap difficultyBeatmap = new OsuDifficultyBeatmap(beatmap.HitObjects.Cast<OsuHitObject>().ToList(), timeRate);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Skill[] skills =
|
|
|
|
|
{
|
|
|
|
|
new Aim(),
|
|
|
|
|
new Speed()
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-14 14:36:49 +08:00
|
|
|
|
double sectionLength = section_length * timeRate;
|
2018-05-15 20:26:06 +08:00
|
|
|
|
|
|
|
|
|
// The first object doesn't generate a strain, so we begin with an incremented section end
|
|
|
|
|
double currentSectionEnd = 2 * sectionLength;
|
|
|
|
|
|
2018-06-14 14:36:49 +08:00
|
|
|
|
foreach (OsuDifficultyHitObject h in difficultyBeatmap)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-05-15 20:26:06 +08:00
|
|
|
|
while (h.BaseObject.StartTime > currentSectionEnd)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
foreach (Skill s in skills)
|
|
|
|
|
{
|
|
|
|
|
s.SaveCurrentPeak();
|
2018-05-15 20:26:06 +08:00
|
|
|
|
s.StartNewSectionFrom(currentSectionEnd);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 20:26:06 +08:00
|
|
|
|
currentSectionEnd += sectionLength;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (Skill s in skills)
|
|
|
|
|
s.Process(h);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2018-06-14 14:36:49 +08:00
|
|
|
|
return new OsuDifficultyAttributes(mods, starRating)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-14 14:36:49 +08:00
|
|
|
|
AimStrain = aimRating,
|
|
|
|
|
SpeedStrain = speedRating
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2018-06-06 15:20:17 +08:00
|
|
|
|
|
|
|
|
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new OsuModDoubleTime(),
|
|
|
|
|
new OsuModHalfTime(),
|
|
|
|
|
new OsuModEasy(),
|
|
|
|
|
new OsuModHardRock(),
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|