mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Update tests to better support stack regeneration cases
This commit is contained in:
parent
3e1002fbf3
commit
84a7138223
@ -10,6 +10,7 @@ using osu.Game.Rulesets.Catch.UI;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -170,16 +171,25 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCatcherStacking()
|
public void TestCatcherRandomStacking()
|
||||||
|
{
|
||||||
|
AddStep("catch more fruits", () => attemptCatch(() => new Fruit
|
||||||
|
{
|
||||||
|
X = (RNG.NextSingle() - 0.5f) * CatcherArea.CATCHER_SIZE
|
||||||
|
}, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCatcherStackingSameCaughtPosition()
|
||||||
{
|
{
|
||||||
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
||||||
checkPlate(1);
|
checkPlate(1);
|
||||||
AddStep("catch more fruits", () => attemptCatch(new Fruit(), 9));
|
AddStep("catch more fruits", () => attemptCatch(() => new Fruit(), 9));
|
||||||
checkPlate(10);
|
checkPlate(10);
|
||||||
AddAssert("caught objects are stacked", () =>
|
AddAssert("caught objects are stacked", () =>
|
||||||
catcher.CaughtObjects.All(obj => obj.Y <= 0) &&
|
catcher.CaughtObjects.All(obj => obj.Y <= Catcher.CAUGHT_FRUIT_VERTICAL_OFFSET) &&
|
||||||
catcher.CaughtObjects.Any(obj => obj.Y == 0) &&
|
catcher.CaughtObjects.Any(obj => obj.Y == Catcher.CAUGHT_FRUIT_VERTICAL_OFFSET) &&
|
||||||
catcher.CaughtObjects.Any(obj => obj.Y < -20));
|
catcher.CaughtObjects.Any(obj => obj.Y < -25));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -189,11 +199,11 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
AddStep("catch tiny droplet", () => attemptCatch(new TinyDroplet()));
|
AddStep("catch tiny droplet", () => attemptCatch(new TinyDroplet()));
|
||||||
AddAssert("tiny droplet is exploded", () => catcher.CaughtObjects.Count() == 1 && droppedObjectContainer.Count == 1);
|
AddAssert("tiny droplet is exploded", () => catcher.CaughtObjects.Count() == 1 && droppedObjectContainer.Count == 1);
|
||||||
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
||||||
AddStep("catch more fruits", () => attemptCatch(new Fruit(), 9));
|
AddStep("catch more fruits", () => attemptCatch(() => new Fruit(), 9));
|
||||||
AddStep("explode", () => catcher.Explode());
|
AddStep("explode", () => catcher.Explode());
|
||||||
AddAssert("fruits are exploded", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
AddAssert("fruits are exploded", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
||||||
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
||||||
AddStep("catch fruits", () => attemptCatch(new Fruit(), 10));
|
AddStep("catch fruits", () => attemptCatch(() => new Fruit(), 10));
|
||||||
AddStep("drop", () => catcher.Drop());
|
AddStep("drop", () => catcher.Drop());
|
||||||
AddAssert("fruits are dropped", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
AddAssert("fruits are dropped", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
||||||
}
|
}
|
||||||
@ -222,10 +232,15 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
private void checkHyperDash(bool state) => AddAssert($"catcher is {(state ? "" : "not ")}hyper dashing", () => catcher.HyperDashing == state);
|
private void checkHyperDash(bool state) => AddAssert($"catcher is {(state ? "" : "not ")}hyper dashing", () => catcher.HyperDashing == state);
|
||||||
|
|
||||||
private void attemptCatch(CatchHitObject hitObject, int count = 1)
|
private void attemptCatch(CatchHitObject hitObject)
|
||||||
|
{
|
||||||
|
attemptCatch(() => hitObject, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void attemptCatch(Func<CatchHitObject> hitObject, int count)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
attemptCatch(hitObject, out _, out _);
|
attemptCatch(hitObject(), out _, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attemptCatch(CatchHitObject hitObject, out DrawableCatchHitObject drawableObject, out JudgementResult result)
|
private void attemptCatch(CatchHitObject hitObject, out DrawableCatchHitObject drawableObject, out JudgementResult result)
|
||||||
|
@ -53,6 +53,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const double BASE_SPEED = 1.0;
|
public const double BASE_SPEED = 1.0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount by which caught fruit should be offset from the plate surface to make them look visually "caught".
|
||||||
|
/// </summary>
|
||||||
|
public const float CAUGHT_FRUIT_VERTICAL_OFFSET = -5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount by which caught fruit should be scaled down to fit on the plate.
|
/// The amount by which caught fruit should be scaled down to fit on the plate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -492,7 +497,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
float checkDistance = MathF.Pow(adjustedRadius, 2);
|
float checkDistance = MathF.Pow(adjustedRadius, 2);
|
||||||
|
|
||||||
// offset fruit vertically to better place "above" the plate.
|
// offset fruit vertically to better place "above" the plate.
|
||||||
position.Y -= 5;
|
position.Y += CAUGHT_FRUIT_VERTICAL_OFFSET;
|
||||||
|
|
||||||
while (caughtObjectContainer.Any(f => Vector2Extensions.DistanceSquared(f.Position, position) < checkDistance))
|
while (caughtObjectContainer.Any(f => Vector2Extensions.DistanceSquared(f.Position, position) < checkDistance))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user