2021-11-09 22:05:25 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2021-11-10 18:58:36 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2021-11-09 22:05:25 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Edit.Checks
|
|
|
|
{
|
2021-11-09 23:16:29 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Check the spinner/banana shower gaps specified in the osu!catch difficulty specific ranking criteria.
|
|
|
|
/// </summary>
|
|
|
|
public class CheckBananaShowerGap : ICheck
|
2021-11-09 22:05:25 +00:00
|
|
|
{
|
2021-11-10 18:58:36 +00:00
|
|
|
private static readonly Dictionary<DifficultyRating, (int startGap, int endGap)> spinner_delta_threshold = new Dictionary<DifficultyRating, (int, int)>
|
|
|
|
{
|
|
|
|
[DifficultyRating.Easy] = (250, 250),
|
|
|
|
[DifficultyRating.Normal] = (250, 250),
|
|
|
|
[DifficultyRating.Hard] = (125, 250),
|
|
|
|
[DifficultyRating.Insane] = (125, 125),
|
|
|
|
[DifficultyRating.Expert] = (62, 125),
|
|
|
|
[DifficultyRating.ExpertPlus] = (62, 125)
|
|
|
|
};
|
2021-11-09 22:05:25 +00:00
|
|
|
|
|
|
|
public CheckMetadata Metadata { get; } = new CheckMetadata(CheckCategory.Compose, "Too short spinner gap");
|
|
|
|
|
|
|
|
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
|
|
|
{
|
2021-11-09 23:16:29 +00:00
|
|
|
new IssueTemplateBananaShowerStartGap(this),
|
|
|
|
new IssueTemplateBananaShowerEndGap(this)
|
2021-11-09 22:05:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|
|
|
{
|
|
|
|
var hitObjects = context.Beatmap.HitObjects;
|
2021-11-10 18:58:36 +00:00
|
|
|
(int expectedStartDelta, int expectedEndDelta) = spinner_delta_threshold[context.InterpretedDifficulty];
|
2021-11-09 22:05:25 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < hitObjects.Count - 1; ++i)
|
|
|
|
{
|
|
|
|
if (!(hitObjects[i] is BananaShower bananaShower))
|
|
|
|
continue;
|
|
|
|
|
2021-11-09 23:16:29 +00:00
|
|
|
// Skip if the previous hitobject is a banana shower, consecutive spinners are allowed
|
2021-11-09 22:05:25 +00:00
|
|
|
if (i != 0 && hitObjects[i - 1] is CatchHitObject previousHitObject && !(previousHitObject is BananaShower))
|
|
|
|
{
|
|
|
|
double spinnerStartDelta = bananaShower.StartTime - previousHitObject.GetEndTime();
|
|
|
|
|
|
|
|
if (spinnerStartDelta < expectedStartDelta)
|
|
|
|
{
|
2021-11-09 23:16:29 +00:00
|
|
|
yield return new IssueTemplateBananaShowerStartGap(this)
|
2021-11-09 22:05:25 +00:00
|
|
|
.Create(spinnerStartDelta, expectedStartDelta, bananaShower, previousHitObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 23:16:29 +00:00
|
|
|
// Skip if the next hitobject is a banana shower, consecutive spinners are allowed
|
2021-11-09 22:05:25 +00:00
|
|
|
if (hitObjects[i + 1] is CatchHitObject nextHitObject && !(nextHitObject is BananaShower))
|
|
|
|
{
|
|
|
|
double spinnerEndDelta = nextHitObject.StartTime - bananaShower.EndTime;
|
|
|
|
|
|
|
|
if (spinnerEndDelta < expectedEndDelta)
|
|
|
|
{
|
2021-11-09 23:16:29 +00:00
|
|
|
yield return new IssueTemplateBananaShowerEndGap(this)
|
2021-11-09 22:05:25 +00:00
|
|
|
.Create(spinnerEndDelta, expectedEndDelta, bananaShower, nextHitObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 23:16:29 +00:00
|
|
|
public abstract class IssueTemplateBananaShowerGap : IssueTemplate
|
2021-11-09 22:05:25 +00:00
|
|
|
{
|
2021-11-09 23:16:29 +00:00
|
|
|
protected IssueTemplateBananaShowerGap(ICheck check, IssueType issueType, string unformattedMessage)
|
2021-11-09 22:05:25 +00:00
|
|
|
: base(check, issueType, unformattedMessage)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Issue Create(double deltaTime, int expectedDeltaTime, params HitObject[] hitObjects)
|
|
|
|
{
|
|
|
|
return new Issue(hitObjects, this, Math.Floor(deltaTime), expectedDeltaTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 23:16:29 +00:00
|
|
|
public class IssueTemplateBananaShowerStartGap : IssueTemplateBananaShowerGap
|
2021-11-09 22:05:25 +00:00
|
|
|
{
|
2021-11-09 23:16:29 +00:00
|
|
|
public IssueTemplateBananaShowerStartGap(ICheck check)
|
2021-11-09 23:23:14 +00:00
|
|
|
: base(check, IssueType.Problem, "There is only {0} ms between the start of the spinner and the last object, it should not be less than {1} ms.")
|
2021-11-09 22:05:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 23:16:29 +00:00
|
|
|
public class IssueTemplateBananaShowerEndGap : IssueTemplateBananaShowerGap
|
2021-11-09 22:05:25 +00:00
|
|
|
{
|
2021-11-09 23:16:29 +00:00
|
|
|
public IssueTemplateBananaShowerEndGap(ICheck check)
|
2021-11-09 23:23:14 +00:00
|
|
|
: base(check, IssueType.Problem, "There is only {0} ms between the end of the spinner and the next object, it should not be less than {1} ms.")
|
2021-11-09 22:05:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|