-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
CatchBeatmapConversionTest.cs
132 lines (112 loc) · 5.3 KB
/
CatchBeatmapConversionTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// 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.
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using NUnit.Framework;
using osu.Framework.Utils;
using osu.Game.Rulesets.Catch.Mods;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class CatchBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch.Tests";
[TestCase("basic")]
[TestCase("spinner")]
[TestCase("spinner-and-circles")]
[TestCase("slider")]
[TestCase("hardrock-stream", new[] { typeof(CatchModHardRock) })]
[TestCase("hardrock-repeat-slider", new[] { typeof(CatchModHardRock) })]
[TestCase("hardrock-spinner", new[] { typeof(CatchModHardRock) })]
[TestCase("right-bound-hr-offset", new[] { typeof(CatchModHardRock) })]
[TestCase("basic-hyperdash")]
[TestCase("pixel-jump")]
[TestCase("tiny-ticks")]
[TestCase("v8-tick-distance")]
[TestCase("spinner-precision")]
[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) })]
[TestCase("112643")]
[TestCase("1041052", new[] { typeof(CatchModHardRock) })]
public new void Test(string name, params Type[] mods) => base.Test(name, mods);
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
{
switch (hitObject)
{
case JuiceStream stream:
foreach (var nested in stream.NestedHitObjects)
yield return new ConvertValue((CatchHitObject)nested);
break;
case BananaShower shower:
foreach (var nested in shower.NestedHitObjects)
yield return new ConvertValue((CatchHitObject)nested);
break;
default:
yield return new ConvertValue((CatchHitObject)hitObject);
break;
}
}
protected override Ruleset CreateRuleset() => new CatchRuleset();
}
public struct ConvertValue : IEquatable<ConvertValue>
{
/// <summary>
/// A sane value to account for osu!stable using ints everwhere.
/// </summary>
private const float conversion_lenience = 3;
[JsonIgnore]
public readonly CatchHitObject HitObject;
public ConvertValue(CatchHitObject hitObject)
{
HitObject = hitObject;
startTime = 0;
position = 0;
hyperDash = false;
}
private double startTime;
public double StartTime
{
get => HitObject?.StartTime ?? startTime;
set => startTime = value;
}
private float position;
public float Position
{
get => HitObject?.EffectiveX ?? position;
set => position = value;
}
private bool hyperDash;
public bool HyperDash
{
get => (HitObject as PalpableCatchHitObject)?.HyperDash ?? hyperDash;
set => hyperDash = value;
}
public bool Equals(ConvertValue other)
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
&& Precision.AlmostEquals(Position, other.Position, conversion_lenience)
&& HyperDash == other.HyperDash;
}
}