1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-08 06:36:05 +08:00

Fix hyperdash test having a zero-length juice stream

This commit is contained in:
Dean Herbert 2020-03-10 17:49:51 +09:00
parent a6cf6207aa
commit 5329b222f6
2 changed files with 32 additions and 17 deletions

View File

@ -8,7 +8,9 @@ using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
@ -26,9 +28,11 @@ namespace osu.Game.Rulesets.Catch.Tests
public void TestHyperDash() public void TestHyperDash()
{ {
AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash); AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash);
AddUntilStep("wait for left hyperdash", () => getCatcher().Scale.X < 0 && getCatcher().HyperDashing); AddUntilStep("wait for right movement", () => getCatcher().Scale.X > 0); // don't check hyperdashing as it happens too fast.
for (int i = 0; i < 2; i++) AddUntilStep("wait for left movement", () => getCatcher().Scale.X < 0);
for (int i = 0; i < 3; i++)
{ {
AddUntilStep("wait for right hyperdash", () => getCatcher().Scale.X > 0 && getCatcher().HyperDashing); AddUntilStep("wait for right hyperdash", () => getCatcher().Scale.X > 0 && getCatcher().HyperDashing);
AddUntilStep("wait for left hyperdash", () => getCatcher().Scale.X < 0 && getCatcher().HyperDashing); AddUntilStep("wait for left hyperdash", () => getCatcher().Scale.X < 0 && getCatcher().HyperDashing);
@ -49,39 +53,50 @@ namespace osu.Game.Rulesets.Catch.Tests
}; };
// Should produce a hyper-dash (edge case test) // Should produce a hyper-dash (edge case test)
beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 308 / 512f, NewCombo = true }); beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 56 / 512f, NewCombo = true });
beatmap.HitObjects.Add(new JuiceStream { StartTime = 2008, X = 56 / 512f, }); beatmap.HitObjects.Add(new Fruit { StartTime = 2008, X = 308 / 512f, NewCombo = true });
double startTime = 3000; double startTime = 3000;
const float left_x = 0.02f; const float left_x = 0.02f;
const float right_x = 0.98f; const float right_x = 0.98f;
createObjects(() => new Fruit(), left_x); createObjects(() => new Fruit { X = left_x });
createObjects(() => new JuiceStream(), right_x); createObjects(() => new TestJuiceStream(right_x), 1);
createObjects(() => new JuiceStream(), left_x); createObjects(() => new TestJuiceStream(left_x), 1);
createObjects(() => new Fruit(), right_x); createObjects(() => new Fruit { X = right_x });
createObjects(() => new Fruit(), left_x); createObjects(() => new Fruit { X = left_x });
createObjects(() => new Fruit(), right_x); createObjects(() => new Fruit { X = right_x });
createObjects(() => new JuiceStream(), left_x); createObjects(() => new TestJuiceStream(left_x), 1);
return beatmap; return beatmap;
void createObjects(Func<CatchHitObject> createObject, float x) void createObjects(Func<CatchHitObject> createObject, int count = 3)
{ {
const float spacing = 140; const float spacing = 140;
for (int i = 0; i < 3; i++) for (int i = 0; i < count; i++)
{ {
var hitObject = createObject(); var hitObject = createObject();
hitObject.X = x;
hitObject.StartTime = startTime + i * spacing; hitObject.StartTime = startTime + i * spacing;
beatmap.HitObjects.Add(hitObject); beatmap.HitObjects.Add(hitObject);
} }
startTime += 700; startTime += 700;
} }
} }
private class TestJuiceStream : JuiceStream
{
public TestJuiceStream(float x)
{
X = x;
Path = new SliderPath(new[]
{
new PathControlPoint(new Vector2(x, 0)),
new PathControlPoint(new Vector2(x + 30, 0)),
});
}
}
} }
} }

View File

@ -24,8 +24,8 @@ namespace osu.Game.Rulesets.Catch.Objects
public int RepeatCount { get; set; } public int RepeatCount { get; set; }
public double Velocity; public double Velocity { get; private set; }
public double TickDistance; public double TickDistance { get; private set; }
/// <summary> /// <summary>
/// The length of one span of this <see cref="JuiceStream"/>. /// The length of one span of this <see cref="JuiceStream"/>.