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