mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:07:52 +08:00
Merge pull request #10253 from smoogipoo/fix-hp-instafail
Fix HP drain edgecase potentially causing insta-fails
This commit is contained in:
commit
1d1de59ecc
@ -1,15 +1,18 @@
|
|||||||
// 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.Threading;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
@ -175,6 +178,24 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
assertHealthNotEqualTo(0);
|
assertHealthNotEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSingleLongObjectDoesNotDrain()
|
||||||
|
{
|
||||||
|
var beatmap = new Beatmap
|
||||||
|
{
|
||||||
|
HitObjects = { new JudgeableLongHitObject() }
|
||||||
|
};
|
||||||
|
|
||||||
|
beatmap.HitObjects[0].ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
|
||||||
|
createProcessor(beatmap);
|
||||||
|
setTime(0);
|
||||||
|
assertHealthEqualTo(1);
|
||||||
|
|
||||||
|
setTime(5000);
|
||||||
|
assertHealthEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
private Beatmap createBeatmap(double startTime, double endTime, params BreakPeriod[] breaks)
|
private Beatmap createBeatmap(double startTime, double endTime, params BreakPeriod[] breaks)
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap
|
var beatmap = new Beatmap
|
||||||
@ -235,5 +256,23 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class JudgeableLongHitObject : JudgeableHitObject, IHasDuration
|
||||||
|
{
|
||||||
|
public double EndTime => StartTime + Duration;
|
||||||
|
public double Duration { get; set; } = 5000;
|
||||||
|
|
||||||
|
public JudgeableLongHitObject()
|
||||||
|
: base(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
base.CreateNestedHitObjects(cancellationToken);
|
||||||
|
|
||||||
|
AddNested(new JudgeableHitObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
|
|
||||||
private double computeDrainRate()
|
private double computeDrainRate()
|
||||||
{
|
{
|
||||||
if (healthIncreases.Count == 0)
|
if (healthIncreases.Count <= 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int adjustment = 1;
|
int adjustment = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user