2019-11-28 05:03:11 +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;
|
|
|
|
|
using System.Collections.Generic;
|
2022-02-17 04:26:12 +00:00
|
|
|
|
using System.Linq;
|
2019-11-28 05:03:11 +00:00
|
|
|
|
using NUnit.Framework;
|
2022-02-17 04:26:12 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-11-28 05:03:11 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
2019-11-28 13:06:15 +00:00
|
|
|
|
public partial class TestSceneFooterButtonMods : OsuTestScene
|
2019-11-28 05:03:11 +00:00
|
|
|
|
{
|
2022-02-17 04:26:12 +00:00
|
|
|
|
private readonly TestFooterButtonMods footerButtonMods;
|
2019-11-28 05:03:11 +00:00
|
|
|
|
|
2019-11-28 13:06:15 +00:00
|
|
|
|
public TestSceneFooterButtonMods()
|
2019-11-28 05:03:11 +00:00
|
|
|
|
{
|
2022-02-17 04:26:12 +00:00
|
|
|
|
Add(footerButtonMods = new TestFooterButtonMods());
|
2019-11-28 05:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestIncrementMultiplier()
|
|
|
|
|
{
|
2019-12-15 15:42:44 +00:00
|
|
|
|
var hiddenMod = new Mod[] { new OsuModHidden() };
|
|
|
|
|
AddStep(@"Add Hidden", () => changeMods(hiddenMod));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check Hidden multiplier", () => assertModsMultiplier(hiddenMod));
|
2019-12-15 15:42:44 +00:00
|
|
|
|
|
|
|
|
|
var hardRockMod = new Mod[] { new OsuModHardRock() };
|
|
|
|
|
AddStep(@"Add HardRock", () => changeMods(hardRockMod));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check HardRock multiplier", () => assertModsMultiplier(hardRockMod));
|
2019-12-15 15:42:44 +00:00
|
|
|
|
|
|
|
|
|
var doubleTimeMod = new Mod[] { new OsuModDoubleTime() };
|
|
|
|
|
AddStep(@"Add DoubleTime", () => changeMods(doubleTimeMod));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check DoubleTime multiplier", () => assertModsMultiplier(doubleTimeMod));
|
2019-12-15 15:42:44 +00:00
|
|
|
|
|
2021-10-09 12:26:32 +00:00
|
|
|
|
var multipleIncrementMods = new Mod[] { new OsuModDoubleTime(), new OsuModHidden(), new OsuModHardRock() };
|
|
|
|
|
AddStep(@"Add multiple Mods", () => changeMods(multipleIncrementMods));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check multiple mod multiplier", () => assertModsMultiplier(multipleIncrementMods));
|
2019-11-28 05:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecrementMultiplier()
|
|
|
|
|
{
|
2019-12-15 15:42:44 +00:00
|
|
|
|
var easyMod = new Mod[] { new OsuModEasy() };
|
|
|
|
|
AddStep(@"Add Easy", () => changeMods(easyMod));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check Easy multiplier", () => assertModsMultiplier(easyMod));
|
2019-12-15 15:42:44 +00:00
|
|
|
|
|
|
|
|
|
var noFailMod = new Mod[] { new OsuModNoFail() };
|
|
|
|
|
AddStep(@"Add NoFail", () => changeMods(noFailMod));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check NoFail multiplier", () => assertModsMultiplier(noFailMod));
|
2019-12-15 15:42:44 +00:00
|
|
|
|
|
|
|
|
|
var multipleDecrementMods = new Mod[] { new OsuModEasy(), new OsuModNoFail() };
|
|
|
|
|
AddStep(@"Add Multiple Mods", () => changeMods(multipleDecrementMods));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check multiple mod multiplier", () => assertModsMultiplier(multipleDecrementMods));
|
2019-11-28 05:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClearMultiplier()
|
|
|
|
|
{
|
2019-12-15 15:42:44 +00:00
|
|
|
|
var multipleMods = new Mod[] { new OsuModDoubleTime(), new OsuModFlashlight() };
|
|
|
|
|
AddStep(@"Add mods", () => changeMods(multipleMods));
|
2019-11-28 05:03:11 +00:00
|
|
|
|
AddStep(@"Clear selected mod", () => changeMods(Array.Empty<Mod>()));
|
2022-02-17 04:26:12 +00:00
|
|
|
|
AddAssert(@"Check empty multiplier", () => assertModsMultiplier(Array.Empty<Mod>()));
|
2019-11-28 05:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void changeMods(IReadOnlyList<Mod> mods)
|
|
|
|
|
{
|
|
|
|
|
footerButtonMods.Current.Value = mods;
|
|
|
|
|
}
|
2022-02-17 04:26:12 +00:00
|
|
|
|
|
|
|
|
|
private bool assertModsMultiplier(IEnumerable<Mod> mods)
|
|
|
|
|
{
|
|
|
|
|
double multiplier = mods.Aggregate(1.0, (current, mod) => current * mod.ScoreMultiplier);
|
|
|
|
|
string expectedValue = multiplier.Equals(1.0) ? string.Empty : $"{multiplier:N2}x";
|
|
|
|
|
|
|
|
|
|
return expectedValue == footerButtonMods.MultiplierText.Current.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private partial class TestFooterButtonMods : FooterButtonMods
|
|
|
|
|
{
|
|
|
|
|
public new OsuSpriteText MultiplierText => base.MultiplierText;
|
|
|
|
|
}
|
2019-11-28 05:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|