From 5329b222f6de157989225761aeaf5dd89c60d72f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Mar 2020 17:49:51 +0900 Subject: [PATCH 1/2] Fix hyperdash test having a zero-length juice stream --- .../TestSceneHyperDash.cs | 45 ++++++++++++------- .../Objects/JuiceStream.cs | 4 +- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs index 7a7c3f4103..5b3a114506 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs @@ -8,7 +8,9 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Objects; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Rulesets.Catch.Tests { @@ -26,9 +28,11 @@ public TestSceneHyperDash() public void TestHyperDash() { 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 left hyperdash", () => getCatcher().Scale.X < 0 && getCatcher().HyperDashing); @@ -49,39 +53,50 @@ protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) }; // Should produce a hyper-dash (edge case test) - beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 308 / 512f, NewCombo = true }); - beatmap.HitObjects.Add(new JuiceStream { StartTime = 2008, X = 56 / 512f, }); + beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 56 / 512f, NewCombo = true }); + beatmap.HitObjects.Add(new Fruit { StartTime = 2008, X = 308 / 512f, NewCombo = true }); double startTime = 3000; const float left_x = 0.02f; const float right_x = 0.98f; - createObjects(() => new Fruit(), left_x); - createObjects(() => new JuiceStream(), right_x); - createObjects(() => new JuiceStream(), left_x); - createObjects(() => new Fruit(), right_x); - createObjects(() => new Fruit(), left_x); - createObjects(() => new Fruit(), right_x); - createObjects(() => new JuiceStream(), left_x); + createObjects(() => new Fruit { X = left_x }); + createObjects(() => new TestJuiceStream(right_x), 1); + createObjects(() => new TestJuiceStream(left_x), 1); + createObjects(() => new Fruit { X = right_x }); + createObjects(() => new Fruit { X = left_x }); + createObjects(() => new Fruit { X = right_x }); + createObjects(() => new TestJuiceStream(left_x), 1); return beatmap; - void createObjects(Func createObject, float x) + void createObjects(Func createObject, int count = 3) { const float spacing = 140; - for (int i = 0; i < 3; i++) + for (int i = 0; i < count; i++) { var hitObject = createObject(); - hitObject.X = x; hitObject.StartTime = startTime + i * spacing; - beatmap.HitObjects.Add(hitObject); } 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)), + }); + } + } } } diff --git a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs index 642ff0246e..bcc2d9d9bb 100644 --- a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs +++ b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs @@ -24,8 +24,8 @@ public class JuiceStream : CatchHitObject, IHasCurve public int RepeatCount { get; set; } - public double Velocity; - public double TickDistance; + public double Velocity { get; private set; } + public double TickDistance { get; private set; } /// /// The length of one span of this . From 9683c0756d391930d6514e4d3a93ba9021ad623a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 11 Mar 2020 12:56:12 +0900 Subject: [PATCH 2/2] Start path at (0,0) --- osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs index 5b3a114506..f39395ba44 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs @@ -91,10 +91,11 @@ 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)), + new PathControlPoint(Vector2.Zero), + new PathControlPoint(new Vector2(30, 0)), }); } }