2021-10-05 07:48:54 +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.
|
|
|
|
|
|
|
|
using System.Diagnostics;
|
2021-10-05 08:10:24 +00:00
|
|
|
using NUnit.Framework;
|
2021-10-05 07:48:54 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
|
|
|
public class TestScenePerformancePointsCounter : OsuTestScene
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private GameplayState gameplayState;
|
|
|
|
|
|
|
|
[Cached]
|
|
|
|
private ScoreProcessor scoreProcessor;
|
|
|
|
|
|
|
|
private int iteration;
|
2021-10-05 08:10:24 +00:00
|
|
|
private PerformancePointsCounter counter;
|
2021-10-05 07:48:54 +00:00
|
|
|
|
|
|
|
public TestScenePerformancePointsCounter()
|
|
|
|
{
|
|
|
|
var ruleset = CreateRuleset();
|
|
|
|
|
|
|
|
Debug.Assert(ruleset != null);
|
|
|
|
|
|
|
|
var beatmap = CreateWorkingBeatmap(ruleset.RulesetInfo)
|
|
|
|
.GetPlayableBeatmap(ruleset.RulesetInfo);
|
|
|
|
|
|
|
|
gameplayState = new GameplayState(beatmap, ruleset);
|
|
|
|
scoreProcessor = new ScoreProcessor();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Ruleset CreateRuleset() => new OsuRuleset();
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("Create counter", () =>
|
|
|
|
{
|
2021-10-05 08:10:24 +00:00
|
|
|
iteration = 0;
|
|
|
|
|
|
|
|
Child = counter = new PerformancePointsCounter
|
2021-10-05 07:48:54 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(5),
|
|
|
|
};
|
|
|
|
});
|
2021-10-05 08:10:24 +00:00
|
|
|
}
|
2021-10-05 07:48:54 +00:00
|
|
|
|
2021-10-05 08:10:24 +00:00
|
|
|
[Test]
|
|
|
|
public void TestBasicCounting()
|
|
|
|
{
|
|
|
|
AddAssert("counter displaying zero", () => counter.Current.Value == 0);
|
2021-10-05 07:48:54 +00:00
|
|
|
|
2021-10-05 08:10:24 +00:00
|
|
|
AddRepeatStep("Add judgement", applyOneJudgement, 10);
|
2021-10-05 07:48:54 +00:00
|
|
|
|
2021-10-05 08:10:24 +00:00
|
|
|
AddUntilStep("counter non-zero", () => counter.Current.Value > 0);
|
2021-10-05 08:24:36 +00:00
|
|
|
AddUntilStep("counter opaque", () => counter.Child.Alpha == 1);
|
2021-10-05 07:48:54 +00:00
|
|
|
|
|
|
|
AddStep("Revert judgement", () =>
|
|
|
|
{
|
|
|
|
scoreProcessor.RevertResult(new JudgementResult(new HitObject(), new OsuJudgement()));
|
|
|
|
});
|
2021-10-05 08:10:24 +00:00
|
|
|
|
|
|
|
AddUntilStep("counter faded", () => counter.Child.Alpha < 1);
|
|
|
|
|
|
|
|
AddStep("Add judgement", applyOneJudgement);
|
|
|
|
|
|
|
|
AddUntilStep("counter opaque", () => counter.Child.Alpha == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void applyOneJudgement()
|
|
|
|
{
|
|
|
|
var scoreInfo = gameplayState.Score.ScoreInfo;
|
|
|
|
|
|
|
|
scoreInfo.MaxCombo = iteration * 1000;
|
|
|
|
scoreInfo.Accuracy = 1;
|
|
|
|
scoreInfo.Statistics[HitResult.Great] = iteration * 1000;
|
|
|
|
|
|
|
|
scoreProcessor.ApplyResult(new OsuJudgementResult(new HitObject
|
|
|
|
{
|
|
|
|
StartTime = iteration * 10000,
|
|
|
|
}, new OsuJudgement())
|
|
|
|
{
|
|
|
|
Type = HitResult.Perfect,
|
|
|
|
});
|
|
|
|
|
|
|
|
iteration++;
|
2021-10-05 07:48:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|