1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 11:47:24 +08:00
osu-lazer/osu.Game.Tests/Visual/TestCaseReplay.cs

36 lines
1.3 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
2017-09-18 21:32:49 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2018-01-17 16:35:27 +08:00
using System.ComponentModel;
2017-09-18 21:32:49 +08:00
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
2018-01-17 16:35:27 +08:00
using osu.Game.Rulesets.Mods;
2017-09-18 21:32:49 +08:00
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
{
2018-01-17 16:35:27 +08:00
[Description("Player instantiated with a replay.")]
2017-12-20 20:47:45 +08:00
public class TestCaseReplay : TestCasePlayer
2017-09-18 21:32:49 +08:00
{
protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset)
{
2018-01-17 16:35:27 +08:00
// We create a dummy RulesetContainer just to get the replay - we don't want to use mods here
// to simulate setting a replay rather than having the replay already set for us
2017-09-18 21:32:49 +08:00
beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
var dummyRulesetContainer = ruleset.CreateRulesetContainerWith(beatmap, beatmap.BeatmapInfo.Ruleset.Equals(ruleset.RulesetInfo));
2018-01-17 16:35:27 +08:00
// We have the replay
var replay = dummyRulesetContainer.Replay;
// Reset the mods
beatmap.Mods.Value = beatmap.Mods.Value.Where(m => !(m is ModAutoplay));
return new ReplayPlayer(replay)
{
InitialBeatmap = beatmap
};
2017-09-18 21:32:49 +08:00
}
}
}