osu/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

96 lines
3.6 KiB
C#
Raw Normal View History

// 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.
2018-04-13 09:19:50 +00:00
2018-05-21 01:49:23 +00:00
using System;
2018-06-21 03:26:15 +00:00
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
using osu.Game.Rulesets.Catch.Difficulty.Skills;
using osu.Game.Rulesets.Catch.Mods;
2018-05-21 01:49:23 +00:00
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Catch.Difficulty
{
public class CatchDifficultyCalculator : DifficultyCalculator
{
2024-08-05 13:33:42 +00:00
private const double difficulty_multiplier = 4.59;
2018-05-21 01:49:23 +00:00
private float halfCatcherWidth;
public override int Version => 20220701;
public CatchDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
2018-06-21 03:26:15 +00:00
: base(ruleset, beatmap)
{
}
2019-01-31 16:57:59 +00:00
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
{
if (beatmap.HitObjects.Count == 0)
return new CatchDifficultyAttributes { Mods = mods };
2018-05-21 01:49:23 +00:00
2018-06-21 08:32:10 +00:00
// this is the same as osu!, so there's potential to share the implementation... maybe
double preempt = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
2018-05-21 01:49:23 +00:00
CatchDifficultyAttributes attributes = new CatchDifficultyAttributes
2018-06-21 03:26:15 +00:00
{
2024-08-05 13:33:42 +00:00
StarRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier,
2019-02-19 08:45:52 +00:00
Mods = mods,
ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0,
2024-09-22 12:01:58 +00:00
MaxCombo = beatmap.GetMaxCombo(),
2018-06-21 03:26:15 +00:00
};
return attributes;
2018-05-21 01:49:23 +00:00
}
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
2018-05-21 01:49:23 +00:00
{
CatchHitObject? lastObject = null;
2018-05-21 01:49:23 +00:00
List<DifficultyHitObject> objects = new List<DifficultyHitObject>();
// In 2B beatmaps, it is possible that a normal Fruit is placed in the middle of a JuiceStream.
foreach (var hitObject in CatchBeatmap.GetPalpableObjects(beatmap.HitObjects))
2018-06-21 07:21:08 +00:00
{
// We want to only consider fruits that contribute to the combo.
if (hitObject is Banana || hitObject is TinyDroplet)
continue;
2018-05-21 01:49:23 +00:00
if (lastObject != null)
2022-05-26 18:26:14 +00:00
objects.Add(new CatchDifficultyHitObject(hitObject, lastObject, clockRate, halfCatcherWidth, objects, objects.Count));
2019-02-28 04:31:40 +00:00
lastObject = hitObject;
2018-06-21 03:26:15 +00:00
}
return objects;
2018-05-21 01:49:23 +00:00
}
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate)
{
halfCatcherWidth = Catcher.CalculateCatchWidth(beatmap.Difficulty) * 0.5f;
// For circle sizes above 5.5, reduce the catcher width further to simulate imperfect gameplay.
halfCatcherWidth *= 1 - (Math.Max(0, beatmap.Difficulty.CircleSize - 5.5f) * 0.0625f);
2020-04-08 03:19:09 +00:00
return new Skill[]
{
new Movement(mods, halfCatcherWidth, clockRate),
};
}
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
{
new CatchModDoubleTime(),
new CatchModHalfTime(),
new CatchModHardRock(),
new CatchModEasy(),
};
}
}