2020-08-11 19:28:00 +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.
|
|
|
|
|
2020-08-11 19:55:50 +00:00
|
|
|
using System;
|
2020-08-11 19:28:00 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Testing;
|
2020-08-11 19:55:50 +00:00
|
|
|
using osu.Framework.Utils;
|
2020-08-11 19:28:00 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2022-02-22 05:11:22 +00:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-08-11 19:55:50 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-08-11 19:28:00 +00:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2022-02-22 05:11:22 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2020-08-11 19:28:00 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2020-12-04 11:21:53 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
2022-02-22 05:11:22 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-08-11 19:28:00 +00:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|
|
|
{
|
|
|
|
public partial class TestSceneOsuModSpunOut : OsuModTestScene
|
|
|
|
{
|
2020-08-11 19:55:50 +00:00
|
|
|
protected override bool AllowFail => true;
|
|
|
|
|
2020-08-11 19:28:00 +00:00
|
|
|
[Test]
|
2022-02-23 07:56:50 +00:00
|
|
|
public void TestSpinnerAutoCompleted()
|
2020-08-11 19:28:00 +00:00
|
|
|
{
|
2022-07-20 12:34:55 +00:00
|
|
|
DrawableSpinner? spinner = null;
|
|
|
|
JudgementResult? lastResult = null;
|
2022-02-23 07:56:50 +00:00
|
|
|
|
|
|
|
CreateModTest(new ModTestData
|
|
|
|
{
|
|
|
|
Mod = new OsuModSpunOut(),
|
|
|
|
Autoplay = false,
|
|
|
|
Beatmap = singleSpinnerBeatmap,
|
|
|
|
PassCondition = () =>
|
|
|
|
{
|
|
|
|
// Bind to the first spinner's results for further tracking.
|
|
|
|
if (spinner == null)
|
|
|
|
{
|
|
|
|
// We only care about the first spinner we encounter for this test.
|
|
|
|
var nextSpinner = Player.ChildrenOfType<DrawableSpinner>().SingleOrDefault();
|
|
|
|
|
|
|
|
if (nextSpinner == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
lastResult = null;
|
|
|
|
|
|
|
|
spinner = nextSpinner;
|
2022-06-24 12:25:23 +00:00
|
|
|
spinner.OnNewResult += (_, result) => lastResult = result;
|
2022-02-23 07:56:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return lastResult?.Type == HitResult.Great;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-08-11 19:55:50 +00:00
|
|
|
|
|
|
|
[TestCase(null)]
|
|
|
|
[TestCase(typeof(OsuModDoubleTime))]
|
|
|
|
[TestCase(typeof(OsuModHalfTime))]
|
2022-07-20 12:34:55 +00:00
|
|
|
public void TestSpinRateUnaffectedByMods(Type? additionalModType)
|
2020-08-11 19:55:50 +00:00
|
|
|
{
|
|
|
|
var mods = new List<Mod> { new OsuModSpunOut() };
|
|
|
|
if (additionalModType != null)
|
2022-07-20 12:34:55 +00:00
|
|
|
mods.Add((Mod)Activator.CreateInstance(additionalModType)!);
|
2020-08-11 19:55:50 +00:00
|
|
|
|
|
|
|
CreateModTest(new ModTestData
|
2020-08-11 19:28:00 +00:00
|
|
|
{
|
2020-08-11 19:55:50 +00:00
|
|
|
Mods = mods,
|
|
|
|
Autoplay = false,
|
|
|
|
Beatmap = singleSpinnerBeatmap,
|
2020-11-13 14:03:44 +00:00
|
|
|
PassCondition = () =>
|
|
|
|
{
|
2021-03-26 10:09:44 +00:00
|
|
|
var counter = Player.ChildrenOfType<SpinnerSpmCalculator>().SingleOrDefault();
|
2022-02-14 08:11:44 +00:00
|
|
|
var spinner = Player.ChildrenOfType<DrawableSpinner>().FirstOrDefault();
|
|
|
|
|
|
|
|
if (counter == null || spinner == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// ignore cases where the spinner hasn't started as these lead to false-positives
|
|
|
|
if (Precision.AlmostEquals(counter.Result.Value, 0, 1))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
float rotationSpeed = (float)(1.01 * spinner.HitObject.SpinsRequired / spinner.HitObject.Duration);
|
|
|
|
|
|
|
|
return Precision.AlmostEquals(counter.Result.Value, rotationSpeed * 1000 * 60, 1);
|
2020-11-13 14:03:44 +00:00
|
|
|
}
|
2020-08-11 19:55:50 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-02-14 08:45:02 +00:00
|
|
|
[Test]
|
2022-02-22 05:11:22 +00:00
|
|
|
public void TestSpinnerGetsNoBonusScore()
|
2022-02-14 08:45:02 +00:00
|
|
|
{
|
2022-07-20 12:34:55 +00:00
|
|
|
DrawableSpinner? spinner = null;
|
2022-02-22 05:11:22 +00:00
|
|
|
List<JudgementResult> results = new List<JudgementResult>();
|
|
|
|
|
|
|
|
CreateModTest(new ModTestData
|
2022-02-14 08:45:02 +00:00
|
|
|
{
|
2022-02-22 05:11:22 +00:00
|
|
|
Mod = new OsuModSpunOut(),
|
|
|
|
Autoplay = false,
|
|
|
|
Beatmap = singleSpinnerBeatmap,
|
|
|
|
PassCondition = () =>
|
|
|
|
{
|
|
|
|
// Bind to the first spinner's results for further tracking.
|
|
|
|
if (spinner == null)
|
|
|
|
{
|
|
|
|
// We only care about the first spinner we encounter for this test.
|
|
|
|
var nextSpinner = Player.ChildrenOfType<DrawableSpinner>().SingleOrDefault();
|
2022-02-14 08:45:02 +00:00
|
|
|
|
2022-02-22 05:11:22 +00:00
|
|
|
if (nextSpinner == null)
|
|
|
|
return false;
|
2022-02-14 08:45:02 +00:00
|
|
|
|
2022-02-22 05:11:22 +00:00
|
|
|
spinner = nextSpinner;
|
2022-06-24 12:25:23 +00:00
|
|
|
spinner.OnNewResult += (_, result) => results.Add(result);
|
2022-02-14 08:45:02 +00:00
|
|
|
|
2022-02-22 05:11:22 +00:00
|
|
|
results.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// we should only be checking the bonus/progress after the spinner has fully completed.
|
2022-02-23 07:22:13 +00:00
|
|
|
if (results.OfType<OsuSpinnerJudgementResult>().All(r => r.TimeCompleted == null))
|
2022-02-22 05:11:22 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return
|
2022-02-22 05:37:52 +00:00
|
|
|
results.Any(r => r.Type == HitResult.SmallBonus)
|
2022-02-23 07:22:13 +00:00
|
|
|
&& results.All(r => r.Type != HitResult.LargeBonus);
|
2022-02-22 05:11:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-02-14 08:45:02 +00:00
|
|
|
|
2020-08-11 19:55:50 +00:00
|
|
|
private Beatmap singleSpinnerBeatmap => new Beatmap
|
|
|
|
{
|
|
|
|
HitObjects = new List<HitObject>
|
|
|
|
{
|
|
|
|
new Spinner
|
2020-08-11 19:28:00 +00:00
|
|
|
{
|
2020-08-11 19:55:50 +00:00
|
|
|
Position = new Vector2(256, 192),
|
|
|
|
StartTime = 500,
|
|
|
|
Duration = 2000
|
2020-08-11 19:28:00 +00:00
|
|
|
}
|
2020-08-11 19:55:50 +00:00
|
|
|
}
|
|
|
|
};
|
2020-08-11 19:28:00 +00:00
|
|
|
}
|
|
|
|
}
|