2020-03-10 06:00:23 +00:00
|
|
|
// 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.
|
|
|
|
|
2021-01-31 16:19:07 +00:00
|
|
|
using System.Collections.Generic;
|
2020-03-10 06:00:23 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Replays;
|
2021-01-31 16:19:07 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-03-10 06:00:23 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Replays;
|
2020-03-10 06:45:21 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
2020-03-10 06:00:23 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
{
|
2020-03-10 06:45:21 +00:00
|
|
|
public class TestSceneMissHitWindowJudgements : ModTestScene
|
2020-03-10 06:00:23 +00:00
|
|
|
{
|
2020-04-23 10:25:06 +00:00
|
|
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
|
|
|
|
2020-03-10 06:00:23 +00:00
|
|
|
[Test]
|
2020-03-10 06:45:21 +00:00
|
|
|
public void TestMissViaEarlyHit()
|
2020-03-10 06:00:23 +00:00
|
|
|
{
|
2020-03-10 06:45:21 +00:00
|
|
|
var beatmap = new Beatmap
|
2020-03-10 06:00:23 +00:00
|
|
|
{
|
|
|
|
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
|
2020-03-10 06:45:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var hitWindows = new OsuHitWindows();
|
2021-10-02 03:34:29 +00:00
|
|
|
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty);
|
2020-03-10 06:45:21 +00:00
|
|
|
|
|
|
|
CreateModTest(new ModTestData
|
|
|
|
{
|
|
|
|
Autoplay = false,
|
|
|
|
Mod = new TestAutoMod(),
|
|
|
|
Beatmap = new Beatmap
|
|
|
|
{
|
|
|
|
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
|
|
|
|
},
|
2020-10-02 20:57:49 +00:00
|
|
|
PassCondition = () => Player.Results.Count > 0 && Player.Results[0].TimeOffset < -hitWindows.WindowFor(HitResult.Meh) && !Player.Results[0].IsHit
|
2020-03-10 06:45:21 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestMissViaNotHitting()
|
|
|
|
{
|
|
|
|
var beatmap = new Beatmap
|
|
|
|
{
|
|
|
|
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
|
|
|
|
};
|
|
|
|
|
|
|
|
var hitWindows = new OsuHitWindows();
|
2021-10-02 03:34:29 +00:00
|
|
|
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty);
|
2020-03-10 06:45:21 +00:00
|
|
|
|
|
|
|
CreateModTest(new ModTestData
|
|
|
|
{
|
|
|
|
Autoplay = false,
|
|
|
|
Beatmap = beatmap,
|
2020-10-02 20:57:49 +00:00
|
|
|
PassCondition = () => Player.Results.Count > 0 && Player.Results[0].TimeOffset >= hitWindows.WindowFor(HitResult.Meh) && !Player.Results[0].IsHit
|
2020-03-10 06:45:21 +00:00
|
|
|
});
|
|
|
|
}
|
2020-03-10 06:00:23 +00:00
|
|
|
|
|
|
|
private class TestAutoMod : OsuModAutoplay
|
|
|
|
{
|
2022-03-29 07:59:03 +00:00
|
|
|
public override ModReplayData CreateReplayData(IBeatmap beatmap, IReadOnlyList<Mod> mods)
|
2022-03-31 02:34:23 +00:00
|
|
|
=> new ModReplayData(new MissingAutoGenerator(beatmap, mods).Generate(), new ModCreatedUser { Username = "Autoplay" });
|
2020-03-10 06:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class MissingAutoGenerator : OsuAutoGeneratorBase
|
|
|
|
{
|
|
|
|
public new OsuBeatmap Beatmap => (OsuBeatmap)base.Beatmap;
|
|
|
|
|
2021-01-31 16:59:35 +00:00
|
|
|
public MissingAutoGenerator(IBeatmap beatmap, IReadOnlyList<Mod> mods)
|
|
|
|
: base(beatmap, mods)
|
2020-03-10 06:00:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Replay Generate()
|
|
|
|
{
|
|
|
|
AddFrameToReplay(new OsuReplayFrame(-100000, new Vector2(256, 500)));
|
|
|
|
AddFrameToReplay(new OsuReplayFrame(Beatmap.HitObjects[0].StartTime - 1500, new Vector2(256, 500)));
|
|
|
|
AddFrameToReplay(new OsuReplayFrame(Beatmap.HitObjects[0].StartTime - 1500, new Vector2(256, 500)));
|
|
|
|
|
|
|
|
AddFrameToReplay(new OsuReplayFrame(Beatmap.HitObjects[0].StartTime - 450, Beatmap.HitObjects[0].StackedPosition));
|
|
|
|
AddFrameToReplay(new OsuReplayFrame(Beatmap.HitObjects[0].StartTime - 350, Beatmap.HitObjects[0].StackedPosition, OsuAction.LeftButton));
|
|
|
|
AddFrameToReplay(new OsuReplayFrame(Beatmap.HitObjects[0].StartTime - 325, Beatmap.HitObjects[0].StackedPosition));
|
|
|
|
|
|
|
|
return Replay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|