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.Collections.Generic;
|
2018-05-14 10:15:14 +08:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
using osu.Framework.Timing;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2018-05-14 10:15:14 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-05-15 16:38:04 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-05-15 16:38:04 +08:00
|
|
|
namespace osu.Game.Rulesets.Difficulty
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
public abstract class PerformanceCalculator
|
|
|
|
{
|
2018-06-14 15:04:48 +08:00
|
|
|
protected readonly DifficultyAttributes Attributes;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-05-16 00:43:58 +08:00
|
|
|
protected readonly Ruleset Ruleset;
|
2018-04-19 21:04:12 +08:00
|
|
|
protected readonly IBeatmap Beatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
protected readonly Score Score;
|
|
|
|
|
2018-05-14 10:15:14 +08:00
|
|
|
protected double TimeRate { get; private set; } = 1;
|
|
|
|
|
2018-06-14 15:04:48 +08:00
|
|
|
protected PerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, Score score)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-05-16 00:43:58 +08:00
|
|
|
Ruleset = ruleset;
|
|
|
|
Score = score;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-06-14 15:04:48 +08:00
|
|
|
beatmap.Mods.Value = score.Mods;
|
|
|
|
Beatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo);
|
|
|
|
|
|
|
|
Attributes = ruleset.CreateDifficultyCalculator(beatmap).Calculate(score.Mods);
|
2018-05-14 10:15:14 +08:00
|
|
|
|
|
|
|
ApplyMods(score.Mods);
|
|
|
|
}
|
2018-05-14 10:52:22 +08:00
|
|
|
|
2018-05-14 10:15:14 +08:00
|
|
|
protected virtual void ApplyMods(Mod[] mods)
|
|
|
|
{
|
|
|
|
var clock = new StopwatchClock();
|
|
|
|
mods.OfType<IApplicableToClock>().ForEach(m => m.ApplyToClock(clock));
|
|
|
|
TimeRate = clock.Rate;
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|