2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2018-06-14 20:46:47 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using NUnit.Framework;
|
2020-01-09 12:43:44 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2019-08-01 13:58:17 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.Mods;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests
|
|
|
|
|
{
|
2018-06-13 22:43:58 +08:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class CatchBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2023-12-05 14:51:59 +08:00
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch.Tests";
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-13 21:23:19 +08:00
|
|
|
|
[TestCase("basic")]
|
2018-06-13 17:39:26 +08:00
|
|
|
|
[TestCase("spinner")]
|
2018-06-13 20:12:08 +08:00
|
|
|
|
[TestCase("spinner-and-circles")]
|
2019-01-25 17:13:14 +08:00
|
|
|
|
[TestCase("slider")]
|
2019-08-01 13:58:17 +08:00
|
|
|
|
[TestCase("hardrock-stream", new[] { typeof(CatchModHardRock) })]
|
|
|
|
|
[TestCase("hardrock-repeat-slider", new[] { typeof(CatchModHardRock) })]
|
2019-08-01 16:58:20 +08:00
|
|
|
|
[TestCase("hardrock-spinner", new[] { typeof(CatchModHardRock) })]
|
2020-08-20 19:25:40 +08:00
|
|
|
|
[TestCase("right-bound-hr-offset", new[] { typeof(CatchModHardRock) })]
|
2021-12-16 18:26:36 +08:00
|
|
|
|
[TestCase("basic-hyperdash")]
|
2023-12-04 13:30:08 +08:00
|
|
|
|
[TestCase("pixel-jump")]
|
2023-12-05 10:57:51 +08:00
|
|
|
|
[TestCase("tiny-ticks")]
|
2023-12-05 14:09:55 +08:00
|
|
|
|
[TestCase("v8-tick-distance")]
|
2023-12-05 14:39:23 +08:00
|
|
|
|
[TestCase("spinner-precision")]
|
2023-12-05 14:51:59 +08:00
|
|
|
|
[TestCase("37902", new[] { typeof(CatchModDoubleTime), typeof(CatchModHardRock), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("39206", new[] { typeof(CatchModDoubleTime), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("42587")]
|
|
|
|
|
[TestCase("50859", new[] { typeof(CatchModDoubleTime), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("75858", new[] { typeof(CatchModHardRock), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("103019", new[] { typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("104973", new[] { typeof(CatchModHardRock), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("871815", new[] { typeof(CatchModDoubleTime), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("1284935", new[] { typeof(CatchModDoubleTime), typeof(CatchModHardRock) })]
|
|
|
|
|
[TestCase("1431386", new[] { typeof(CatchModDoubleTime), typeof(CatchModHardRock), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("1597806", new[] { typeof(CatchModDoubleTime), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("2190499", new[] { typeof(CatchModDoubleTime), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("2571731", new[] { typeof(CatchModHardRock), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("2768615", new[] { typeof(CatchModDoubleTime), typeof(CatchModHardRock) })]
|
|
|
|
|
[TestCase("2781126", new[] { typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("3152510", new[] { typeof(CatchModDoubleTime) })]
|
|
|
|
|
[TestCase("3227428", new[] { typeof(CatchModHardRock), typeof(CatchModHidden) })]
|
|
|
|
|
[TestCase("3524302", new[] { typeof(CatchModDoubleTime), typeof(CatchModEasy) })]
|
|
|
|
|
[TestCase("3644427", new[] { typeof(CatchModEasy), typeof(CatchModFlashlight) })]
|
|
|
|
|
[TestCase("3689906", new[] { typeof(CatchModDoubleTime), typeof(CatchModEasy) })]
|
|
|
|
|
[TestCase("3949367", new[] { typeof(CatchModDoubleTime), typeof(CatchModEasy) })]
|
2023-12-11 20:52:39 +08:00
|
|
|
|
[TestCase("112643")]
|
2024-03-02 08:18:42 +08:00
|
|
|
|
[TestCase("1041052", new[] { typeof(CatchModHardRock) })]
|
2019-08-05 17:19:18 +08:00
|
|
|
|
public new void Test(string name, params Type[] mods) => base.Test(name, mods);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
|
|
|
|
{
|
2018-07-17 13:35:09 +08:00
|
|
|
|
switch (hitObject)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-17 13:35:09 +08:00
|
|
|
|
case JuiceStream stream:
|
|
|
|
|
foreach (var nested in stream.NestedHitObjects)
|
|
|
|
|
yield return new ConvertValue((CatchHitObject)nested);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
case BananaShower shower:
|
|
|
|
|
foreach (var nested in shower.NestedHitObjects)
|
|
|
|
|
yield return new ConvertValue((CatchHitObject)nested);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
default:
|
|
|
|
|
yield return new ConvertValue((CatchHitObject)hitObject);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-07-17 13:35:09 +08:00
|
|
|
|
break;
|
2018-06-13 17:39:26 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 12:09:48 +08:00
|
|
|
|
protected override Ruleset CreateRuleset() => new CatchRuleset();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-13 22:43:58 +08:00
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A sane value to account for osu!stable using ints everwhere.
|
|
|
|
|
/// </summary>
|
2023-12-05 14:51:59 +08:00
|
|
|
|
private const float conversion_lenience = 3;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-14 20:46:47 +08:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public readonly CatchHitObject HitObject;
|
|
|
|
|
|
|
|
|
|
public ConvertValue(CatchHitObject hitObject)
|
|
|
|
|
{
|
|
|
|
|
HitObject = hitObject;
|
|
|
|
|
startTime = 0;
|
|
|
|
|
position = 0;
|
2021-12-16 18:04:42 +08:00
|
|
|
|
hyperDash = false;
|
2018-06-14 20:46:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private double startTime;
|
|
|
|
|
|
|
|
|
|
public double StartTime
|
|
|
|
|
{
|
|
|
|
|
get => HitObject?.StartTime ?? startTime;
|
|
|
|
|
set => startTime = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private float position;
|
|
|
|
|
|
|
|
|
|
public float Position
|
|
|
|
|
{
|
2020-12-09 16:58:53 +08:00
|
|
|
|
get => HitObject?.EffectiveX ?? position;
|
2018-06-14 20:46:47 +08:00
|
|
|
|
set => position = value;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-12-16 18:04:42 +08:00
|
|
|
|
private bool hyperDash;
|
|
|
|
|
|
|
|
|
|
public bool HyperDash
|
|
|
|
|
{
|
|
|
|
|
get => (HitObject as PalpableCatchHitObject)?.HyperDash ?? hyperDash;
|
|
|
|
|
set => hyperDash = value;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public bool Equals(ConvertValue other)
|
|
|
|
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
2021-12-16 18:04:42 +08:00
|
|
|
|
&& Precision.AlmostEquals(Position, other.Position, conversion_lenience)
|
2021-12-16 18:26:36 +08:00
|
|
|
|
&& HyperDash == other.HyperDash;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|