From 2ae1a2435504f8c49391f6870286074af1a4781b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 4 Oct 2023 18:55:20 +0200 Subject: [PATCH] Add failing test covering counting multiple swell hits per frame --- .../Judgements/TestSceneSwellJudgements.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/osu.Game.Rulesets.Taiko.Tests/Judgements/TestSceneSwellJudgements.cs b/osu.Game.Rulesets.Taiko.Tests/Judgements/TestSceneSwellJudgements.cs index 4abad98eab..6e42ae7eb5 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Judgements/TestSceneSwellJudgements.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Judgements/TestSceneSwellJudgements.cs @@ -115,6 +115,48 @@ namespace osu.Game.Rulesets.Taiko.Tests.Judgements AddAssert("all tick offsets are 0", () => JudgementResults.Where(r => r.HitObject is SwellTick).All(r => r.TimeOffset == 0)); } + [Test] + public void TestAtMostOneSwellTickJudgedPerFrame() + { + const double swell_time = 1000; + + Swell swell = new Swell + { + StartTime = swell_time, + Duration = 1000, + RequiredHits = 10 + }; + + List frames = new List + { + new TaikoReplayFrame(1000), + new TaikoReplayFrame(1250, TaikoAction.LeftCentre, TaikoAction.LeftRim), + new TaikoReplayFrame(1251), + new TaikoReplayFrame(1500, TaikoAction.LeftCentre, TaikoAction.LeftRim, TaikoAction.RightCentre, TaikoAction.RightRim), + new TaikoReplayFrame(1501), + new TaikoReplayFrame(2000), + }; + + PerformTest(frames, CreateBeatmap(swell)); + + AssertJudgementCount(11); + + // this is a charitable interpretation of the inputs. + // + // for the frame at time 1250, we only count either one of the input actions - simple. + // + // for the frame at time 1500, we give the user the benefit of the doubt, + // and we ignore actions that wouldn't otherwise cause a hit due to not alternating, + // but we still count one (just one) of the actions that _would_ normally cause a hit. + // this is done as a courtesy to avoid stuff like key chattering after press blocking legitimate inputs. + for (int i = 0; i < 2; i++) + AssertResult(i, HitResult.IgnoreHit); + for (int i = 2; i < swell.RequiredHits; i++) + AssertResult(i, HitResult.IgnoreMiss); + + AssertResult(0, HitResult.IgnoreMiss); + } + /// /// Ensure input is correctly sent to subsequent hits if a swell is fully completed. ///