mirror of
https://github.com/ppy/osu.git
synced 2024-12-23 23:02:54 +08:00
Improve Tests
Fix divisor in test
This commit is contained in:
parent
5a9b027ebc
commit
7fc0366afd
@ -1,27 +1,40 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
{
|
||||
public class TestSceneOsuModFreezeFrame : OsuModTestScene
|
||||
{
|
||||
[TestCase(0.5f)]
|
||||
[TestCase(1)]
|
||||
[TestCase(2)]
|
||||
public void TestFreezeFrequency(float beatMeasure)
|
||||
[TestCase(OsuModFreezeFrame.BeatDivisor.Quarter_Measure)]
|
||||
[TestCase(OsuModFreezeFrame.BeatDivisor.Single_Measure)]
|
||||
[TestCase(OsuModFreezeFrame.BeatDivisor.Quadruple_Measure)]
|
||||
public void TestFreezeFrequency(OsuModFreezeFrame.BeatDivisor divisor)
|
||||
{
|
||||
CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new OsuModFreezeFrame
|
||||
{
|
||||
BeatDivisor = { Value = beatMeasure }
|
||||
},
|
||||
PassCondition = () => true,
|
||||
Mod = new OsuModFreezeFrame { Divisor = { Value = divisor } },
|
||||
PassCondition = checkSomeHit,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public class OsuModFreezeFrame : ModWithVisibilityAdjustment, IHidesApproachCircles, IApplicableToDrawableRuleset<OsuHitObject>
|
||||
{
|
||||
public override string Name => "Freeze frame";
|
||||
public override string Name => "Freeze Frame";
|
||||
|
||||
public override string Acronym => "FF";
|
||||
|
||||
@ -26,10 +26,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
public override ModType Type => ModType.Fun;
|
||||
|
||||
public override IconUsage? Icon => FontAwesome.Solid.Camera;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(OsuModTarget), typeof(OsuModStrictTracking) };
|
||||
|
||||
[SettingSource("Beat divisor")]
|
||||
public Bindable<BeatDivisor> Divisor { get; } = new Bindable<BeatDivisor>(BeatDivisor.Measure);
|
||||
[SettingSource("Measure", "How often the hitcircles should be Grouped to freeze")]
|
||||
public Bindable<BeatDivisor> Divisor { get; } = new Bindable<BeatDivisor>(BeatDivisor.Single_Measure);
|
||||
|
||||
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||
{
|
||||
@ -42,11 +41,10 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
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);
|
||||
// +1 is added due to First HitCircle in each measure not appearing appropriately without it
|
||||
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;
|
||||
applyFadeInAdjustment(obj);
|
||||
|
||||
@ -73,7 +71,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
case BeatDivisor.Half_Measure:
|
||||
return 0.5f;
|
||||
|
||||
case BeatDivisor.Measure:
|
||||
case BeatDivisor.Single_Measure:
|
||||
return 1;
|
||||
|
||||
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
|
||||
{
|
||||
Quarter_Measure,
|
||||
Half_Measure,
|
||||
Measure,
|
||||
Single_Measure,
|
||||
Double_Measure,
|
||||
Quadruple_Measure
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user