2020-03-01 05:16:28 +00:00
|
|
|
|
// 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.
|
|
|
|
|
|
2021-01-06 19:40:47 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-03-05 02:53:04 +00:00
|
|
|
|
using System.Linq;
|
2020-03-02 03:20:25 +00:00
|
|
|
|
using NUnit.Framework;
|
2020-03-05 02:53:04 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Framework.Utils;
|
2021-01-06 19:40:47 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-03-05 02:53:04 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2021-01-06 19:40:47 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2020-03-01 05:16:28 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2021-01-06 19:40:47 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2020-03-05 02:53:04 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2020-03-01 05:16:28 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|
|
|
|
{
|
2020-06-03 20:23:56 +00:00
|
|
|
|
public class TestSceneOsuModDifficultyAdjust : OsuModTestScene
|
2020-03-01 05:16:28 +00:00
|
|
|
|
{
|
2020-03-02 03:20:25 +00:00
|
|
|
|
[Test]
|
2020-03-05 02:33:30 +00:00
|
|
|
|
public void TestNoAdjustment() => CreateModTest(new ModTestData
|
2020-03-02 01:50:41 +00:00
|
|
|
|
{
|
2020-03-05 01:21:25 +00:00
|
|
|
|
Mod = new OsuModDifficultyAdjust(),
|
2021-01-06 19:40:47 +00:00
|
|
|
|
Beatmap = new Beatmap
|
|
|
|
|
{
|
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
|
{
|
|
|
|
|
BaseDifficulty = new BeatmapDifficulty
|
|
|
|
|
{
|
|
|
|
|
CircleSize = 8
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
HitObjects = new List<HitObject>
|
|
|
|
|
{
|
|
|
|
|
new HitCircle { StartTime = 1000 },
|
|
|
|
|
new HitCircle { StartTime = 2000 }
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-03-02 03:20:25 +00:00
|
|
|
|
Autoplay = true,
|
2021-01-06 19:40:47 +00:00
|
|
|
|
PassCondition = () => checkSomeHit() && checkObjectsScale(0.29f)
|
2020-03-05 02:53:04 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCircleSize1() => CreateModTest(new ModTestData
|
|
|
|
|
{
|
|
|
|
|
Mod = new OsuModDifficultyAdjust { CircleSize = { Value = 1 } },
|
|
|
|
|
Autoplay = true,
|
|
|
|
|
PassCondition = () => checkSomeHit() && checkObjectsScale(0.78f)
|
2020-03-02 03:20:25 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[Test]
|
2020-03-05 01:21:25 +00:00
|
|
|
|
public void TestCircleSize10() => CreateModTest(new ModTestData
|
2020-03-02 03:20:25 +00:00
|
|
|
|
{
|
2020-03-05 01:21:25 +00:00
|
|
|
|
Mod = new OsuModDifficultyAdjust { CircleSize = { Value = 10 } },
|
2020-03-02 03:20:25 +00:00
|
|
|
|
Autoplay = true,
|
2020-03-05 02:53:04 +00:00
|
|
|
|
PassCondition = () => checkSomeHit() && checkObjectsScale(0.15f)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestApproachRate1() => CreateModTest(new ModTestData
|
|
|
|
|
{
|
|
|
|
|
Mod = new OsuModDifficultyAdjust { ApproachRate = { Value = 1 } },
|
|
|
|
|
Autoplay = true,
|
|
|
|
|
PassCondition = () => checkSomeHit() && checkObjectsPreempt(1680)
|
2020-03-02 03:20:25 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[Test]
|
2020-03-05 01:21:25 +00:00
|
|
|
|
public void TestApproachRate10() => CreateModTest(new ModTestData
|
2020-03-02 03:20:25 +00:00
|
|
|
|
{
|
2020-03-05 01:21:25 +00:00
|
|
|
|
Mod = new OsuModDifficultyAdjust { ApproachRate = { Value = 10 } },
|
2020-03-02 03:20:25 +00:00
|
|
|
|
Autoplay = true,
|
2020-03-05 02:53:04 +00:00
|
|
|
|
PassCondition = () => checkSomeHit() && checkObjectsPreempt(450)
|
2020-03-02 03:20:25 +00:00
|
|
|
|
});
|
2020-03-05 02:53:04 +00:00
|
|
|
|
|
|
|
|
|
private bool checkObjectsPreempt(double target)
|
|
|
|
|
{
|
|
|
|
|
var objects = Player.ChildrenOfType<DrawableHitCircle>();
|
|
|
|
|
if (!objects.Any())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return objects.All(o => o.HitObject.TimePreempt == target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool checkObjectsScale(float target)
|
|
|
|
|
{
|
|
|
|
|
var objects = Player.ChildrenOfType<DrawableHitCircle>();
|
|
|
|
|
if (!objects.Any())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return objects.All(o => Precision.AlmostEquals(o.ChildrenOfType<ShakeContainer>().First().Children.OfType<Container>().Single().Scale.X, target));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool checkSomeHit()
|
|
|
|
|
{
|
|
|
|
|
return Player.ScoreProcessor.JudgedHits >= 2;
|
|
|
|
|
}
|
2020-03-01 05:16:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|