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;
|
|
|
|
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
|
|
|
|
{
|
|
|
|
private const double star_scaling_factor = 0.018;
|
|
|
|
|
|
|
|
private readonly bool isForCurrentRuleset;
|
|
|
|
|
|
|
|
public ManiaDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
|
|
|
: base(ruleset, beatmap)
|
|
|
|
{
|
|
|
|
isForCurrentRuleset = beatmap.BeatmapInfo.Ruleset.Equals(ruleset.RulesetInfo);
|
|
|
|
}
|
|
|
|
|
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)
|
2019-05-29 09:22:51 +00:00
|
|
|
return new ManiaDifficultyAttributes { Mods = mods, Skills = skills };
|
2019-02-13 06:49:30 +00:00
|
|
|
|
2019-09-02 08:38:52 +00:00
|
|
|
HitWindows hitWindows = new ManiaHitWindows();
|
|
|
|
hitWindows.SetDifficulty(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty);
|
|
|
|
|
2019-02-19 08:48:00 +00:00
|
|
|
return new ManiaDifficultyAttributes
|
|
|
|
{
|
2020-10-09 12:47:34 +00:00
|
|
|
StarRating = skills[0].DifficultyValue() * star_scaling_factor,
|
2019-02-19 08:48:00 +00:00
|
|
|
Mods = mods,
|
|
|
|
// Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be removed in the future
|
2019-09-06 06:24:00 +00:00
|
|
|
GreatHitWindow = (int)(hitWindows.WindowFor(HitResult.Great)) / clockRate,
|
2020-10-14 08:53:28 +00:00
|
|
|
ScoreMultiplier = getScoreMultiplier(beatmap, mods),
|
2020-08-28 10:16:24 +00:00
|
|
|
MaxCombo = beatmap.HitObjects.Sum(h => h is HoldNote ? 2 : 1),
|
2019-05-29 09:22:51 +00:00
|
|
|
Skills = skills
|
2019-02-19 08:48:00 +00:00
|
|
|
};
|
2019-02-13 06:49:30 +00:00
|
|
|
}
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
for (int i = 1; i < sortedObjects.Length; i++)
|
|
|
|
yield return new ManiaDifficultyHitObject(sortedObjects[i], sortedObjects[i - 1], clockRate);
|
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;
|
|
|
|
|
2020-10-09 12:47:34 +00:00
|
|
|
protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[]
|
2019-02-13 06:49:30 +00:00
|
|
|
{
|
2020-10-09 12:47:34 +00:00
|
|
|
new Strain(((ManiaBeatmap)beatmap).TotalColumns)
|
|
|
|
};
|
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
|
|
|
|
|
|
|
private double getScoreMultiplier(IBeatmap beatmap, Mod[] mods)
|
|
|
|
{
|
|
|
|
double scoreMultiplier = 1;
|
|
|
|
|
|
|
|
foreach (var m in mods)
|
|
|
|
{
|
|
|
|
switch (m)
|
|
|
|
{
|
|
|
|
case ManiaModNoFail _:
|
|
|
|
case ManiaModEasy _:
|
|
|
|
case ManiaModHalfTime _:
|
|
|
|
scoreMultiplier *= 0.5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var maniaBeatmap = (ManiaBeatmap)beatmap;
|
|
|
|
int diff = maniaBeatmap.TotalColumns - maniaBeatmap.OriginalTotalColumns;
|
|
|
|
|
|
|
|
if (diff > 0)
|
|
|
|
scoreMultiplier *= 0.9;
|
|
|
|
else if (diff < 0)
|
|
|
|
scoreMultiplier *= 0.9 + 0.04 * diff;
|
|
|
|
|
|
|
|
return scoreMultiplier;
|
|
|
|
}
|
2019-02-13 06:49:30 +00:00
|
|
|
}
|
|
|
|
}
|