mirror of
https://github.com/ppy/osu.git
synced 2025-01-09 02:24:10 +08:00
Make check ruleset specific
This commit is contained in:
parent
a4822fd615
commit
6fa663c8ca
@ -0,0 +1,158 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Catch.Edit.Checks;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Tests.Editor.Checks
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CheckCatchAbnormalDifficultySettingsTest
|
||||||
|
{
|
||||||
|
private CheckCatchAbnormalDifficultySettings check = null!;
|
||||||
|
|
||||||
|
private IBeatmap beatmap = new Beatmap<HitObject>();
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
check = new CheckCatchAbnormalDifficultySettings();
|
||||||
|
|
||||||
|
beatmap.BeatmapInfo.Ruleset = new CatchRuleset().RulesetInfo;
|
||||||
|
beatmap.Difficulty = new BeatmapDifficulty()
|
||||||
|
{
|
||||||
|
ApproachRate = 5,
|
||||||
|
CircleSize = 5,
|
||||||
|
DrainRate = 5,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNormalSettings()
|
||||||
|
{
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestApproachRateTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.ApproachRate = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCircleSizeTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestApproachRateUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.ApproachRate = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCircleSizeUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestApproachRateOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.ApproachRate = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCircleSizeOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BeatmapVerifierContext getContext()
|
||||||
|
{
|
||||||
|
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,8 @@ namespace osu.Game.Rulesets.Catch.Edit
|
|||||||
{
|
{
|
||||||
private readonly List<ICheck> checks = new List<ICheck>
|
private readonly List<ICheck> checks = new List<ICheck>
|
||||||
{
|
{
|
||||||
new CheckBananaShowerGap()
|
new CheckBananaShowerGap(),
|
||||||
|
new CheckCatchAbnormalDifficultySettings(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Edit.Checks
|
||||||
|
{
|
||||||
|
public class CheckCatchAbnormalDifficultySettings : CheckAbnormalDifficultySettings
|
||||||
|
{
|
||||||
|
public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks catch relevant settings");
|
||||||
|
|
||||||
|
public override IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
var diff = context.Beatmap.Difficulty;
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.ApproachRate))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.ApproachRate))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate);
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.CircleSize))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.CircleSize))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize);
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.DrainRate))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.DrainRate))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mania.Edit.Checks;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CheckManiaAbnormalDifficultySettingsTest
|
||||||
|
{
|
||||||
|
private CheckManiaAbnormalDifficultySettings check = null!;
|
||||||
|
|
||||||
|
private IBeatmap beatmap = new Beatmap<HitObject>();
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
check = new CheckManiaAbnormalDifficultySettings();
|
||||||
|
|
||||||
|
beatmap.BeatmapInfo.Ruleset = new ManiaRuleset().RulesetInfo;
|
||||||
|
beatmap.Difficulty = new BeatmapDifficulty()
|
||||||
|
{
|
||||||
|
OverallDifficulty = 5,
|
||||||
|
DrainRate = 5,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNormalSettings()
|
||||||
|
{
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BeatmapVerifierContext getContext()
|
||||||
|
{
|
||||||
|
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Edit.Checks
|
||||||
|
{
|
||||||
|
public class CheckManiaAbnormalDifficultySettings : CheckAbnormalDifficultySettings
|
||||||
|
{
|
||||||
|
public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks mania relevant settings");
|
||||||
|
|
||||||
|
public override IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
var diff = context.Beatmap.Difficulty;
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.OverallDifficulty))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty);
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.DrainRate))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.DrainRate))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,9 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
private readonly List<ICheck> checks = new List<ICheck>
|
private readonly List<ICheck> checks = new List<ICheck>
|
||||||
{
|
{
|
||||||
|
// Settings
|
||||||
new CheckKeyCount(),
|
new CheckKeyCount(),
|
||||||
|
new CheckManiaAbnormalDifficultySettings(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
@ -0,0 +1,194 @@
|
|||||||
|
// 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 osu.Game.Rulesets.Osu.Edit.Checks;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CheckOsuAbnormalDifficultySettingsTest
|
||||||
|
{
|
||||||
|
private CheckOsuAbnormalDifficultySettings check = null!;
|
||||||
|
|
||||||
|
private IBeatmap beatmap = new Beatmap<HitObject>();
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
check = new CheckOsuAbnormalDifficultySettings();
|
||||||
|
|
||||||
|
beatmap.Difficulty = new BeatmapDifficulty()
|
||||||
|
{
|
||||||
|
ApproachRate = 5,
|
||||||
|
CircleSize = 5,
|
||||||
|
DrainRate = 5,
|
||||||
|
OverallDifficulty = 5,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNormalSettings()
|
||||||
|
{
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestApproachRateTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.ApproachRate = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCircleSizeTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestApproachRateUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.ApproachRate = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCircleSizeUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestApproachRateOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.ApproachRate = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCircleSizeOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.CircleSize = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDrainRateOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.DrainRate = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BeatmapVerifierContext getContext()
|
||||||
|
{
|
||||||
|
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Edit.Checks
|
||||||
|
{
|
||||||
|
public class CheckOsuAbnormalDifficultySettings : CheckAbnormalDifficultySettings
|
||||||
|
{
|
||||||
|
public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks osu relevant settings");
|
||||||
|
public override IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
var diff = context.Beatmap.Difficulty;
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.ApproachRate))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.ApproachRate))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate);
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.OverallDifficulty))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty);
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.CircleSize))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.CircleSize))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize);
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.DrainRate))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.DrainRate))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,9 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
new CheckTimeDistanceEquality(),
|
new CheckTimeDistanceEquality(),
|
||||||
new CheckLowDiffOverlaps(),
|
new CheckLowDiffOverlaps(),
|
||||||
new CheckTooShortSliders(),
|
new CheckTooShortSliders(),
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
new CheckOsuAbnormalDifficultySettings(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
// 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 osu.Game.Rulesets.Taiko.Edit.Checks;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Tests.Editor.Checks
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CheckTaikoAbnormalDifficultySettingsTest
|
||||||
|
{
|
||||||
|
private CheckTaikoAbnormalDifficultySettings check = null!;
|
||||||
|
|
||||||
|
private IBeatmap beatmap = new Beatmap<HitObject>();
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
check = new CheckTaikoAbnormalDifficultySettings();
|
||||||
|
|
||||||
|
beatmap.BeatmapInfo.Ruleset = new TaikoRuleset().RulesetInfo;
|
||||||
|
beatmap.Difficulty = new BeatmapDifficulty()
|
||||||
|
{
|
||||||
|
OverallDifficulty = 5,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNormalSettings()
|
||||||
|
{
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyTwoDecimals()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = 5.55f;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyUnder()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = -10;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverallDifficultyOver()
|
||||||
|
{
|
||||||
|
beatmap.Difficulty.OverallDifficulty = 20;
|
||||||
|
|
||||||
|
var context = getContext();
|
||||||
|
var issues = check.Run(context).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BeatmapVerifierContext getContext()
|
||||||
|
{
|
||||||
|
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Edit.Checks
|
||||||
|
{
|
||||||
|
public class CheckTaikoAbnormalDifficultySettings : CheckAbnormalDifficultySettings
|
||||||
|
{
|
||||||
|
public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks taiko relevant settings");
|
||||||
|
|
||||||
|
public override IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
var diff = context.Beatmap.Difficulty;
|
||||||
|
|
||||||
|
if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty))
|
||||||
|
yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty);
|
||||||
|
|
||||||
|
if (OutOfRange(diff.OverallDifficulty))
|
||||||
|
yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
osu.Game.Rulesets.Taiko/Edit/TaikoBeatmapVerifier.cs
Normal file
24
osu.Game.Rulesets.Taiko/Edit/TaikoBeatmapVerifier.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.Taiko.Edit.Checks;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Edit
|
||||||
|
{
|
||||||
|
public class TaikoBeatmapVerifier : IBeatmapVerifier
|
||||||
|
{
|
||||||
|
private readonly List<ICheck> checks = new List<ICheck>
|
||||||
|
{
|
||||||
|
new CheckTaikoAbnormalDifficultySettings(),
|
||||||
|
};
|
||||||
|
|
||||||
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
return checks.SelectMany(check => check.Run(context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -188,6 +188,8 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
|
|
||||||
public override HitObjectComposer CreateHitObjectComposer() => new TaikoHitObjectComposer(this);
|
public override HitObjectComposer CreateHitObjectComposer() => new TaikoHitObjectComposer(this);
|
||||||
|
|
||||||
|
public override IBeatmapVerifier CreateBeatmapVerifier() => new TaikoBeatmapVerifier();
|
||||||
|
|
||||||
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => new TaikoDifficultyCalculator(RulesetInfo, beatmap);
|
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => new TaikoDifficultyCalculator(RulesetInfo, beatmap);
|
||||||
|
|
||||||
public override PerformanceCalculator CreatePerformanceCalculator() => new TaikoPerformanceCalculator();
|
public override PerformanceCalculator CreatePerformanceCalculator() => new TaikoPerformanceCalculator();
|
||||||
|
Loading…
Reference in New Issue
Block a user