1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 21:17:33 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs

92 lines
3.7 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 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;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
using osu.Game.Rulesets.Catch.Difficulty.Skills;
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;
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 17:19:50 +08:00
namespace osu.Game.Rulesets.Catch.Difficulty
2018-04-13 17:19:50 +08:00
{
public class CatchDifficultyCalculator : DifficultyCalculator
2018-04-13 17:19:50 +08:00
{
private const double star_scaling_factor = 0.145;
2018-05-21 09:49:23 +08:00
protected override int SectionLength => 750;
2018-05-21 09:49:23 +08:00
2018-06-21 11:26:15 +08:00
public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
: base(ruleset, beatmap)
2018-04-13 17:19:50 +08:00
{
}
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
{
if (beatmap.HitObjects.Count == 0)
2019-05-29 17:22:51 +08:00
return new CatchDifficultyAttributes { Mods = mods, Skills = skills };
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
double preempt = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate;
2018-05-21 09:49:23 +08:00
return new CatchDifficultyAttributes
2018-06-21 11:26:15 +08:00
{
StarRating = Math.Sqrt(skills[0].DifficultyValue()) * star_scaling_factor,
2019-02-19 16:45:52 +08:00
Mods = mods,
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)),
Skills = skills
2018-06-21 11:26:15 +08:00
};
2018-05-21 09:49:23 +08:00
}
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
2018-05-21 09:49:23 +08:00
{
float halfCatchWidth;
using (var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty))
{
halfCatchWidth = catcher.CatchWidth * 0.5f;
halfCatchWidth *= 0.8f; // We're only using 80% of the catcher's width to simulate imperfect gameplay.
}
CatchHitObject lastObject = null;
2018-05-21 09:49:23 +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
.SelectMany(obj => obj is JuiceStream stream ? stream.NestedHitObjects : new[] { obj })
.Cast<CatchHitObject>()
.OrderBy(x => x.StartTime))
2018-06-21 15:21:08 +08:00
{
// We want to only consider fruits that contribute to the combo.
if (hitObject is BananaShower || hitObject is TinyDroplet)
continue;
2018-05-21 09:49:23 +08:00
if (lastObject != null)
yield return new CatchDifficultyHitObject(hitObject, lastObject, clockRate, halfCatchWidth);
2019-02-28 12:31:40 +08:00
lastObject = hitObject;
2018-06-21 11:26:15 +08:00
}
2018-05-21 09:49:23 +08:00
}
2019-02-19 16:54:00 +08:00
protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[]
{
new Movement(),
};
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
{
new CatchModDoubleTime(),
new CatchModHalfTime(),
new CatchModHardRock(),
new CatchModEasy(),
};
2018-04-13 17:19:50 +08:00
}
}