1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 14:42:56 +08:00

Rename GameplayState.HasFailed to properly clarify its meaning

This commit is contained in:
Salman Ahmed 2024-01-27 19:09:46 +03:00
parent d38779f962
commit ea641bb8d2
14 changed files with 33 additions and 30 deletions

View File

@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
Player.ScoreProcessor.NewJudgement += _ => judged = true;
});
AddUntilStep("swell judged", () => judged);
AddAssert("not failed", () => !Player.GameplayState.HasFailed);
AddAssert("not failed", () => !Player.GameplayState.ShownFailAnimation);
}
}
}

View File

@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override void AddCheckSteps()
{
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddUntilStep("wait for fail overlay", () => ((FailPlayer)Player).FailOverlay.State.Value == Visibility.Visible);
// The pause screen and fail animation both ramp frequency.

View File

@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override void AddCheckSteps()
{
AddUntilStep("player is playing", () => Player.LocalUserPlaying.Value);
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddAssert("player is not playing", () => !Player.LocalUserPlaying.Value);
AddUntilStep("wait for multiple judgements", () => ((FailPlayer)Player).ScoreProcessor.JudgedHits > 1);
AddAssert("total number of results == 1", () =>

View File

@ -224,7 +224,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestPauseAfterFail()
{
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddUntilStep("fail overlay shown", () => Player.FailOverlayVisible);
confirmClockRunning(false);
@ -240,7 +240,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestExitFromFailedGameplayAfterFailAnimation()
{
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddUntilStep("wait for fail overlay shown", () => Player.FailOverlayVisible);
confirmClockRunning(false);
@ -252,7 +252,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestExitFromFailedGameplayDuringFailAnimation()
{
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
// will finish the fail animation and show the fail/pause screen.
pauseViaBackAction();
@ -266,7 +266,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestQuickRetryFromFailedGameplay()
{
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddStep("quick retry", () => Player.GameplayClockContainer.ChildrenOfType<HotkeyRetryOverlay>().First().Action?.Invoke());
confirmExited();
@ -275,7 +275,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestQuickExitFromFailedGameplay()
{
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
exitViaQuickExitAction();
confirmExited();
@ -380,7 +380,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
confirmClockRunning(false);
confirmNotExited();
AddAssert("player not failed", () => !Player.GameplayState.HasFailed);
AddAssert("player not failed", () => !Player.GameplayState.ShownFailAnimation);
AddAssert("pause overlay shown", () => Player.PauseOverlayVisible);
}

View File

@ -171,7 +171,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddStep("exit", () => Player.Exit());
AddAssert("ensure no submission", () => Player.SubmittedScore == null);
@ -188,7 +188,7 @@ namespace osu.Game.Tests.Visual.Gameplay
addFakeHit();
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddUntilStep("wait for submission", () => Player.SubmittedScore != null);
AddAssert("ensure failing submission", () => Player.SubmittedScore.ScoreInfo.Passed == false);

View File

@ -353,7 +353,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("send failed", () => spectatorClient.SendEndPlay(streamingUser.Id, SpectatedUserState.Failed));
AddUntilStep("state is failed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Failed);
AddUntilStep("wait for player to fail", () => player.GameplayState.HasFailed);
AddUntilStep("wait for player to fail", () => player.GameplayState.ShownFailAnimation);
start();
sendFrames();

View File

@ -102,7 +102,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("set storyboard duration to 0.6s", () => currentStoryboardDuration = 600);
});
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.CurrentTime >= currentStoryboardDuration);
AddUntilStep("wait for fail overlay", () => Player.FailOverlay.State.Value == Visibility.Visible);
}
@ -116,7 +116,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("set storyboard duration to 0s", () => currentStoryboardDuration = 0);
});
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.CurrentTime >= currentStoryboardDuration);
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => Player.GameplayState.ShownFailAnimation);
AddUntilStep("wait for fail overlay", () => Player.FailOverlay.State.Value == Visibility.Visible);
AddUntilStep("wait for button clickable", () => Player.ChildrenOfType<SaveFailedScoreButton>().First().ChildrenOfType<OsuClickableContainer>().First().Enabled.Value);

View File

@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Mods
Position = new Vector2(i * 50)
}).Cast<HitObject>().ToList()
},
PassCondition = () => Player.GameplayState.HasFailed && Player.ScoreProcessor.JudgedHits >= 3
PassCondition = () => Player.GameplayState.ShownFailAnimation && Player.ScoreProcessor.JudgedHits >= 3
});
[Test]
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Mods
Position = new Vector2(i * 50)
}).Cast<HitObject>().ToList()
},
PassCondition = () => Player.GameplayState.HasFailed && Player.ScoreProcessor.JudgedHits >= 1
PassCondition = () => Player.GameplayState.ShownFailAnimation && Player.ScoreProcessor.JudgedHits >= 1
});
}
}

View File

@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for gameplay start", () => player.LocalUserPlaying.Value);
AddStep("set health zero", () => player.ChildrenOfType<HealthProcessor>().Single().Health.Value = 0);
AddUntilStep("wait for fail", () => player.ChildrenOfType<HealthProcessor>().Single().HasFailed);
AddAssert("fail animation not shown", () => !player.GameplayState.HasFailed);
AddAssert("fail animation not shown", () => !player.GameplayState.ShownFailAnimation);
// ensure that even after reaching a failed state, score processor keeps accounting for new hit results.
// the testing method used here (autopilot + hold key) is sort-of dodgy, but works enough.

View File

@ -392,7 +392,7 @@ namespace osu.Game.Tests.Visual.Navigation
return (player = Game.ScreenStack.CurrentScreen as Player) != null;
});
AddUntilStep("wait for fail", () => player.GameplayState.HasFailed);
AddUntilStep("wait for fail", () => player.GameplayState.ShownFailAnimation);
AddUntilStep("wait for track stop", () => !Game.MusicController.IsPlaying);
AddAssert("Ensure time before preview point", () => Game.MusicController.CurrentTrack.CurrentTime < beatmap().BeatmapInfo.Metadata.PreviewTime);

View File

@ -251,7 +251,7 @@ namespace osu.Game.Online.Spectator
if (state.HasPassed)
currentState.State = SpectatedUserState.Passed;
else if (state.HasFailed)
else if (state.ShownFailAnimation)
currentState.State = SpectatedUserState.Failed;
else
currentState.State = SpectatedUserState.Quit;

View File

@ -46,9 +46,12 @@ namespace osu.Game.Screens.Play
public bool HasPassed { get; set; }
/// <summary>
/// Whether the user failed during gameplay. This is only set when the gameplay session has completed due to the fail.
/// Whether the user failed during gameplay and the fail animation has been displayed.
/// </summary>
public bool HasFailed { get; set; }
/// <remarks>
/// In multiplayer, this is never set to <c>true</c> even if the player reached zero health, due to <see cref="PlayerConfiguration.AllowFailAnimation"/> being turned off.
/// </remarks>
public bool ShownFailAnimation { get; set; }
/// <summary>
/// Whether the user quit gameplay without having either passed or failed.

View File

@ -489,7 +489,7 @@ namespace osu.Game.Screens.Play
private void updateGameplayState()
{
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value && !GameplayState.HasFailed;
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value && !GameplayState.ShownFailAnimation;
OverlayActivationMode.Value = inGameplay ? OverlayActivation.Disabled : OverlayActivation.UserTriggered;
localUserPlaying.Value = inGameplay;
}
@ -586,7 +586,7 @@ namespace osu.Game.Screens.Play
if (showDialogFirst && !pauseOrFailDialogVisible)
{
// if the fail animation is currently in progress, accelerate it (it will show the pause dialog on completion).
if (ValidForResume && GameplayState.HasFailed)
if (ValidForResume && GameplayState.ShownFailAnimation)
{
failAnimationContainer.FinishTransforms(true);
return false;
@ -733,7 +733,7 @@ namespace osu.Game.Screens.Play
}
// Only show the completion screen if the player hasn't failed
if (GameplayState.HasFailed)
if (GameplayState.ShownFailAnimation)
return;
GameplayState.HasPassed = true;
@ -922,11 +922,11 @@ namespace osu.Game.Screens.Play
if (Configuration.AllowFailAnimation)
{
Debug.Assert(!GameplayState.HasFailed);
Debug.Assert(!GameplayState.ShownFailAnimation);
Debug.Assert(!GameplayState.HasPassed);
Debug.Assert(!GameplayState.HasQuit);
GameplayState.HasFailed = true;
GameplayState.ShownFailAnimation = true;
updateGameplayState();
@ -1002,13 +1002,13 @@ namespace osu.Game.Screens.Play
// replays cannot be paused and exit immediately
&& !DrawableRuleset.HasReplayLoaded.Value
// cannot pause if we are already in a fail state
&& !GameplayState.HasFailed;
&& !GameplayState.ShownFailAnimation;
private bool canResume =>
// cannot resume from a non-paused state
GameplayClockContainer.IsPaused.Value
// cannot resume if we are already in a fail state
&& !GameplayState.HasFailed
&& !GameplayState.ShownFailAnimation
// already resuming
&& !IsResuming;
@ -1142,7 +1142,7 @@ namespace osu.Game.Screens.Play
{
Debug.Assert(resultsDisplayDelegate == null);
if (!GameplayState.HasFailed)
if (!GameplayState.ShownFailAnimation)
GameplayState.HasQuit = true;
if (DrawableRuleset.ReplayScore == null)

View File

@ -37,7 +37,7 @@ namespace osu.Game.Screens.Play
if (!touchActive.Value)
return;
if (gameplayState.HasPassed || gameplayState.HasFailed || gameplayState.HasQuit)
if (gameplayState.HasPassed || gameplayState.ShownFailAnimation || gameplayState.HasQuit)
return;
if (gameplayState.Score.ScoreInfo.Mods.OfType<ModTouchDevice>().Any())