2020-02-01 22:50:33 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-02-01 22:50:33 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2021-11-01 19:12:21 +08:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2020-02-01 22:50:33 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
2022-04-21 07:52:24 +08:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2020-02-01 22:50:33 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2021-01-08 22:56:35 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2020-02-01 22:50:33 +08:00
|
|
|
using osu.Game.Screens.Select.Details;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.SongSelect
|
|
|
|
{
|
|
|
|
[System.ComponentModel.Description("Advanced beatmap statistics display")]
|
|
|
|
public partial class TestSceneAdvancedStats : OsuTestScene
|
|
|
|
{
|
|
|
|
private TestAdvancedStats advancedStats;
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() => Child = advancedStats = new TestAdvancedStats
|
|
|
|
{
|
|
|
|
Width = 500
|
|
|
|
});
|
|
|
|
|
|
|
|
private BeatmapInfo exampleBeatmapInfo => new BeatmapInfo
|
|
|
|
{
|
|
|
|
Ruleset = rulesets.AvailableRulesets.First(),
|
2022-01-18 21:57:39 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2020-02-01 22:50:33 +08:00
|
|
|
{
|
|
|
|
CircleSize = 7.2f,
|
2020-02-01 23:08:24 +08:00
|
|
|
DrainRate = 3,
|
2020-02-01 22:50:33 +08:00
|
|
|
OverallDifficulty = 5.7f,
|
|
|
|
ApproachRate = 3.5f
|
|
|
|
},
|
2021-11-11 16:18:51 +08:00
|
|
|
StarRating = 4.5f
|
2020-02-01 22:50:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNoMod()
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
2020-02-01 22:50:33 +08:00
|
|
|
|
|
|
|
AddStep("no mods selected", () => SelectedMods.Value = Array.Empty<Mod>());
|
|
|
|
|
2022-04-21 07:52:24 +08:00
|
|
|
AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType<SpriteText>().First().Text == BeatmapsetsStrings.ShowStatsCs);
|
2020-02-01 23:08:24 +08:00
|
|
|
AddAssert("circle size bar is white", () => barIsWhite(advancedStats.FirstValue));
|
|
|
|
AddAssert("HP drain bar is white", () => barIsWhite(advancedStats.HpDrain));
|
|
|
|
AddAssert("accuracy bar is white", () => barIsWhite(advancedStats.Accuracy));
|
|
|
|
AddAssert("approach rate bar is white", () => barIsWhite(advancedStats.ApproachRate));
|
2020-02-01 22:50:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestManiaFirstBarText()
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
|
2020-02-01 22:50:33 +08:00
|
|
|
{
|
2022-06-28 00:34:24 +08:00
|
|
|
Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException("osu!mania ruleset not found"),
|
2022-01-18 21:57:39 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2020-02-01 22:50:33 +08:00
|
|
|
{
|
|
|
|
CircleSize = 5,
|
|
|
|
DrainRate = 4.3f,
|
|
|
|
OverallDifficulty = 4.5f,
|
|
|
|
ApproachRate = 3.1f
|
|
|
|
},
|
2021-11-11 16:18:51 +08:00
|
|
|
StarRating = 8
|
2020-02-01 22:50:33 +08:00
|
|
|
});
|
|
|
|
|
2022-04-21 07:52:24 +08:00
|
|
|
AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType<SpriteText>().First().Text == BeatmapsetsStrings.ShowStatsCsMania);
|
2020-02-01 22:50:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestEasyMod()
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
2020-02-01 22:50:33 +08:00
|
|
|
|
|
|
|
AddStep("select EZ mod", () =>
|
|
|
|
{
|
2021-11-01 19:12:21 +08:00
|
|
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance().AsNonNull();
|
2021-09-10 11:00:41 +08:00
|
|
|
SelectedMods.Value = new[] { ruleset.CreateMod<ModEasy>() };
|
2020-02-01 22:50:33 +08:00
|
|
|
});
|
|
|
|
|
2020-02-01 23:08:24 +08:00
|
|
|
AddAssert("circle size bar is blue", () => barIsBlue(advancedStats.FirstValue));
|
|
|
|
AddAssert("HP drain bar is blue", () => barIsBlue(advancedStats.HpDrain));
|
|
|
|
AddAssert("accuracy bar is blue", () => barIsBlue(advancedStats.Accuracy));
|
|
|
|
AddAssert("approach rate bar is blue", () => barIsBlue(advancedStats.ApproachRate));
|
2020-02-01 22:50:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestHardRockMod()
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
2020-02-01 22:50:33 +08:00
|
|
|
|
|
|
|
AddStep("select HR mod", () =>
|
|
|
|
{
|
2021-11-01 19:12:21 +08:00
|
|
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance().AsNonNull();
|
2021-09-10 11:00:41 +08:00
|
|
|
SelectedMods.Value = new[] { ruleset.CreateMod<ModHardRock>() };
|
2020-02-01 22:50:33 +08:00
|
|
|
});
|
|
|
|
|
2020-02-01 23:08:24 +08:00
|
|
|
AddAssert("circle size bar is red", () => barIsRed(advancedStats.FirstValue));
|
|
|
|
AddAssert("HP drain bar is red", () => barIsRed(advancedStats.HpDrain));
|
|
|
|
AddAssert("accuracy bar is red", () => barIsRed(advancedStats.Accuracy));
|
|
|
|
AddAssert("approach rate bar is red", () => barIsRed(advancedStats.ApproachRate));
|
2020-02-01 22:50:33 +08:00
|
|
|
}
|
|
|
|
|
2020-02-01 23:08:24 +08:00
|
|
|
[Test]
|
|
|
|
public void TestUnchangedDifficultyAdjustMod()
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
2020-02-01 23:08:24 +08:00
|
|
|
|
|
|
|
AddStep("select unchanged Difficulty Adjust mod", () =>
|
|
|
|
{
|
2021-11-01 19:12:21 +08:00
|
|
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance().AsNonNull();
|
2022-09-13 08:08:13 +08:00
|
|
|
var difficultyAdjustMod = ruleset.CreateMod<ModDifficultyAdjust>().AsNonNull();
|
2021-10-29 16:58:46 +08:00
|
|
|
difficultyAdjustMod.ReadFromDifficulty(advancedStats.BeatmapInfo.Difficulty);
|
2020-02-01 23:08:24 +08:00
|
|
|
SelectedMods.Value = new[] { difficultyAdjustMod };
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("circle size bar is white", () => barIsWhite(advancedStats.FirstValue));
|
|
|
|
AddAssert("HP drain bar is white", () => barIsWhite(advancedStats.HpDrain));
|
|
|
|
AddAssert("accuracy bar is white", () => barIsWhite(advancedStats.Accuracy));
|
|
|
|
AddAssert("approach rate bar is white", () => barIsWhite(advancedStats.ApproachRate));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangedDifficultyAdjustMod()
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
2020-02-01 23:08:24 +08:00
|
|
|
|
|
|
|
AddStep("select changed Difficulty Adjust mod", () =>
|
|
|
|
{
|
2021-11-01 19:12:21 +08:00
|
|
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance().AsNonNull();
|
2022-09-13 08:08:13 +08:00
|
|
|
var difficultyAdjustMod = ruleset.CreateMod<OsuModDifficultyAdjust>().AsNonNull();
|
2021-10-29 16:58:46 +08:00
|
|
|
var originalDifficulty = advancedStats.BeatmapInfo.Difficulty;
|
2021-01-08 22:56:35 +08:00
|
|
|
|
|
|
|
difficultyAdjustMod.ReadFromDifficulty(originalDifficulty);
|
|
|
|
difficultyAdjustMod.DrainRate.Value = originalDifficulty.DrainRate - 0.5f;
|
|
|
|
difficultyAdjustMod.ApproachRate.Value = originalDifficulty.ApproachRate + 2.2f;
|
2020-02-01 23:08:24 +08:00
|
|
|
SelectedMods.Value = new[] { difficultyAdjustMod };
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("circle size bar is white", () => barIsWhite(advancedStats.FirstValue));
|
|
|
|
AddAssert("drain rate bar is blue", () => barIsBlue(advancedStats.HpDrain));
|
|
|
|
AddAssert("accuracy bar is white", () => barIsWhite(advancedStats.Accuracy));
|
|
|
|
AddAssert("approach rate bar is red", () => barIsRed(advancedStats.ApproachRate));
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool barIsWhite(AdvancedStats.StatisticRow row) => row.ModBar.AccentColour == Color4.White;
|
|
|
|
private bool barIsBlue(AdvancedStats.StatisticRow row) => row.ModBar.AccentColour == colours.BlueDark;
|
|
|
|
private bool barIsRed(AdvancedStats.StatisticRow row) => row.ModBar.AccentColour == colours.Red;
|
|
|
|
|
2020-02-01 22:50:33 +08:00
|
|
|
private partial class TestAdvancedStats : AdvancedStats
|
|
|
|
{
|
|
|
|
public new StatisticRow FirstValue => base.FirstValue;
|
|
|
|
public new StatisticRow HpDrain => base.HpDrain;
|
|
|
|
public new StatisticRow Accuracy => base.Accuracy;
|
|
|
|
public new StatisticRow ApproachRate => base.ApproachRate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|