1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 22:22:55 +08:00
osu-lazer/osu.Game.Tests/Visual/Gameplay/TestSceneFailJudgement.cs

55 lines
1.8 KiB
C#
Raw Normal View History

2023-06-23 00:37:25 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2019-08-09 13:04:56 +08:00
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
2020-11-14 00:49:48 +08:00
using osu.Game.Scoring;
2019-08-09 13:04:56 +08:00
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual.Gameplay
{
2022-11-24 13:32:20 +08:00
public partial class TestSceneFailJudgement : TestSceneAllRulesetPlayers
2019-08-09 13:04:56 +08:00
{
protected override Player CreatePlayer(Ruleset ruleset)
{
2019-12-13 20:45:38 +08:00
SelectedMods.Value = Array.Empty<Mod>();
2019-09-19 04:17:24 +08:00
return new FailPlayer();
2019-08-09 13:04:56 +08:00
}
protected override void AddCheckSteps()
{
AddUntilStep("player is playing", () => Player.LocalUserPlaying.Value);
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddAssert("player is not playing", () => !Player.LocalUserPlaying.Value);
2020-11-14 00:49:48 +08:00
AddUntilStep("wait for multiple judgements", () => ((FailPlayer)Player).ScoreProcessor.JudgedHits > 1);
AddAssert("total number of results == 1", () =>
{
var score = new ScoreInfo { Ruleset = Ruleset.Value };
2020-11-14 00:49:48 +08:00
((FailPlayer)Player).ScoreProcessor.PopulateScore(score);
return score.Statistics.Values.Sum() == 1;
});
2019-08-09 13:04:56 +08:00
}
2022-11-24 13:32:20 +08:00
private partial class FailPlayer : TestPlayer
2019-08-09 13:04:56 +08:00
{
2019-12-26 18:18:39 +08:00
public new HealthProcessor HealthProcessor => base.HealthProcessor;
2019-08-09 13:04:56 +08:00
2019-09-19 04:17:24 +08:00
public FailPlayer()
: base(false, false)
2019-08-09 13:04:56 +08:00
{
}
protected override void LoadComplete()
{
base.LoadComplete();
2022-06-24 20:25:23 +08:00
HealthProcessor.FailConditions += (_, _) => true;
2019-08-09 13:04:56 +08:00
}
}
}
}