Merge pull request #8201 from peppy/fix-hyperdash-test

Fix hyperdash test having a zero-length juice stream
This commit is contained in:
Dan Balasescu 2020-03-11 13:46:59 +09:00 committed by GitHub
commit cd5f0d6e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 17 deletions

View File

@ -8,7 +8,9 @@
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 @@ public TestSceneHyperDash()
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,51 @@ protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
}; };
// 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(Vector2.Zero),
new PathControlPoint(new Vector2(30, 0)),
});
}
}
} }
} }

View File

@ -24,8 +24,8 @@ public class JuiceStream : CatchHitObject, IHasCurve
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"/>.