mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Fix player instantiation
Since ModTestScene.CreatePlayer would apply mods in addition to instantiating the player, overriding it could lead to mistakenly also overriding the code that was supposed to set up the test via currentTestData. Make ModTestScene.CreatePlayer sealed, which ensures that mod & autoplay changes are applied, and expose ModTestScene.CreateModPlayer instead which has the expected semantics.
This commit is contained in:
parent
cc5cae4db9
commit
c803de2b49
@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual
|
||||
PassCondition = () => ((PerfectModTestPlayer)Player).CheckFailed(shouldMiss && testCaseData.FailOnMiss)
|
||||
});
|
||||
|
||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new PerfectModTestPlayer();
|
||||
protected override TestPlayer CreateModPlayer(Ruleset ruleset) => new PerfectModTestPlayer();
|
||||
|
||||
private class PerfectModTestPlayer : TestPlayer
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestData?.Beatmap ?? base.CreateBeatmap(ruleset);
|
||||
|
||||
protected override TestPlayer CreatePlayer(Ruleset ruleset)
|
||||
protected sealed override TestPlayer CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
var mods = new List<Mod>(SelectedMods.Value);
|
||||
|
||||
@ -57,9 +57,11 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
SelectedMods.Value = mods;
|
||||
|
||||
return new ModTestPlayer(AllowFail);
|
||||
return CreateModPlayer(ruleset);
|
||||
}
|
||||
|
||||
protected virtual TestPlayer CreateModPlayer(Ruleset ruleset) => new ModTestPlayer(AllowFail);
|
||||
|
||||
protected class ModTestPlayer : TestPlayer
|
||||
{
|
||||
protected override bool AllowFail { get; }
|
||||
|
Loading…
Reference in New Issue
Block a user