mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 05:22:54 +08:00
Fix incorrectly encoded score IsPerfect value
This commit is contained in:
parent
498948f17d
commit
af713a7869
@ -6,6 +6,7 @@ using System.IO;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
@ -21,9 +22,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
public void CatchMergesFruitAndDropletMisses(int missCount, int largeTickMissCount)
|
||||
{
|
||||
var ruleset = new CatchRuleset().RulesetInfo;
|
||||
|
||||
var scoreInfo = TestResources.CreateTestScoreInfo(ruleset);
|
||||
var beatmap = new TestBeatmap(ruleset);
|
||||
|
||||
scoreInfo.Statistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
[HitResult.Great] = 50,
|
||||
@ -31,14 +32,41 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
[HitResult.Miss] = missCount,
|
||||
[HitResult.LargeTickMiss] = largeTickMissCount
|
||||
};
|
||||
var score = new Score { ScoreInfo = scoreInfo };
|
||||
|
||||
var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap);
|
||||
var score = new Score { ScoreInfo = scoreInfo };
|
||||
var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap, out _);
|
||||
|
||||
Assert.That(decodedAfterEncode.ScoreInfo.GetCountMiss(), Is.EqualTo(missCount + largeTickMissCount));
|
||||
}
|
||||
|
||||
private static Score encodeThenDecode(int beatmapVersion, Score score, TestBeatmap beatmap)
|
||||
[Test]
|
||||
public void ScoreWithMissIsNotPerfect()
|
||||
{
|
||||
var ruleset = new OsuRuleset().RulesetInfo;
|
||||
var scoreInfo = TestResources.CreateTestScoreInfo(ruleset);
|
||||
var beatmap = new TestBeatmap(ruleset);
|
||||
|
||||
scoreInfo.Statistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
[HitResult.Great] = 2,
|
||||
[HitResult.Miss] = 1,
|
||||
};
|
||||
|
||||
scoreInfo.MaximumStatistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
[HitResult.Great] = 3
|
||||
};
|
||||
|
||||
// Hit -> Miss -> Hit
|
||||
scoreInfo.Combo = 1;
|
||||
scoreInfo.MaxCombo = 1;
|
||||
|
||||
encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, new Score { ScoreInfo = scoreInfo }, beatmap, out var decoder);
|
||||
|
||||
Assert.That(decoder.DecodedPerfectValue, Is.False);
|
||||
}
|
||||
|
||||
private static Score encodeThenDecode(int beatmapVersion, Score score, TestBeatmap beatmap, out LegacyScoreDecoderTest.TestLegacyScoreDecoder decoder)
|
||||
{
|
||||
var encodeStream = new MemoryStream();
|
||||
|
||||
@ -47,7 +75,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
|
||||
var decodeStream = new MemoryStream(encodeStream.GetBuffer());
|
||||
|
||||
var decoder = new LegacyScoreDecoderTest.TestLegacyScoreDecoder(beatmapVersion);
|
||||
decoder = new LegacyScoreDecoderTest.TestLegacyScoreDecoder(beatmapVersion);
|
||||
var decodedAfterEncode = decoder.Parse(decodeStream);
|
||||
return decodedAfterEncode;
|
||||
}
|
||||
|
@ -27,6 +27,11 @@ namespace osu.Game.Scoring.Legacy
|
||||
{
|
||||
public abstract class LegacyScoreDecoder
|
||||
{
|
||||
/// <summary>
|
||||
/// The decoded "IsPerfect" value. This isn't used by osu!lazer.
|
||||
/// </summary>
|
||||
public bool DecodedPerfectValue { get; private set; }
|
||||
|
||||
private IBeatmap currentBeatmap;
|
||||
private Ruleset currentRuleset;
|
||||
|
||||
@ -82,7 +87,7 @@ namespace osu.Game.Scoring.Legacy
|
||||
scoreInfo.MaxCombo = sr.ReadUInt16();
|
||||
|
||||
/* score.Perfect = */
|
||||
sr.ReadBoolean();
|
||||
DecodedPerfectValue = sr.ReadBoolean();
|
||||
|
||||
scoreInfo.Mods = currentRuleset.ConvertFromLegacyMods((LegacyMods)sr.ReadInt32()).ToArray();
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Scoring.Legacy
|
||||
sw.Write((ushort)(score.ScoreInfo.GetCountMiss() ?? 0));
|
||||
sw.Write((int)(score.ScoreInfo.TotalScore));
|
||||
sw.Write((ushort)score.ScoreInfo.MaxCombo);
|
||||
sw.Write(score.ScoreInfo.Combo == score.ScoreInfo.MaxCombo);
|
||||
sw.Write(score.ScoreInfo.Combo == score.ScoreInfo.GetMaximumAchievableCombo());
|
||||
sw.Write((int)score.ScoreInfo.Ruleset.CreateInstance().ConvertToLegacyMods(score.ScoreInfo.Mods));
|
||||
|
||||
sw.Write(getHpGraphFormatted());
|
||||
|
Loading…
Reference in New Issue
Block a user