2019-08-09 05:04:56 +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.Linq;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-11-13 16:49:48 +00:00
|
|
|
using osu.Game.Scoring;
|
2019-08-09 05:04:56 +00:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
2020-01-31 04:54:26 +00:00
|
|
|
public class TestSceneFailJudgement : TestSceneAllRulesetPlayers
|
2019-08-09 05:04:56 +00:00
|
|
|
{
|
|
|
|
protected override Player CreatePlayer(Ruleset ruleset)
|
|
|
|
{
|
2019-12-13 12:45:38 +00:00
|
|
|
SelectedMods.Value = Array.Empty<Mod>();
|
2019-09-18 20:17:24 +00:00
|
|
|
return new FailPlayer();
|
2019-08-09 05:04:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void AddCheckSteps()
|
|
|
|
{
|
2022-04-26 03:02:38 +00:00
|
|
|
AddUntilStep("player is playing", () => Player.LocalUserPlaying.Value);
|
2022-01-25 16:45:11 +00:00
|
|
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
2022-04-26 03:02:38 +00:00
|
|
|
AddAssert("player is not playing", () => !Player.LocalUserPlaying.Value);
|
2020-11-13 16:49:48 +00:00
|
|
|
AddUntilStep("wait for multiple judgements", () => ((FailPlayer)Player).ScoreProcessor.JudgedHits > 1);
|
|
|
|
AddAssert("total number of results == 1", () =>
|
|
|
|
{
|
2022-03-08 03:57:59 +00:00
|
|
|
var score = new ScoreInfo { Ruleset = Ruleset.Value };
|
2021-12-13 07:50:29 +00:00
|
|
|
|
2020-11-13 16:49:48 +00:00
|
|
|
((FailPlayer)Player).ScoreProcessor.PopulateScore(score);
|
|
|
|
|
|
|
|
return score.Statistics.Values.Sum() == 1;
|
|
|
|
});
|
2019-08-09 05:04:56 +00:00
|
|
|
}
|
|
|
|
|
2019-09-18 20:17:24 +00:00
|
|
|
private class FailPlayer : TestPlayer
|
2019-08-09 05:04:56 +00:00
|
|
|
{
|
2019-12-26 10:18:39 +00:00
|
|
|
public new HealthProcessor HealthProcessor => base.HealthProcessor;
|
2019-08-09 05:04:56 +00:00
|
|
|
|
2019-09-18 20:17:24 +00:00
|
|
|
public FailPlayer()
|
|
|
|
: base(false, false)
|
2019-08-09 05:04:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2019-12-19 11:03:14 +00:00
|
|
|
HealthProcessor.FailConditions += (_, __) => true;
|
2019-08-09 05:04:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|