2019-01-24 08:43:03 +00: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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2019-09-10 02:44:11 +00:00
|
|
|
using osu.Framework.Testing;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
|
|
|
using osu.Game.Rulesets.Mania.Replays;
|
|
|
|
using osu.Game.Rulesets.Replays;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2019-09-10 02:44:11 +00:00
|
|
|
[HeadlessTest]
|
2019-05-14 19:37:25 +00:00
|
|
|
public class TestSceneAutoGeneration : OsuTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-09-18 05:08:09 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The number of frames which are generated at the start of a replay regardless of hitobject content.
|
|
|
|
/// </summary>
|
2021-04-16 04:06:02 +00:00
|
|
|
private const int frame_offset = 0;
|
2019-09-18 05:08:09 +00:00
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
[Test]
|
|
|
|
public void TestSingleNote()
|
|
|
|
{
|
|
|
|
// | |
|
|
|
|
// | - |
|
|
|
|
// | |
|
|
|
|
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
|
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 1000 });
|
|
|
|
|
|
|
|
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
|
|
|
|
2021-04-16 04:06:02 +00:00
|
|
|
Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time");
|
|
|
|
Assert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect release time");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Special1), "Special1 has not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Special1), "Special1 has not been released");
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSingleHoldNote()
|
|
|
|
{
|
|
|
|
// | |
|
|
|
|
// | * |
|
|
|
|
// | * |
|
|
|
|
// | * |
|
|
|
|
// | |
|
|
|
|
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
|
|
|
|
|
|
|
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
|
|
|
|
2021-04-16 04:06:02 +00:00
|
|
|
Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time");
|
2021-03-22 21:45:18 +00:00
|
|
|
Assert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect release time");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Special1), "Special1 has not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Special1), "Special1 has not been released");
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSingleNoteChord()
|
|
|
|
{
|
|
|
|
// | | |
|
|
|
|
// | - | - |
|
|
|
|
// | | |
|
|
|
|
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 1000 });
|
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 1000, Column = 1 });
|
|
|
|
|
|
|
|
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
|
|
|
|
2021-04-16 04:06:02 +00:00
|
|
|
Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time");
|
|
|
|
Assert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect release time");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been released");
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestHoldNoteChord()
|
|
|
|
{
|
|
|
|
// | | |
|
|
|
|
// | * | * |
|
|
|
|
// | * | * |
|
|
|
|
// | * | * |
|
|
|
|
// | | |
|
|
|
|
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000, Column = 1 });
|
|
|
|
|
|
|
|
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
|
|
|
|
2021-04-16 04:06:02 +00:00
|
|
|
Assert.AreEqual(generated.Frames.Count, frame_offset + 2, "Incorrect number of frames");
|
2019-09-18 05:08:09 +00:00
|
|
|
|
|
|
|
Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect hit time");
|
2021-03-22 21:45:18 +00:00
|
|
|
Assert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect release time");
|
2019-09-18 05:08:09 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been released");
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSingleNoteStair()
|
|
|
|
{
|
|
|
|
// | | |
|
|
|
|
// | | - |
|
|
|
|
// | - | |
|
|
|
|
// | | |
|
|
|
|
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 1000 });
|
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 2000, Column = 1 });
|
|
|
|
|
|
|
|
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
|
|
|
|
2021-04-16 04:06:02 +00:00
|
|
|
Assert.AreEqual(generated.Frames.Count, frame_offset + 4, "Incorrect number of frames");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time");
|
|
|
|
Assert.AreEqual(1000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 1].Time, "Incorrect first note release time");
|
|
|
|
Assert.AreEqual(2000, generated.Frames[frame_offset + 2].Time, "Incorrect second note hit time");
|
|
|
|
Assert.AreEqual(2000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 3].Time, "Incorrect second note release time");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 3], ManiaAction.Key2), "Key2 has not been released");
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestHoldNoteStair()
|
|
|
|
{
|
|
|
|
// | | |
|
|
|
|
// | | * |
|
|
|
|
// | * | * |
|
|
|
|
// | * | * |
|
|
|
|
// | * | |
|
|
|
|
// | | |
|
|
|
|
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 2000, Duration = 2000, Column = 1 });
|
|
|
|
|
|
|
|
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
|
|
|
|
2021-04-16 04:06:02 +00:00
|
|
|
Assert.AreEqual(generated.Frames.Count, frame_offset + 4, "Incorrect number of frames");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time");
|
2021-03-22 21:45:18 +00:00
|
|
|
Assert.AreEqual(3000, generated.Frames[frame_offset + 2].Time, "Incorrect first note release time");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.AreEqual(2000, generated.Frames[frame_offset + 1].Time, "Incorrect second note hit time");
|
2021-03-22 21:45:18 +00:00
|
|
|
Assert.AreEqual(4000, generated.Frames[frame_offset + 3].Time, "Incorrect second note release time");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1, ManiaAction.Key2), "Key1 & Key2 have not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key1), "Key1 has not been released");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has been released");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 3], ManiaAction.Key2), "Key2 has not been released");
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestHoldNoteWithReleasePress()
|
|
|
|
{
|
|
|
|
// | | |
|
|
|
|
// | * | - |
|
|
|
|
// | * | |
|
|
|
|
// | * | |
|
|
|
|
// | | |
|
|
|
|
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
2021-03-22 21:45:18 +00:00
|
|
|
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
2018-04-13 09:19:50 +00:00
|
|
|
beatmap.HitObjects.Add(new Note { StartTime = 3000, Column = 1 });
|
|
|
|
|
|
|
|
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
|
|
|
|
2021-04-16 04:06:02 +00:00
|
|
|
Assert.AreEqual(generated.Frames.Count, frame_offset + 3, "Incorrect number of frames");
|
2019-09-18 05:08:09 +00:00
|
|
|
Assert.AreEqual(1000, generated.Frames[frame_offset].Time, "Incorrect first note hit time");
|
|
|
|
Assert.AreEqual(3000, generated.Frames[frame_offset + 1].Time, "Incorrect second note press time + first note release time");
|
|
|
|
Assert.AreEqual(3000 + ManiaAutoGenerator.RELEASE_DELAY, generated.Frames[frame_offset + 2].Time, "Incorrect second note release time");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset], ManiaAction.Key1), "Key1 has not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key1), "Key1 has not been released");
|
|
|
|
Assert.IsTrue(checkContains(generated.Frames[frame_offset + 1], ManiaAction.Key2), "Key2 has not been pressed");
|
|
|
|
Assert.IsFalse(checkContains(generated.Frames[frame_offset + 2], ManiaAction.Key2), "Key2 has not been released");
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private bool checkContains(ReplayFrame frame, params ManiaAction[] actions) => actions.All(action => ((ManiaReplayFrame)frame).Actions.Contains(action));
|
|
|
|
}
|
|
|
|
}
|