2018-04-13 17:19:50 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
|
|
|
|
[Description("Player instantiated with a replay.")]
|
|
|
|
|
public class TestCaseReplay : TestCasePlayer
|
|
|
|
|
{
|
|
|
|
|
protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset)
|
|
|
|
|
{
|
|
|
|
|
// 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
|
|
|
|
|
beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
|
2018-05-07 09:17:54 +08:00
|
|
|
|
var dummyRulesetContainer = ruleset.CreateRulesetContainerWith(beatmap);
|
2018-04-13 17:19:50 +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
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|