osu/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModNoScope.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

157 lines
5.7 KiB
C#
Raw Normal View History

2021-10-24 15:41:35 +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.
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Extensions.ObjectExtensions;
2021-10-24 15:41:35 +00:00
using osu.Framework.Utils;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
2022-10-14 19:14:23 +00:00
using osu.Game.Rulesets.Osu.UI;
2021-10-24 15:41:35 +00:00
using osuTK;
namespace osu.Game.Rulesets.Osu.Tests.Mods
{
public partial class TestSceneOsuModNoScope : OsuModTestScene
{
[Test]
public void TestVisibleDuringBreak()
{
CreateModTest(new ModTestData
{
Mod = new OsuModNoScope
{
HiddenComboCount = { Value = 0 },
},
Autoplay = true,
PassCondition = () => true,
Beatmap = new Beatmap
{
HitObjects = new List<HitObject>
{
new HitCircle
{
Position = new Vector2(300, 192),
StartTime = 1000,
},
new HitCircle
{
Position = new Vector2(300, 192),
StartTime = 5000,
}
},
2024-06-19 05:31:53 +00:00
Breaks =
2021-10-24 15:41:35 +00:00
{
new BreakPeriod(2000, 4000),
}
}
});
AddUntilStep("wait for cursor to hide", () => cursorAlphaAlmostEquals(0));
AddUntilStep("wait for start of break", isBreak);
AddUntilStep("wait for cursor to show", () => cursorAlphaAlmostEquals(1));
AddUntilStep("wait for end of break", () => !isBreak());
AddUntilStep("wait for cursor to hide", () => cursorAlphaAlmostEquals(0));
}
[Test]
public void TestVisibleDuringSpinner()
{
CreateModTest(new ModTestData
{
Mod = new OsuModNoScope
{
HiddenComboCount = { Value = 0 },
},
Autoplay = true,
PassCondition = () => true,
Beatmap = new Beatmap
{
HitObjects = new List<HitObject>
{
new HitCircle
{
Position = new Vector2(300, 192),
StartTime = 1000,
},
new Spinner
{
Position = new Vector2(256, 192),
StartTime = 2000,
Duration = 2000,
},
new HitCircle
{
Position = new Vector2(300, 192),
StartTime = 5000,
}
}
}
});
AddUntilStep("wait for cursor to hide", () => cursorAlphaAlmostEquals(0));
AddUntilStep("wait for start of spinner", isSpinning);
AddUntilStep("wait for cursor to show", () => cursorAlphaAlmostEquals(1));
AddUntilStep("wait for end of spinner", () => !isSpinning());
AddUntilStep("wait for cursor to hide", () => cursorAlphaAlmostEquals(0));
}
[Test]
public void TestVisibleAfterComboBreak()
{
CreateModTest(new ModTestData
{
Mod = new OsuModNoScope
{
HiddenComboCount = { Value = 2 },
},
Autoplay = true,
PassCondition = () => true,
Beatmap = new Beatmap
{
HitObjects = new List<HitObject>
{
new HitCircle
{
Position = new Vector2(100, 192),
StartTime = 1000,
},
new HitCircle
{
Position = new Vector2(150, 192),
StartTime = 3000,
},
new HitCircle
{
Position = new Vector2(200, 192),
StartTime = 5000,
},
}
}
});
AddAssert("cursor must start visible", () => cursorAlphaAlmostEquals(1));
AddUntilStep("wait for combo", () => Player.ScoreProcessor.Combo.Value >= 2);
AddAssert("cursor must dim after combo", () => !cursorAlphaAlmostEquals(1));
2021-11-10 12:50:36 +00:00
AddStep("break combo", () => Player.ScoreProcessor.Combo.Value = 0);
2021-10-24 15:41:35 +00:00
AddUntilStep("wait for cursor to show", () => cursorAlphaAlmostEquals(1));
}
private bool isSpinning() => Player.ChildrenOfType<DrawableSpinner>().SingleOrDefault()?.Progress > 0;
private bool isBreak() => Player.IsBreakTime.Value;
2022-10-14 19:14:23 +00:00
private OsuPlayfield playfield => (OsuPlayfield)Player.DrawableRuleset.Playfield;
private bool cursorAlphaAlmostEquals(float alpha) =>
Precision.AlmostEquals(playfield.Cursor.AsNonNull().Alpha, alpha, 0.1f) &&
2022-10-14 19:14:23 +00:00
Precision.AlmostEquals(playfield.Smoke.Alpha, alpha, 0.1f);
2021-10-24 15:41:35 +00:00
}
}