mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Add too short spinners check and tests
This commit is contained in:
parent
fec9448301
commit
53c0298b5e
@ -0,0 +1,116 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit.Checks;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CheckTooShortSpinnersTest
|
||||||
|
{
|
||||||
|
private CheckTooShortSpinners check;
|
||||||
|
private BeatmapDifficulty difficulty;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
check = new CheckTooShortSpinners();
|
||||||
|
difficulty = new BeatmapDifficulty();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLongSpinner()
|
||||||
|
{
|
||||||
|
Spinner spinner = new Spinner { StartTime = 0, Duration = 4000 };
|
||||||
|
spinner.ApplyDefaults(new ControlPointInfo(), difficulty);
|
||||||
|
|
||||||
|
assertOk(new List<HitObject> { spinner }, difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShortSpinner()
|
||||||
|
{
|
||||||
|
Spinner spinner = new Spinner { StartTime = 0, Duration = 750 };
|
||||||
|
spinner.ApplyDefaults(new ControlPointInfo(), difficulty);
|
||||||
|
|
||||||
|
assertOk(new List<HitObject> { spinner }, difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestVeryShortSpinner()
|
||||||
|
{
|
||||||
|
// Spinners at a certain duration only get 1000 points if approached by auto at a certain angle, making it difficult to determine.
|
||||||
|
Spinner spinner = new Spinner { StartTime = 0, Duration = 475 };
|
||||||
|
spinner.ApplyDefaults(new ControlPointInfo(), difficulty);
|
||||||
|
|
||||||
|
assertVeryShort(new List<HitObject> { spinner }, difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTooShortSpinner()
|
||||||
|
{
|
||||||
|
Spinner spinner = new Spinner { StartTime = 0, Duration = 400 };
|
||||||
|
spinner.ApplyDefaults(new ControlPointInfo(), difficulty);
|
||||||
|
|
||||||
|
assertTooShort(new List<HitObject> { spinner }, difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTooShortSpinnerVaryingOd()
|
||||||
|
{
|
||||||
|
const double duration = 450;
|
||||||
|
|
||||||
|
var difficultyLowOd = new BeatmapDifficulty { OverallDifficulty = 1 };
|
||||||
|
Spinner spinnerLowOd = new Spinner { StartTime = 0, Duration = duration };
|
||||||
|
spinnerLowOd.ApplyDefaults(new ControlPointInfo(), difficultyLowOd);
|
||||||
|
|
||||||
|
var difficultyHighOd = new BeatmapDifficulty { OverallDifficulty = 10 };
|
||||||
|
Spinner spinnerHighOd = new Spinner { StartTime = 0, Duration = duration };
|
||||||
|
spinnerHighOd.ApplyDefaults(new ControlPointInfo(), difficultyHighOd);
|
||||||
|
|
||||||
|
assertOk(new List<HitObject> { spinnerLowOd }, difficultyLowOd);
|
||||||
|
assertTooShort(new List<HitObject> { spinnerHighOd }, difficultyHighOd);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertOk(List<HitObject> hitObjects, BeatmapDifficulty beatmapDifficulty)
|
||||||
|
{
|
||||||
|
Assert.That(check.Run(getContext(hitObjects, beatmapDifficulty)), Is.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertVeryShort(List<HitObject> hitObjects, BeatmapDifficulty beatmapDifficulty)
|
||||||
|
{
|
||||||
|
var issues = check.Run(getContext(hitObjects, beatmapDifficulty)).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.First().Template is CheckTooShortSpinners.IssueTemplateVeryShort);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertTooShort(List<HitObject> hitObjects, BeatmapDifficulty beatmapDifficulty)
|
||||||
|
{
|
||||||
|
var issues = check.Run(getContext(hitObjects, beatmapDifficulty)).ToList();
|
||||||
|
|
||||||
|
Assert.That(issues, Has.Count.EqualTo(1));
|
||||||
|
Assert.That(issues.First().Template is CheckTooShortSpinners.IssueTemplateTooShort);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BeatmapVerifierContext getContext(List<HitObject> hitObjects, BeatmapDifficulty beatmapDifficulty)
|
||||||
|
{
|
||||||
|
var beatmap = new Beatmap<HitObject>
|
||||||
|
{
|
||||||
|
HitObjects = hitObjects,
|
||||||
|
BeatmapInfo = new BeatmapInfo { BaseDifficulty = beatmapDifficulty }
|
||||||
|
};
|
||||||
|
|
||||||
|
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
osu.Game.Rulesets.Osu/Edit/Checks/CheckTooShortSpinners.cs
Normal file
61
osu.Game.Rulesets.Osu/Edit/Checks/CheckTooShortSpinners.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Edit.Checks
|
||||||
|
{
|
||||||
|
public class CheckTooShortSpinners : ICheck
|
||||||
|
{
|
||||||
|
public CheckMetadata Metadata { get; } = new CheckMetadata(CheckCategory.Spread, "Too short spinners");
|
||||||
|
|
||||||
|
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||||
|
{
|
||||||
|
new IssueTemplateTooShort(this)
|
||||||
|
};
|
||||||
|
|
||||||
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
|
{
|
||||||
|
double od = context.Beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty;
|
||||||
|
|
||||||
|
// These are meant to reflect the duration necessary for auto to score at least 1000 points on the spinner.
|
||||||
|
// It's difficult to eliminate warnings here, as auto achieving 1000 points depends on the approach angle on some spinners.
|
||||||
|
double warningThreshold = 500 + (od < 5 ? (5 - od) * -21.8 : (od - 5) * 20); // Anything above this is always ok.
|
||||||
|
double problemThreshold = 450 + (od < 5 ? (5 - od) * -17 : (od - 5) * 17); // Anything below this is never ok.
|
||||||
|
|
||||||
|
foreach (var hitObject in context.Beatmap.HitObjects)
|
||||||
|
{
|
||||||
|
if (!(hitObject is Spinner spinner))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (spinner.Duration < problemThreshold)
|
||||||
|
yield return new IssueTemplateTooShort(this).Create(spinner);
|
||||||
|
else if (spinner.Duration < warningThreshold)
|
||||||
|
yield return new IssueTemplateVeryShort(this).Create(spinner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class IssueTemplateTooShort : IssueTemplate
|
||||||
|
{
|
||||||
|
public IssueTemplateTooShort(ICheck check)
|
||||||
|
: base(check, IssueType.Problem, "This spinner is too short. Auto cannot achieve 1000 points on this.")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Issue Create(Spinner spinner) => new Issue(spinner, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class IssueTemplateVeryShort : IssueTemplate
|
||||||
|
{
|
||||||
|
public IssueTemplateVeryShort(ICheck check)
|
||||||
|
: base(check, IssueType.Warning, "This spinner may be too short. Ensure auto can achieve 1000 points on this.")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Issue Create(Spinner spinner) => new Issue(spinner, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user