mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Use autoplay mod rather than local replay provider
This commit is contained in:
parent
77fddcd2c2
commit
26ce0d05d6
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||||
@ -17,11 +15,11 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNoAdjustment() => CreateModTest(new ModTestData()
|
public void TestNoAdjustment() => CreateModTest(new ModTestData
|
||||||
{
|
{
|
||||||
Mod = new OsuModDifficultyAdjust(),
|
Mod = new OsuModDifficultyAdjust(),
|
||||||
Autoplay = true,
|
Autoplay = true,
|
||||||
PassCondition = () => ((ScoreAccessibleTestPlayer)Player).ScoreProcessor.JudgedHits >= 2
|
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -29,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|||||||
{
|
{
|
||||||
Mod = new OsuModDifficultyAdjust { CircleSize = { Value = 10 } },
|
Mod = new OsuModDifficultyAdjust { CircleSize = { Value = 10 } },
|
||||||
Autoplay = true,
|
Autoplay = true,
|
||||||
PassCondition = () => ((ScoreAccessibleTestPlayer)Player).ScoreProcessor.JudgedHits >= 2
|
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -37,19 +35,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|||||||
{
|
{
|
||||||
Mod = new OsuModDifficultyAdjust { ApproachRate = { Value = 10 } },
|
Mod = new OsuModDifficultyAdjust { ApproachRate = { Value = 10 } },
|
||||||
Autoplay = true,
|
Autoplay = true,
|
||||||
PassCondition = () => ((ScoreAccessibleTestPlayer)Player).ScoreProcessor.JudgedHits >= 2
|
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2
|
||||||
});
|
});
|
||||||
|
|
||||||
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, bool allowFail)
|
|
||||||
: base(score, allowFail)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -27,52 +24,48 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModTestData currentTest;
|
private ModTestData currentTestData;
|
||||||
|
|
||||||
protected void CreateModTest(ModTestData testData) => CreateTest(() =>
|
protected void CreateModTest(ModTestData testData) => CreateTest(() =>
|
||||||
{
|
{
|
||||||
AddStep("set test data", () => currentTest = testData);
|
AddStep("set test data", () => currentTestData = testData);
|
||||||
});
|
});
|
||||||
|
|
||||||
public override void TearDownSteps()
|
public override void TearDownSteps()
|
||||||
{
|
{
|
||||||
AddUntilStep("test passed", () =>
|
AddUntilStep("test passed", () =>
|
||||||
{
|
{
|
||||||
if (currentTest == null)
|
if (currentTestData == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return currentTest.PassCondition?.Invoke() ?? false;
|
return currentTestData.PassCondition?.Invoke() ?? false;
|
||||||
});
|
});
|
||||||
|
|
||||||
base.TearDownSteps();
|
base.TearDownSteps();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTest?.Beatmap ?? base.CreateBeatmap(ruleset);
|
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestData?.Beatmap ?? base.CreateBeatmap(ruleset);
|
||||||
|
|
||||||
protected sealed override Player CreatePlayer(Ruleset ruleset)
|
protected sealed override TestPlayer CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
SelectedMods.Value = SelectedMods.Value.Append(currentTest.Mod).ToArray();
|
var mods = new List<Mod>(SelectedMods.Value);
|
||||||
|
|
||||||
var score = currentTest.Autoplay
|
if (currentTestData.Mod != null)
|
||||||
? ruleset.GetAutoplayMod().CreateReplayScore(Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, SelectedMods.Value))
|
mods.Add(currentTestData.Mod);
|
||||||
: null;
|
if (currentTestData.Autoplay)
|
||||||
|
mods.Add(ruleset.GetAutoplayMod());
|
||||||
|
|
||||||
return CreateReplayPlayer(score, AllowFail);
|
SelectedMods.Value = mods;
|
||||||
|
|
||||||
|
return new ModTestPlayer(AllowFail);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected class ModTestPlayer : TestPlayer
|
||||||
/// Creates the <see cref="TestPlayer"/> for a test case.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="score">The <see cref="Score"/>.</param>
|
|
||||||
/// <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
|
|
||||||
{
|
{
|
||||||
protected override bool AllowFail { get; }
|
protected override bool AllowFail { get; }
|
||||||
|
|
||||||
public TestPlayer(Score score, bool allowFail)
|
public ModTestPlayer(bool allowFail)
|
||||||
: base(score, false, false)
|
: base(false, false)
|
||||||
{
|
{
|
||||||
AllowFail = allowFail;
|
AllowFail = allowFail;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
// 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 osu.Game.Rulesets.UI;
|
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
|
||||||
{
|
|
||||||
public class TestReplayPlayer : ReplayPlayer
|
|
||||||
{
|
|
||||||
protected override bool PauseOnFocusLost { get; }
|
|
||||||
|
|
||||||
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
|
|
||||||
|
|
||||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
|
||||||
|
|
||||||
public TestReplayPlayer(Score score, bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
|
||||||
: base(score, allowPause, showResults)
|
|
||||||
{
|
|
||||||
PauseOnFocusLost = pauseOnFocusLost;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user