mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:07:52 +08:00
Merge pull request #24121 from peppy/fix-judged-fallback
Fix fallback for `Judged` to be more correct
This commit is contained in:
commit
f3576b88a4
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
@ -80,7 +81,9 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
TestLifetimeEntry entry = null;
|
TestLifetimeEntry entry = null;
|
||||||
AddStep("Create entry", () => entry = new TestLifetimeEntry(new HitObject()) { LifetimeStart = 1 });
|
AddStep("Create entry", () => entry = new TestLifetimeEntry(new HitObject()) { LifetimeStart = 1 });
|
||||||
|
assertJudged(() => entry, false);
|
||||||
AddStep("ApplyDefaults", () => entry.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()));
|
AddStep("ApplyDefaults", () => entry.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()));
|
||||||
|
assertJudged(() => entry, false);
|
||||||
AddAssert("Lifetime is updated", () => entry.LifetimeStart == -TestLifetimeEntry.INITIAL_LIFETIME_OFFSET);
|
AddAssert("Lifetime is updated", () => entry.LifetimeStart == -TestLifetimeEntry.INITIAL_LIFETIME_OFFSET);
|
||||||
|
|
||||||
TestDrawableHitObject dho = null;
|
TestDrawableHitObject dho = null;
|
||||||
@ -91,6 +94,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
});
|
});
|
||||||
AddStep("ApplyDefaults", () => entry.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()));
|
AddStep("ApplyDefaults", () => entry.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()));
|
||||||
AddAssert("Lifetime is correct", () => dho.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY && entry.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY);
|
AddAssert("Lifetime is correct", () => dho.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY && entry.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY);
|
||||||
|
assertJudged(() => entry, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -138,6 +142,29 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
AddAssert("DHO state is correct", () => dho.State.Value == ArmedState.Miss);
|
AddAssert("DHO state is correct", () => dho.State.Value == ArmedState.Miss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestJudgedStateThroughLifetime()
|
||||||
|
{
|
||||||
|
TestDrawableHitObject dho = null;
|
||||||
|
HitObjectLifetimeEntry lifetimeEntry = null;
|
||||||
|
|
||||||
|
AddStep("Create lifetime entry", () => lifetimeEntry = new HitObjectLifetimeEntry(new HitObject { StartTime = Time.Current }));
|
||||||
|
|
||||||
|
assertJudged(() => lifetimeEntry, false);
|
||||||
|
|
||||||
|
AddStep("Create DHO and apply entry", () =>
|
||||||
|
{
|
||||||
|
Child = dho = new TestDrawableHitObject();
|
||||||
|
dho.Apply(lifetimeEntry);
|
||||||
|
});
|
||||||
|
|
||||||
|
assertJudged(() => lifetimeEntry, false);
|
||||||
|
|
||||||
|
AddStep("Apply result", () => dho.MissForcefully());
|
||||||
|
|
||||||
|
assertJudged(() => lifetimeEntry, true);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestResultSetBeforeLoadComplete()
|
public void TestResultSetBeforeLoadComplete()
|
||||||
{
|
{
|
||||||
@ -154,15 +181,20 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
assertJudged(() => lifetimeEntry, true);
|
||||||
AddStep("Create DHO and apply entry", () =>
|
AddStep("Create DHO and apply entry", () =>
|
||||||
{
|
{
|
||||||
dho = new TestDrawableHitObject();
|
dho = new TestDrawableHitObject();
|
||||||
dho.Apply(lifetimeEntry);
|
dho.Apply(lifetimeEntry);
|
||||||
Child = dho;
|
Child = dho;
|
||||||
});
|
});
|
||||||
|
assertJudged(() => lifetimeEntry, true);
|
||||||
AddAssert("DHO state is correct", () => dho.State.Value, () => Is.EqualTo(ArmedState.Hit));
|
AddAssert("DHO state is correct", () => dho.State.Value, () => Is.EqualTo(ArmedState.Hit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertJudged(Func<HitObjectLifetimeEntry> entry, bool val) =>
|
||||||
|
AddAssert(val ? "Is judged" : "Not judged", () => entry().Judged, () => Is.EqualTo(val));
|
||||||
|
|
||||||
private partial class TestDrawableHitObject : DrawableHitObject
|
private partial class TestDrawableHitObject : DrawableHitObject
|
||||||
{
|
{
|
||||||
public const double INITIAL_LIFETIME_OFFSET = 100;
|
public const double INITIAL_LIFETIME_OFFSET = 100;
|
||||||
|
@ -112,12 +112,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// Whether this <see cref="DrawableHitObject"/> has been judged.
|
/// Whether this <see cref="DrawableHitObject"/> has been judged.
|
||||||
/// Note: This does NOT include nested hitobjects.
|
/// Note: This does NOT include nested hitobjects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Judged => Entry?.Judged ?? true;
|
public bool Judged => Entry?.Judged ?? false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this <see cref="DrawableHitObject"/> and all of its nested <see cref="DrawableHitObject"/>s have been judged.
|
/// Whether this <see cref="DrawableHitObject"/> and all of its nested <see cref="DrawableHitObject"/>s have been judged.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllJudged => Entry?.AllJudged ?? true;
|
public bool AllJudged => Entry?.AllJudged ?? false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The relative X position of this hit object for sample playback balance adjustment.
|
/// The relative X position of this hit object for sample playback balance adjustment.
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
/// Whether <see cref="HitObject"/> has been judged.
|
/// Whether <see cref="HitObject"/> has been judged.
|
||||||
/// Note: This does NOT include nested hitobjects.
|
/// Note: This does NOT include nested hitobjects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Judged => Result?.HasResult ?? true;
|
public bool Judged => Result?.HasResult ?? false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether <see cref="HitObject"/> and all of its nested objects have been judged.
|
/// Whether <see cref="HitObject"/> and all of its nested objects have been judged.
|
||||||
|
Loading…
Reference in New Issue
Block a user