2019-02-18 13:46:32 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-05-21 09:49:23 +08:00
|
|
|
using System;
|
2018-06-21 11:26:15 +08:00
|
|
|
using System.Collections.Generic;
|
2018-06-21 12:12:22 +08:00
|
|
|
using System.Linq;
|
2018-05-15 16:40:19 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2019-02-18 13:46:32 +08:00
|
|
|
using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Catch.Difficulty.Skills;
|
2019-03-14 22:06:23 +08:00
|
|
|
using osu.Game.Rulesets.Catch.Mods;
|
2018-05-21 09:49:23 +08:00
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2019-02-18 13:46:32 +08:00
|
|
|
using osu.Game.Rulesets.Difficulty;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Skills;
|
2019-02-19 16:42:24 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-05-15 16:40:19 +08:00
|
|
|
namespace osu.Game.Rulesets.Catch.Difficulty
|
2017-02-20 00:41:51 +08:00
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
public class CatchDifficultyCalculator : DifficultyCalculator
|
2017-02-20 00:41:51 +08:00
|
|
|
{
|
2019-04-02 06:28:04 +08:00
|
|
|
private const double star_scaling_factor = 0.153;
|
2018-05-21 09:49:23 +08:00
|
|
|
|
2020-03-13 11:43:01 +08:00
|
|
|
private float halfCatcherWidth;
|
|
|
|
|
2022-07-21 01:05:18 +08:00
|
|
|
public override int Version => 20220701;
|
|
|
|
|
2021-11-15 17:23:03 +08:00
|
|
|
public CatchDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap)
|
2018-06-21 11:26:15 +08:00
|
|
|
: base(ruleset, beatmap)
|
2017-02-20 00:41:51 +08:00
|
|
|
{
|
2019-02-18 13:46:32 +08:00
|
|
|
}
|
2019-02-01 00:57:59 +08:00
|
|
|
|
2019-02-19 16:42:24 +08:00
|
|
|
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
2019-02-18 13:46:32 +08:00
|
|
|
{
|
2019-02-19 16:42:24 +08:00
|
|
|
if (beatmap.HitObjects.Count == 0)
|
2021-11-21 11:12:24 +08:00
|
|
|
return new CatchDifficultyAttributes { Mods = mods };
|
2018-05-21 09:49:23 +08:00
|
|
|
|
2018-06-21 16:32:10 +08:00
|
|
|
// this is the same as osu!, so there's potential to share the implementation... maybe
|
2021-10-02 11:34:29 +08:00
|
|
|
double preempt = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
2018-05-21 09:49:23 +08:00
|
|
|
|
2023-06-24 00:03:18 +08:00
|
|
|
CatchDifficultyAttributes attributes = new CatchDifficultyAttributes
|
2018-06-21 11:26:15 +08:00
|
|
|
{
|
2019-02-19 16:42:24 +08:00
|
|
|
StarRating = Math.Sqrt(skills[0].DifficultyValue()) * star_scaling_factor,
|
2019-02-19 16:45:52 +08:00
|
|
|
Mods = mods,
|
2018-07-05 10:32:09 +08:00
|
|
|
ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0,
|
2019-05-29 17:22:51 +08:00
|
|
|
MaxCombo = beatmap.HitObjects.Count(h => h is Fruit) + beatmap.HitObjects.OfType<JuiceStream>().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet)),
|
2018-06-21 11:26:15 +08:00
|
|
|
};
|
2023-06-24 00:03:18 +08:00
|
|
|
|
|
|
|
return attributes;
|
2018-05-21 09:49:23 +08:00
|
|
|
}
|
|
|
|
|
2019-02-19 16:42:24 +08:00
|
|
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
2018-05-21 09:49:23 +08:00
|
|
|
{
|
2023-01-15 15:22:21 +08:00
|
|
|
CatchHitObject? lastObject = null;
|
2018-05-21 09:49:23 +08:00
|
|
|
|
2022-05-22 23:26:22 +08:00
|
|
|
List<DifficultyHitObject> objects = new List<DifficultyHitObject>();
|
|
|
|
|
2019-05-13 03:31:16 +08:00
|
|
|
// In 2B beatmaps, it is possible that a normal Fruit is placed in the middle of a JuiceStream.
|
|
|
|
foreach (var hitObject in beatmap.HitObjects
|
2021-09-20 00:48:33 +08:00
|
|
|
.SelectMany(obj => obj is JuiceStream stream ? stream.NestedHitObjects.AsEnumerable() : new[] { obj })
|
2019-05-13 04:08:47 +08:00
|
|
|
.Cast<CatchHitObject>()
|
2019-05-13 03:31:16 +08:00
|
|
|
.OrderBy(x => x.StartTime))
|
2018-06-21 15:21:08 +08:00
|
|
|
{
|
2019-05-13 03:31:16 +08:00
|
|
|
// We want to only consider fruits that contribute to the combo.
|
|
|
|
if (hitObject is BananaShower || hitObject is TinyDroplet)
|
2019-02-18 13:46:32 +08:00
|
|
|
continue;
|
2018-05-21 09:49:23 +08:00
|
|
|
|
2019-05-13 03:31:16 +08:00
|
|
|
if (lastObject != null)
|
2022-05-27 02:26:14 +08:00
|
|
|
objects.Add(new CatchDifficultyHitObject(hitObject, lastObject, clockRate, halfCatcherWidth, objects, objects.Count));
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2019-05-13 03:31:16 +08:00
|
|
|
lastObject = hitObject;
|
2018-06-21 11:26:15 +08:00
|
|
|
}
|
2022-05-22 23:26:22 +08:00
|
|
|
|
|
|
|
return objects;
|
2018-05-21 09:49:23 +08:00
|
|
|
}
|
2019-02-18 13:46:32 +08:00
|
|
|
|
2021-06-03 14:09:37 +08:00
|
|
|
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods, double clockRate)
|
2019-02-18 13:46:32 +08:00
|
|
|
{
|
2021-10-02 11:34:29 +08:00
|
|
|
halfCatcherWidth = Catcher.CalculateCatchWidth(beatmap.Difficulty) * 0.5f;
|
2020-03-13 11:43:01 +08:00
|
|
|
|
2020-05-04 14:25:09 +08:00
|
|
|
// For circle sizes above 5.5, reduce the catcher width further to simulate imperfect gameplay.
|
2021-10-02 11:34:29 +08:00
|
|
|
halfCatcherWidth *= 1 - (Math.Max(0, beatmap.Difficulty.CircleSize - 5.5f) * 0.0625f);
|
2020-04-08 11:19:09 +08:00
|
|
|
|
2020-03-13 11:43:01 +08:00
|
|
|
return new Skill[]
|
|
|
|
{
|
2021-06-03 14:09:37 +08:00
|
|
|
new Movement(mods, halfCatcherWidth, clockRate),
|
2020-03-13 11:43:01 +08:00
|
|
|
};
|
|
|
|
}
|
2019-03-14 22:06:23 +08:00
|
|
|
|
2019-03-23 14:57:22 +08:00
|
|
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
2019-03-14 22:06:23 +08:00
|
|
|
{
|
2019-03-23 14:57:22 +08:00
|
|
|
new CatchModDoubleTime(),
|
|
|
|
new CatchModHalfTime(),
|
|
|
|
new CatchModHardRock(),
|
|
|
|
new CatchModEasy(),
|
2019-03-14 22:06:23 +08:00
|
|
|
};
|
2017-02-20 00:41:51 +08:00
|
|
|
}
|
2017-11-16 19:06:32 +08:00
|
|
|
}
|