1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 09:23:06 +08:00

Fix Autoplay = false and AllowFail behavior

This commit is contained in:
voidedWarranties 2020-03-03 17:12:01 -08:00
parent 7a71a48892
commit c3f840cc1a
3 changed files with 13 additions and 8 deletions

View File

@ -42,14 +42,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
PassCondition = () => ((ScoreAccessibleTestPlayer)Player).ScoreProcessor.JudgedHits >= 2
});
protected override TestPlayer CreateReplayPlayer(Score score) => new ScoreAccessibleTestPlayer(score);
protected override TestPlayer CreateReplayPlayer(Score score, bool allowFail) => new ScoreAccessibleTestPlayer(score, allowFail);
private class ScoreAccessibleTestPlayer : TestPlayer
{
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
public ScoreAccessibleTestPlayer(Score score)
: base(score)
public ScoreAccessibleTestPlayer(Score score, bool allowFail)
: base(score, allowFail)
{
}
}

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
@ -56,22 +55,26 @@ namespace osu.Game.Tests.Visual
var score = currentTest.Autoplay
? ruleset.GetAutoplayMod().CreateReplayScore(Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, SelectedMods.Value))
: new Score { Replay = new Replay() };
: null;
return CreateReplayPlayer(score);
return CreateReplayPlayer(score, AllowFail);
}
/// <summary>
/// Creates the <see cref="TestPlayer"/> for a test case.
/// </summary>
/// <param name="score">The <see cref="Score"/>.</param>
protected virtual TestPlayer CreateReplayPlayer(Score score) => new TestPlayer(score);
/// <param name="allowFail">Whether the player can fail.</param>
protected virtual TestPlayer CreateReplayPlayer(Score score, bool allowFail) => new TestPlayer(score, allowFail);
protected class TestPlayer : TestReplayPlayer
{
public TestPlayer(Score score)
protected override bool AllowFail { get; }
public TestPlayer(Score score, bool allowFail)
: base(score, false, false)
{
AllowFail = allowFail;
}
}

View File

@ -68,6 +68,8 @@ namespace osu.Game.Tests.Visual
Beatmap.Value = CreateWorkingBeatmap(beatmap);
SelectedMods.Value = Array.Empty<Mod>();
if (!AllowFail)
{
var noFailMod = ruleset.GetAllMods().FirstOrDefault(m => m is ModNoFail);