mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Add mania keycount check
This commit is contained in:
parent
4904c49c38
commit
c605e463a4
@ -0,0 +1,75 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mania.Edit.Checks;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CheckKeyCountTest
|
||||||
|
{
|
||||||
|
private CheckKeyCount check = null!;
|
||||||
|
|
||||||
|
private IBeatmap beatmap = null!;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
check = new CheckKeyCount();
|
||||||
|
|
||||||
|
beatmap = new Beatmap<HitObject>()
|
||||||
|
{
|
||||||
|
BeatmapInfo = new BeatmapInfo
|
||||||
|
{
|
||||||
|
Ruleset = new ManiaRuleset().RulesetInfo
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestKeycountFour()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = 4;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestKeycountSmallerThanFour()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = 1;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckKeyCount.IssueTemplateKeycountTooLow);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestKeycountHigherThanTen()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = 11;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckKeyCount.IssueTemplateKeycountNonStandard);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BeatmapVerifierContext getContext()
|
||||||
|
{
|
||||||
|
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
55
osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs
Normal file
55
osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// 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.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit.Checks
|
||||||
|
{
|
||||||
|
public class CheckKeyCount : ICheck
|
||||||
|
{
|
||||||
|
public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Check mania keycount.");
|
||||||
|
|
||||||
|
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||||
|
{
|
||||||
|
new IssueTemplateKeycountTooLow(this),
|
||||||
|
new IssueTemplateKeycountNonStandard(this),
|
||||||
|
};
|
||||||
|
|
||||||
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
var diff = context.Beatmap.Difficulty;
|
||||||
|
|
||||||
|
if (diff.CircleSize < 4)
|
||||||
|
{
|
||||||
|
yield return new IssueTemplateKeycountTooLow(this).Create(diff.CircleSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diff.CircleSize > 10)
|
||||||
|
{
|
||||||
|
yield return new IssueTemplateKeycountNonStandard(this).Create(diff.CircleSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class IssueTemplateKeycountTooLow : IssueTemplate
|
||||||
|
{
|
||||||
|
public IssueTemplateKeycountTooLow(ICheck check)
|
||||||
|
: base(check, IssueType.Problem, "Key count is {0} and must be 4 or higher.")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Issue Create(float current) => new Issue(this, current);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class IssueTemplateKeycountNonStandard : IssueTemplate
|
||||||
|
{
|
||||||
|
public IssueTemplateKeycountNonStandard(ICheck check)
|
||||||
|
: base(check, IssueType.Warning, "Key count {0} is higher than 10.")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Issue Create(float current) => new Issue(this, current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs
Normal file
24
osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
using osu.Game.Rulesets.Mania.Edit.Checks;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit
|
||||||
|
{
|
||||||
|
public class ManiaBeatmapVerifier : IBeatmapVerifier
|
||||||
|
{
|
||||||
|
private readonly List<ICheck> checks = new List<ICheck>
|
||||||
|
{
|
||||||
|
new CheckKeyCount(),
|
||||||
|
};
|
||||||
|
|
||||||
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
return checks.SelectMany(check => check.Run(context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -65,6 +65,8 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
|
|
||||||
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
||||||
|
|
||||||
|
public override IBeatmapVerifier CreateBeatmapVerifier() => new ManiaBeatmapVerifier();
|
||||||
|
|
||||||
public override ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
|
public override ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
switch (skin)
|
switch (skin)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit.Checks
|
namespace osu.Game.Rulesets.Edit.Checks
|
||||||
{
|
{
|
||||||
public class CheckAbnormalDifficultySettings : ICheck
|
public class CheckAbnormalDifficultySettings : ICheck
|
||||||
@ -20,6 +19,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
{
|
{
|
||||||
var diff = context.Beatmap.Difficulty;
|
var diff = context.Beatmap.Difficulty;
|
||||||
|
string ruleset = context.Beatmap.BeatmapInfo.Ruleset.ShortName;
|
||||||
|
|
||||||
if (hasMoreThanOneDecimalPlace(diff.ApproachRate))
|
if (hasMoreThanOneDecimalPlace(diff.ApproachRate))
|
||||||
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate);
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate);
|
||||||
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
if (hasMoreThanOneDecimalPlace(diff.CircleSize))
|
if (hasMoreThanOneDecimalPlace(diff.CircleSize))
|
||||||
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize);
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize);
|
||||||
|
|
||||||
if (isOutOfRange(diff.CircleSize))
|
if (ruleset != "mania" && isOutOfRange(diff.CircleSize))
|
||||||
yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize);
|
yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user