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