2017-02-20 00:41:51 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2017-02-20 00:41:51 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
|
{
|
|
|
|
|
public abstract class DifficultyCalculator
|
|
|
|
|
{
|
|
|
|
|
protected double TimeRate = 1;
|
|
|
|
|
|
2017-03-12 13:32:50 +08:00
|
|
|
|
protected abstract double CalculateInternal(Dictionary<string, string> categoryDifficulty);
|
2017-02-20 00:41:51 +08:00
|
|
|
|
|
|
|
|
|
private void loadTiming()
|
|
|
|
|
{
|
|
|
|
|
// TODO: Handle mods
|
2017-03-23 12:52:38 +08:00
|
|
|
|
const int audio_rate = 100;
|
|
|
|
|
TimeRate = audio_rate / 100.0;
|
2017-02-20 00:41:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-25 02:36:17 +08:00
|
|
|
|
public double Calculate(Dictionary<string, string> categoryDifficulty = null)
|
2017-02-20 00:41:51 +08:00
|
|
|
|
{
|
|
|
|
|
loadTiming();
|
2017-02-25 02:36:17 +08:00
|
|
|
|
double difficulty = CalculateInternal(categoryDifficulty);
|
2017-02-20 00:41:51 +08:00
|
|
|
|
return difficulty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class DifficultyCalculator<T> : DifficultyCalculator where T : HitObject
|
|
|
|
|
{
|
2017-08-22 12:34:58 +08:00
|
|
|
|
protected readonly Beatmap Beatmap;
|
|
|
|
|
|
2017-02-20 00:41:51 +08:00
|
|
|
|
protected List<T> Objects;
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
protected DifficultyCalculator(Beatmap beatmap)
|
2017-02-20 00:41:51 +08:00
|
|
|
|
{
|
2017-08-22 12:34:58 +08:00
|
|
|
|
Beatmap = beatmap;
|
|
|
|
|
|
|
|
|
|
Objects = CreateBeatmapConverter().Convert(beatmap).HitObjects;
|
2017-04-26 14:50:08 +08:00
|
|
|
|
|
|
|
|
|
foreach (var h in Objects)
|
2017-10-19 13:05:11 +08:00
|
|
|
|
h.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
|
2017-04-26 14:50:08 +08:00
|
|
|
|
|
2017-02-20 00:41:51 +08:00
|
|
|
|
PreprocessHitObjects();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void PreprocessHitObjects()
|
|
|
|
|
{
|
|
|
|
|
}
|
2017-03-12 13:32:50 +08:00
|
|
|
|
|
2017-04-18 08:38:52 +08:00
|
|
|
|
protected abstract BeatmapConverter<T> CreateBeatmapConverter();
|
2017-02-20 00:41:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|