2019-02-13 06:49:30 +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.
|
|
|
|
|
|
2020-10-09 12:50:11 +00:00
|
|
|
|
using System;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2021-11-15 09:19:23 +00:00
|
|
|
|
using osu.Game.Extensions;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
|
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Difficulty.Skills;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Difficulty.Skills;
|
2020-10-09 12:50:11 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.MathUtils;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
2020-08-28 10:16:24 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2019-09-06 06:24:00 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Scoring;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-10-09 12:50:11 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2019-09-06 06:24:00 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Difficulty
|
|
|
|
|
{
|
|
|
|
|
public class ManiaDifficultyCalculator : DifficultyCalculator
|
|
|
|
|
{
|
2024-08-05 13:33:42 +00:00
|
|
|
|
private const double difficulty_multiplier = 0.018;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
|
|
|
|
|
private readonly bool isForCurrentRuleset;
|
2020-10-14 11:40:29 +00:00
|
|
|
|
private readonly double originalOverallDifficulty;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
|
2024-10-07 13:38:41 +00:00
|
|
|
|
public override int Version => 20241007;
|
2022-07-20 17:05:18 +00:00
|
|
|
|
|
2021-11-15 09:23:03 +00:00
|
|
|
|
public ManiaDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
|
2019-02-13 06:49:30 +00:00
|
|
|
|
: base(ruleset, beatmap)
|
|
|
|
|
{
|
2021-11-15 09:19:23 +00:00
|
|
|
|
isForCurrentRuleset = beatmap.BeatmapInfo.Ruleset.MatchesOnlineID(ruleset);
|
|
|
|
|
originalOverallDifficulty = beatmap.BeatmapInfo.Difficulty.OverallDifficulty;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-19 08:48:00 +00:00
|
|
|
|
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
2019-02-13 06:49:30 +00:00
|
|
|
|
{
|
2019-02-19 08:48:00 +00:00
|
|
|
|
if (beatmap.HitObjects.Count == 0)
|
2021-11-21 03:12:24 +00:00
|
|
|
|
return new ManiaDifficultyAttributes { Mods = mods };
|
2019-02-13 06:49:30 +00:00
|
|
|
|
|
2019-09-02 08:38:52 +00:00
|
|
|
|
HitWindows hitWindows = new ManiaHitWindows();
|
2021-10-02 03:34:29 +00:00
|
|
|
|
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty);
|
2019-09-02 08:38:52 +00:00
|
|
|
|
|
2023-06-23 16:03:18 +00:00
|
|
|
|
ManiaDifficultyAttributes attributes = new ManiaDifficultyAttributes
|
2019-02-19 08:48:00 +00:00
|
|
|
|
{
|
2024-08-05 13:33:42 +00:00
|
|
|
|
StarRating = skills[0].DifficultyValue() * difficulty_multiplier,
|
2019-02-19 08:48:00 +00:00
|
|
|
|
Mods = mods,
|
2022-02-16 11:07:26 +00:00
|
|
|
|
// In osu-stable mania, rate-adjustment mods don't affect the hit window.
|
|
|
|
|
// This is done the way it is to introduce fractional differences in order to match osu-stable for the time being.
|
2022-02-16 10:50:27 +00:00
|
|
|
|
GreatHitWindow = Math.Ceiling((int)(getHitWindow300(mods) * clockRate) / clockRate),
|
2023-06-13 14:22:27 +00:00
|
|
|
|
MaxCombo = beatmap.HitObjects.Sum(maxComboForObject),
|
2019-02-19 08:48:00 +00:00
|
|
|
|
};
|
2023-06-23 16:03:18 +00:00
|
|
|
|
|
|
|
|
|
return attributes;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 10:16:31 +00:00
|
|
|
|
private static int maxComboForObject(HitObject hitObject)
|
|
|
|
|
{
|
|
|
|
|
if (hitObject is HoldNote hold)
|
|
|
|
|
return 1 + (int)((hold.EndTime - hold.StartTime) / 100);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-19 08:48:00 +00:00
|
|
|
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
2019-02-13 06:49:30 +00:00
|
|
|
|
{
|
2020-10-09 12:50:11 +00:00
|
|
|
|
var sortedObjects = beatmap.HitObjects.ToArray();
|
|
|
|
|
|
|
|
|
|
LegacySortHelper<HitObject>.Sort(sortedObjects, Comparer<HitObject>.Create((a, b) => (int)Math.Round(a.StartTime) - (int)Math.Round(b.StartTime)));
|
|
|
|
|
|
2022-05-22 15:26:22 +00:00
|
|
|
|
List<DifficultyHitObject> objects = new List<DifficultyHitObject>();
|
|
|
|
|
|
2020-10-09 12:50:11 +00:00
|
|
|
|
for (int i = 1; i < sortedObjects.Length; i++)
|
2022-05-26 18:26:14 +00:00
|
|
|
|
objects.Add(new ManiaDifficultyHitObject(sortedObjects[i], sortedObjects[i - 1], clockRate, objects, objects.Count));
|
2022-05-22 15:26:22 +00:00
|
|
|
|
|
|
|
|
|
return objects;
|
2019-02-13 06:49:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-09 12:50:11 +00:00
|
|
|
|
// Sorting is done in CreateDifficultyHitObjects, since the full list of hitobjects is required.
|
|
|
|
|
protected override IEnumerable<DifficultyHitObject> SortObjects(IEnumerable<DifficultyHitObject> input) => input;
|
|
|
|
|
|
2021-06-03 06:09:37 +00:00
|
|
|
|
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate) => new Skill[]
|
2019-02-13 06:49:30 +00:00
|
|
|
|
{
|
2021-10-01 10:57:45 +00:00
|
|
|
|
new Strain(mods, ((ManiaBeatmap)Beatmap).TotalColumns)
|
2020-10-09 12:47:34 +00:00
|
|
|
|
};
|
2019-02-13 06:49:30 +00:00
|
|
|
|
|
|
|
|
|
protected override Mod[] DifficultyAdjustmentMods
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var mods = new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModDoubleTime(),
|
|
|
|
|
new ManiaModHalfTime(),
|
|
|
|
|
new ManiaModEasy(),
|
|
|
|
|
new ManiaModHardRock(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (isForCurrentRuleset)
|
|
|
|
|
return mods;
|
|
|
|
|
|
|
|
|
|
// if we are a convert, we can be played in any key mod.
|
|
|
|
|
return mods.Concat(new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModKey1(),
|
|
|
|
|
new ManiaModKey2(),
|
|
|
|
|
new ManiaModKey3(),
|
|
|
|
|
new ManiaModKey4(),
|
|
|
|
|
new ManiaModKey5(),
|
2020-10-14 08:53:28 +00:00
|
|
|
|
new MultiMod(new ManiaModKey5(), new ManiaModDualStages()),
|
2019-02-13 06:49:30 +00:00
|
|
|
|
new ManiaModKey6(),
|
2020-10-14 08:53:28 +00:00
|
|
|
|
new MultiMod(new ManiaModKey6(), new ManiaModDualStages()),
|
2019-02-13 06:49:30 +00:00
|
|
|
|
new ManiaModKey7(),
|
2020-10-14 08:53:28 +00:00
|
|
|
|
new MultiMod(new ManiaModKey7(), new ManiaModDualStages()),
|
2019-02-13 06:49:30 +00:00
|
|
|
|
new ManiaModKey8(),
|
2020-10-14 08:53:28 +00:00
|
|
|
|
new MultiMod(new ManiaModKey8(), new ManiaModDualStages()),
|
2019-02-13 06:49:30 +00:00
|
|
|
|
new ManiaModKey9(),
|
2020-10-14 08:53:28 +00:00
|
|
|
|
new MultiMod(new ManiaModKey9(), new ManiaModDualStages()),
|
2019-02-13 06:49:30 +00:00
|
|
|
|
}).ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-14 08:53:28 +00:00
|
|
|
|
|
2022-02-16 10:50:27 +00:00
|
|
|
|
private double getHitWindow300(Mod[] mods)
|
2020-10-14 11:40:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (isForCurrentRuleset)
|
|
|
|
|
{
|
|
|
|
|
double od = Math.Min(10.0, Math.Max(0, 10.0 - originalOverallDifficulty));
|
|
|
|
|
return applyModAdjustments(34 + 3 * od, mods);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Math.Round(originalOverallDifficulty) > 4)
|
|
|
|
|
return applyModAdjustments(34, mods);
|
|
|
|
|
|
|
|
|
|
return applyModAdjustments(47, mods);
|
|
|
|
|
|
2022-02-16 10:50:27 +00:00
|
|
|
|
static double applyModAdjustments(double value, Mod[] mods)
|
2020-10-14 11:40:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (mods.Any(m => m is ManiaModHardRock))
|
|
|
|
|
value /= 1.4;
|
|
|
|
|
else if (mods.Any(m => m is ManiaModEasy))
|
|
|
|
|
value *= 1.4;
|
|
|
|
|
|
2022-02-16 10:50:27 +00:00
|
|
|
|
return value;
|
2020-10-14 11:40:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-13 06:49:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|