mirror of
https://github.com/ppy/osu
synced 2024-12-23 23:33:36 +00:00
Handle no-duration single-object edge case
This commit is contained in:
parent
547b3d8bed
commit
a0de1cbfd0
@ -16,23 +16,11 @@ namespace osu.Game.Tests.Rulesets.Mods
|
||||
private const double duration = 9000;
|
||||
|
||||
private TrackVirtual track;
|
||||
private IBeatmap beatmap;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
track = new TrackVirtual(20_000);
|
||||
beatmap = new Beatmap
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new Spinner
|
||||
{
|
||||
StartTime = start_time,
|
||||
Duration = duration
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[TestCase(0, 1)]
|
||||
@ -43,6 +31,7 @@ namespace osu.Game.Tests.Rulesets.Mods
|
||||
[TestCase(15000, 1.5)]
|
||||
public void TestModWindUp(double time, double expectedRate)
|
||||
{
|
||||
var beatmap = createSingleSpinnerBeatmap();
|
||||
var mod = new ModWindUp();
|
||||
mod.ApplyToBeatmap(beatmap);
|
||||
mod.ApplyToTrack(track);
|
||||
@ -60,6 +49,7 @@ namespace osu.Game.Tests.Rulesets.Mods
|
||||
[TestCase(15000, 0.5)]
|
||||
public void TestModWindDown(double time, double expectedRate)
|
||||
{
|
||||
var beatmap = createSingleSpinnerBeatmap();
|
||||
var mod = new ModWindDown
|
||||
{
|
||||
FinalRate = { Value = 0.5 }
|
||||
@ -72,11 +62,52 @@ namespace osu.Game.Tests.Rulesets.Mods
|
||||
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
||||
}
|
||||
|
||||
[TestCase(0, 1)]
|
||||
[TestCase(start_time, 1)]
|
||||
[TestCase(2 * start_time, 1.5)]
|
||||
public void TestZeroDurationMap(double time, double expectedRate)
|
||||
{
|
||||
var beatmap = createSingleObjectBeatmap();
|
||||
var mod = new ModWindUp();
|
||||
mod.ApplyToBeatmap(beatmap);
|
||||
mod.ApplyToTrack(track);
|
||||
|
||||
seekTrackAndUpdateMod(mod, time);
|
||||
|
||||
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
||||
}
|
||||
|
||||
private void seekTrackAndUpdateMod(ModTimeRamp mod, double time)
|
||||
{
|
||||
track.Seek(time);
|
||||
// update the mod via a fake playfield to re-calculate the current rate.
|
||||
mod.Update(null);
|
||||
}
|
||||
|
||||
private static Beatmap createSingleSpinnerBeatmap()
|
||||
{
|
||||
return new Beatmap
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new Spinner
|
||||
{
|
||||
StartTime = start_time,
|
||||
Duration = duration
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static Beatmap createSingleObjectBeatmap()
|
||||
{
|
||||
return new Beatmap
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = start_time }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public virtual void Update(Playfield playfield)
|
||||
{
|
||||
applyRateAdjustment((track.CurrentTime - beginRampTime) / (finalRateTime - beginRampTime));
|
||||
applyRateAdjustment((track.CurrentTime - beginRampTime) / Math.Max(1, finalRateTime - beginRampTime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user