From 73ba91bbad2dd77e19fbb017a03e5f55bd3624ce Mon Sep 17 00:00:00 2001 From: HoLLy Date: Sat, 2 Mar 2019 14:05:56 +0100 Subject: [PATCH 1/4] Add failing test case --- .../TestCaseHyperDash.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs index 0851fbed87..5df8f2c2c1 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs @@ -1,9 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using NUnit.Framework; using osu.Game.Beatmaps; using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Screens.Play; namespace osu.Game.Rulesets.Catch.Tests { @@ -11,19 +13,34 @@ namespace osu.Game.Rulesets.Catch.Tests public class TestCaseHyperDash : Game.Tests.Visual.TestCasePlayer { public TestCaseHyperDash() - : base(new CatchRuleset()) - { - } + : base(new CatchRuleset()) { } protected override IBeatmap CreateBeatmap(Ruleset ruleset) { - var beatmap = new Beatmap { BeatmapInfo = { Ruleset = ruleset.RulesetInfo } }; + var beatmap = new Beatmap + { + BeatmapInfo = + { + Ruleset = ruleset.RulesetInfo, + BaseDifficulty = new BeatmapDifficulty { CircleSize = 3.6f } + } + }; + + // Should produce a hperdash + beatmap.HitObjects.Add(new Fruit { StartTime = 816, X = 308 / 512f, NewCombo = true }); + beatmap.HitObjects.Add(new Fruit { StartTime = 1008, X = 56 / 512f, }); for (int i = 0; i < 512; i++) if (i % 5 < 3) - beatmap.HitObjects.Add(new Fruit { X = i % 10 < 5 ? 0.02f : 0.98f, StartTime = i * 100, NewCombo = i % 8 == 0 }); + beatmap.HitObjects.Add(new Fruit { X = i % 10 < 5 ? 0.02f : 0.98f, StartTime = 2000 + i * 100, NewCombo = i % 8 == 0 }); return beatmap; } + + protected override void AddCheckSteps(Func player) + { + base.AddCheckSteps(player); + AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash); + } } } From 5ff47924ab9d0f97124a9c1030e105e80f05b183 Mon Sep 17 00:00:00 2001 From: HoLLy Date: Sat, 2 Mar 2019 14:06:53 +0100 Subject: [PATCH 2/4] Add missing grace time in hyperdash calculation --- osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index 5f1e0b97da..fac08cd0e1 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -100,7 +100,7 @@ private void initialiseHyperDash(List objects) CatchHitObject nextObject = objectWithDroplets[i + 1]; int thisDirection = nextObject.X > currentObject.X ? 1 : -1; - double timeToNext = nextObject.StartTime - currentObject.StartTime; + double timeToNext = nextObject.StartTime - currentObject.StartTime - 1000f / 60f / 4; // 4 frames of grace time, taken from osu-stable double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : halfCatcherWidth); float distanceToHyper = (float)(timeToNext * CatcherArea.Catcher.BASE_SPEED - distanceToNext); if (distanceToHyper < 0) From 1ea4781188c8614684650bd8afa6504435320f3c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Mar 2019 13:50:36 +0900 Subject: [PATCH 3/4] Fix code styling --- osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs index 5df8f2c2c1..7451986a8b 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestCaseHyperDash.cs @@ -13,7 +13,9 @@ namespace osu.Game.Rulesets.Catch.Tests public class TestCaseHyperDash : Game.Tests.Visual.TestCasePlayer { public TestCaseHyperDash() - : base(new CatchRuleset()) { } + : base(new CatchRuleset()) + { + } protected override IBeatmap CreateBeatmap(Ruleset ruleset) { From 679d30d08a6fe0ced3ed0914d9e11388bd5fd897 Mon Sep 17 00:00:00 2001 From: HoLLy Date: Sun, 3 Mar 2019 11:21:39 +0000 Subject: [PATCH 4/4] Fix comment mentioning 4 frames instead of 1/4 --- osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index fac08cd0e1..78b5a510b2 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -100,7 +100,7 @@ private void initialiseHyperDash(List objects) CatchHitObject nextObject = objectWithDroplets[i + 1]; int thisDirection = nextObject.X > currentObject.X ? 1 : -1; - double timeToNext = nextObject.StartTime - currentObject.StartTime - 1000f / 60f / 4; // 4 frames of grace time, taken from osu-stable + double timeToNext = nextObject.StartTime - currentObject.StartTime - 1000f / 60f / 4; // 1/4th of a frame of grace time, taken from osu-stable double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : halfCatcherWidth); float distanceToHyper = (float)(timeToNext * CatcherArea.Catcher.BASE_SPEED - distanceToNext); if (distanceToHyper < 0)