1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 12:12:54 +08:00

Improve Tests

Fix divisor in test
This commit is contained in:
Mk-56spn 2022-09-16 13:18:38 +02:00
parent 5a9b027ebc
commit 7fc0366afd
2 changed files with 30 additions and 18 deletions

View File

@ -1,27 +1,40 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
namespace osu.Game.Rulesets.Osu.Tests.Mods namespace osu.Game.Rulesets.Osu.Tests.Mods
{ {
public class TestSceneOsuModFreezeFrame : OsuModTestScene public class TestSceneOsuModFreezeFrame : OsuModTestScene
{ {
[TestCase(0.5f)] [TestCase(OsuModFreezeFrame.BeatDivisor.Quarter_Measure)]
[TestCase(1)] [TestCase(OsuModFreezeFrame.BeatDivisor.Single_Measure)]
[TestCase(2)] [TestCase(OsuModFreezeFrame.BeatDivisor.Quadruple_Measure)]
public void TestFreezeFrequency(float beatMeasure) public void TestFreezeFrequency(OsuModFreezeFrame.BeatDivisor divisor)
{ {
CreateModTest(new ModTestData CreateModTest(new ModTestData
{ {
Mod = new OsuModFreezeFrame Mod = new OsuModFreezeFrame { Divisor = { Value = divisor } },
{ PassCondition = checkSomeHit,
BeatDivisor = { Value = beatMeasure }
},
PassCondition = () => true,
Autoplay = true Autoplay = true
}); });
} }
[Test]
public void TestWithHidden()
{
var mods = new List<Mod> { new OsuModHidden(), new OsuModFreezeFrame { Divisor = { Value = OsuModFreezeFrame.BeatDivisor.Quadruple_Measure } } };
CreateModTest(new ModTestData
{
Mods = mods,
PassCondition = checkSomeHit,
Autoplay = true
});
}
private bool checkSomeHit() => Player.ScoreProcessor.JudgedHits >= 8;
} }
} }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
public class OsuModFreezeFrame : ModWithVisibilityAdjustment, IHidesApproachCircles, IApplicableToDrawableRuleset<OsuHitObject> public class OsuModFreezeFrame : ModWithVisibilityAdjustment, IHidesApproachCircles, IApplicableToDrawableRuleset<OsuHitObject>
{ {
public override string Name => "Freeze frame"; public override string Name => "Freeze Frame";
public override string Acronym => "FF"; public override string Acronym => "FF";
@ -26,10 +26,9 @@ namespace osu.Game.Rulesets.Osu.Mods
public override ModType Type => ModType.Fun; public override ModType Type => ModType.Fun;
public override IconUsage? Icon => FontAwesome.Solid.Camera; public override IconUsage? Icon => FontAwesome.Solid.Camera;
public override Type[] IncompatibleMods => new[] { typeof(OsuModTarget), typeof(OsuModStrictTracking) };
[SettingSource("Beat divisor")] [SettingSource("Measure", "How often the hitcircles should be Grouped to freeze")]
public Bindable<BeatDivisor> Divisor { get; } = new Bindable<BeatDivisor>(BeatDivisor.Measure); public Bindable<BeatDivisor> Divisor { get; } = new Bindable<BeatDivisor>(BeatDivisor.Single_Measure);
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset) public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{ {
@ -42,11 +41,10 @@ namespace osu.Game.Rulesets.Osu.Mods
foreach (var obj in beatmap.HitObjects.OfType<OsuHitObject>()) foreach (var obj in beatmap.HitObjects.OfType<OsuHitObject>())
{ {
// The +1s below are added due to First HitCircle in each measure not appearing appropriately without them.
var lastTimingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime + 1); var lastTimingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime + 1);
// +1 is added due to First HitCircle in each measure not appearing appropriately without it
double controlPointDifference = obj.StartTime + 1 - lastTimingPoint.Time; double controlPointDifference = obj.StartTime + 1 - lastTimingPoint.Time;
double remainder = controlPointDifference % (lastTimingPoint.BeatLength * getMeasure(Divisor.Value)); double remainder = controlPointDifference % (lastTimingPoint.BeatLength * getMeasure(Divisor.Value)) - 1;
double finalPreempt = obj.TimePreempt + remainder; double finalPreempt = obj.TimePreempt + remainder;
applyFadeInAdjustment(obj); applyFadeInAdjustment(obj);
@ -73,7 +71,7 @@ namespace osu.Game.Rulesets.Osu.Mods
case BeatDivisor.Half_Measure: case BeatDivisor.Half_Measure:
return 0.5f; return 0.5f;
case BeatDivisor.Measure: case BeatDivisor.Single_Measure:
return 1; return 1;
case BeatDivisor.Double_Measure: case BeatDivisor.Double_Measure:
@ -87,11 +85,12 @@ namespace osu.Game.Rulesets.Osu.Mods
} }
} }
//Todo: find better way to represent these Enums to the player
public enum BeatDivisor public enum BeatDivisor
{ {
Quarter_Measure, Quarter_Measure,
Half_Measure, Half_Measure,
Measure, Single_Measure,
Double_Measure, Double_Measure,
Quadruple_Measure Quadruple_Measure
} }