2020-08-18 18:51:26 +08: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.
|
|
|
|
|
2022-01-31 17:54:23 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2020-08-18 18:51:26 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
2022-01-31 17:54:23 +08:00
|
|
|
using osu.Game.Online.Spectator;
|
2020-08-18 18:51:26 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2022-01-31 17:54:23 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Replays;
|
2020-08-18 18:51:26 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Gameplay
|
|
|
|
{
|
|
|
|
[HeadlessTest]
|
|
|
|
public class TestSceneScoreProcessor : OsuTestScene
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestNoScoreIncreaseFromMiss()
|
|
|
|
{
|
2020-09-29 14:25:31 +08:00
|
|
|
var beatmap = new Beatmap<HitObject> { HitObjects = { new HitObject() } };
|
2020-08-18 18:51:26 +08:00
|
|
|
|
|
|
|
var scoreProcessor = new ScoreProcessor();
|
|
|
|
scoreProcessor.ApplyBeatmap(beatmap);
|
|
|
|
|
|
|
|
// Apply a miss judgement
|
2020-09-29 14:25:31 +08:00
|
|
|
scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new TestJudgement()) { Type = HitResult.Miss });
|
2020-08-18 18:51:26 +08:00
|
|
|
|
|
|
|
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(0.0));
|
|
|
|
}
|
|
|
|
|
2020-09-11 00:13:55 +08:00
|
|
|
[Test]
|
|
|
|
public void TestOnlyBonusScore()
|
|
|
|
{
|
2020-09-29 14:25:31 +08:00
|
|
|
var beatmap = new Beatmap<HitObject> { HitObjects = { new HitObject() } };
|
2020-09-11 00:13:55 +08:00
|
|
|
|
|
|
|
var scoreProcessor = new ScoreProcessor();
|
|
|
|
scoreProcessor.ApplyBeatmap(beatmap);
|
|
|
|
|
|
|
|
// Apply a judgement
|
2020-09-29 14:25:31 +08:00
|
|
|
scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new TestJudgement(HitResult.LargeBonus)) { Type = HitResult.LargeBonus });
|
2020-09-11 00:13:55 +08:00
|
|
|
|
2020-09-29 14:25:31 +08:00
|
|
|
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(Judgement.LARGE_BONUS_SCORE));
|
2020-08-18 18:51:26 +08:00
|
|
|
}
|
|
|
|
|
2022-01-31 17:54:23 +08:00
|
|
|
[Test]
|
|
|
|
public void TestResetFromReplayFrame()
|
|
|
|
{
|
|
|
|
var beatmap = new Beatmap<HitObject> { HitObjects = { new HitCircle() } };
|
|
|
|
|
|
|
|
var scoreProcessor = new ScoreProcessor();
|
|
|
|
scoreProcessor.ApplyBeatmap(beatmap);
|
|
|
|
|
|
|
|
scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[0], new TestJudgement(HitResult.Great)) { Type = HitResult.Great });
|
|
|
|
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(1_000_000));
|
|
|
|
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
|
|
|
|
|
|
|
// Reset with a miss instead.
|
|
|
|
scoreProcessor.ResetFromReplayFrame(new OsuRuleset(), new OsuReplayFrame
|
|
|
|
{
|
|
|
|
Header = new FrameHeader(0, 0, 0, new Dictionary<HitResult, int> { { HitResult.Miss, 1 } }, DateTimeOffset.Now)
|
|
|
|
});
|
|
|
|
|
|
|
|
Assert.That(scoreProcessor.TotalScore.Value, Is.Zero);
|
|
|
|
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
|
|
|
|
|
|
|
// Reset with no judged hit.
|
|
|
|
scoreProcessor.ResetFromReplayFrame(new OsuRuleset(), new OsuReplayFrame
|
|
|
|
{
|
|
|
|
Header = new FrameHeader(0, 0, 0, new Dictionary<HitResult, int>(), DateTimeOffset.Now)
|
|
|
|
});
|
|
|
|
|
|
|
|
Assert.That(scoreProcessor.TotalScore.Value, Is.Zero);
|
|
|
|
Assert.That(scoreProcessor.JudgedHits, Is.Zero);
|
|
|
|
}
|
|
|
|
|
2020-08-18 18:51:26 +08:00
|
|
|
private class TestJudgement : Judgement
|
|
|
|
{
|
2020-09-29 14:25:31 +08:00
|
|
|
public override HitResult MaxResult { get; }
|
2020-09-11 00:13:55 +08:00
|
|
|
|
2020-09-29 14:25:31 +08:00
|
|
|
public TestJudgement(HitResult maxResult = HitResult.Perfect)
|
|
|
|
{
|
|
|
|
MaxResult = maxResult;
|
|
|
|
}
|
2020-09-11 00:13:55 +08:00
|
|
|
}
|
2020-08-18 18:51:26 +08:00
|
|
|
}
|
|
|
|
}
|