2022-01-29 05:59:53 +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.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests.Mods
|
|
|
|
{
|
|
|
|
public partial class TestSceneManiaModHoldOff : ModTestScene
|
|
|
|
{
|
|
|
|
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestMapHasNoHoldNotes()
|
|
|
|
{
|
|
|
|
var testBeatmap = createModdedBeatmap();
|
|
|
|
Assert.False(testBeatmap.HitObjects.OfType<HoldNote>().Any());
|
|
|
|
}
|
|
|
|
|
2022-01-31 01:40:15 +08:00
|
|
|
[Test]
|
|
|
|
public void TestCorrectObjectCount()
|
2022-01-29 13:05:23 +08:00
|
|
|
{
|
2022-01-31 01:40:15 +08:00
|
|
|
// Ensure that the mod produces the expected number of objects when applied.
|
2022-01-29 05:59:53 +08:00
|
|
|
|
|
|
|
var rawBeatmap = createRawBeatmap();
|
2022-01-31 01:40:15 +08:00
|
|
|
var testBeatmap = createModdedBeatmap();
|
2022-01-29 05:59:53 +08:00
|
|
|
|
2023-08-15 18:42:32 +08:00
|
|
|
// Both notes and hold notes account for at least one object
|
|
|
|
int expectedObjectCount = rawBeatmap.HitObjects.Count;
|
2022-01-29 05:59:53 +08:00
|
|
|
|
2022-01-29 13:06:43 +08:00
|
|
|
Assert.That(testBeatmap.HitObjects.Count == expectedObjectCount);
|
2022-01-29 05:59:53 +08:00
|
|
|
}
|
|
|
|
|
2022-01-31 01:40:15 +08:00
|
|
|
private static ManiaBeatmap createModdedBeatmap()
|
2022-01-29 05:59:53 +08:00
|
|
|
{
|
|
|
|
var beatmap = createRawBeatmap();
|
2022-01-31 01:40:15 +08:00
|
|
|
var holdOffMod = new ManiaModHoldOff();
|
2022-01-29 05:59:53 +08:00
|
|
|
|
|
|
|
foreach (var hitObject in beatmap.HitObjects)
|
|
|
|
hitObject.ApplyDefaults(beatmap.ControlPointInfo, new BeatmapDifficulty());
|
|
|
|
|
|
|
|
holdOffMod.ApplyToBeatmap(beatmap);
|
|
|
|
|
2022-01-29 13:06:43 +08:00
|
|
|
return beatmap;
|
2022-01-29 05:59:53 +08:00
|
|
|
}
|
2022-01-29 13:05:23 +08:00
|
|
|
|
2022-01-29 05:59:53 +08:00
|
|
|
private static ManiaBeatmap createRawBeatmap()
|
|
|
|
{
|
2022-10-05 18:14:31 +08:00
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition(1));
|
2022-01-29 13:05:23 +08:00
|
|
|
beatmap.ControlPointInfo.Add(0.0, new TimingControlPoint { BeatLength = 1000 }); // Set BPM to 60
|
2022-01-29 05:59:53 +08:00
|
|
|
|
|
|
|
// Add test hit objects
|
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 4000 });
|
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 4500 });
|
2022-01-29 13:05:23 +08:00
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 125 }); // 1/8 note
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 250 }); // 1/4 note
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 500 }); // 1/2 note
|
2022-01-29 05:59:53 +08:00
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 1000 }); // 1/1 note
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 0, EndTime = 2000 }); // 2/1 note
|
|
|
|
|
|
|
|
return beatmap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|