1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 08:32:54 +08:00
osu-lazer/osu.Game/Rulesets/Edit/Checks/CheckDrainLength.cs

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

40 lines
1.3 KiB
C#
Raw Normal View History

2023-07-10 22:29:49 +08: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.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit.Checks.Components;
namespace osu.Game.Rulesets.Edit.Checks
{
public class CheckDrainLength : ICheck
2023-07-10 22:29:49 +08:00
{
private const int min_drain_threshold = 30 * 1000;
public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Compose, "Drain length is too short");
2023-07-10 22:29:49 +08:00
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
{
new IssueTemplateTooShort(this)
};
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
{
double drainTime = context.Beatmap.CalculateDrainLength();
2023-07-10 22:29:49 +08:00
if (drainTime < min_drain_threshold)
yield return new IssueTemplateTooShort(this).Create((int)(drainTime / 1000));
}
public class IssueTemplateTooShort : IssueTemplate
{
public IssueTemplateTooShort(ICheck check)
: base(check, IssueType.Problem, "Less than 30 seconds of drain time, currently {0}.")
{
}
public Issue Create(int drainTimeSeconds) => new Issue(this, drainTimeSeconds);
}
}
}