mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge pull request #17157 from peppy/fix-statistics-json-serialisation
Fix incorrect serialisation of submitted scores
This commit is contained in:
@ -0,0 +1,40 @@
|
|||||||
|
// 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 Newtonsoft.Json;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.IO.Serialization;
|
||||||
|
using osu.Game.Online.Solo;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Online
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Basic testing to ensure our attribute-based naming is correctly working.
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSubmittableScoreJsonSerialization
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestScoreSerialisationViaExtensionMethod()
|
||||||
|
{
|
||||||
|
var score = new SubmittableScore(TestResources.CreateTestScoreInfo());
|
||||||
|
|
||||||
|
string serialised = score.Serialize();
|
||||||
|
|
||||||
|
Assert.That(serialised, Contains.Substring("large_tick_hit"));
|
||||||
|
Assert.That(serialised, Contains.Substring("\"rank\": \"S\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestScoreSerialisationWithoutSettings()
|
||||||
|
{
|
||||||
|
var score = new SubmittableScore(TestResources.CreateTestScoreInfo());
|
||||||
|
|
||||||
|
string serialised = JsonConvert.SerializeObject(score);
|
||||||
|
|
||||||
|
Assert.That(serialised, Contains.Substring("large_tick_hit"));
|
||||||
|
Assert.That(serialised, Contains.Substring("\"rank\":\"S\""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Scoring
|
namespace osu.Game.Rulesets.Scoring
|
||||||
@ -16,6 +17,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// Indicates that the object has not been judged yet.
|
/// Indicates that the object has not been judged yet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description(@"")]
|
[Description(@"")]
|
||||||
|
[EnumMember(Value = "none")]
|
||||||
[Order(14)]
|
[Order(14)]
|
||||||
None,
|
None,
|
||||||
|
|
||||||
@ -27,32 +29,39 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// "too far in the future). It should also define when a forced miss should be triggered (as a result of no user input in time).
|
/// "too far in the future). It should also define when a forced miss should be triggered (as a result of no user input in time).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Description(@"Miss")]
|
[Description(@"Miss")]
|
||||||
|
[EnumMember(Value = "miss")]
|
||||||
[Order(5)]
|
[Order(5)]
|
||||||
Miss,
|
Miss,
|
||||||
|
|
||||||
[Description(@"Meh")]
|
[Description(@"Meh")]
|
||||||
|
[EnumMember(Value = "meh")]
|
||||||
[Order(4)]
|
[Order(4)]
|
||||||
Meh,
|
Meh,
|
||||||
|
|
||||||
[Description(@"OK")]
|
[Description(@"OK")]
|
||||||
|
[EnumMember(Value = "ok")]
|
||||||
[Order(3)]
|
[Order(3)]
|
||||||
Ok,
|
Ok,
|
||||||
|
|
||||||
[Description(@"Good")]
|
[Description(@"Good")]
|
||||||
|
[EnumMember(Value = "good")]
|
||||||
[Order(2)]
|
[Order(2)]
|
||||||
Good,
|
Good,
|
||||||
|
|
||||||
[Description(@"Great")]
|
[Description(@"Great")]
|
||||||
|
[EnumMember(Value = "great")]
|
||||||
[Order(1)]
|
[Order(1)]
|
||||||
Great,
|
Great,
|
||||||
|
|
||||||
[Description(@"Perfect")]
|
[Description(@"Perfect")]
|
||||||
|
[EnumMember(Value = "perfect")]
|
||||||
[Order(0)]
|
[Order(0)]
|
||||||
Perfect,
|
Perfect,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates small tick miss.
|
/// Indicates small tick miss.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[EnumMember(Value = "small_tick_miss")]
|
||||||
[Order(11)]
|
[Order(11)]
|
||||||
SmallTickMiss,
|
SmallTickMiss,
|
||||||
|
|
||||||
@ -60,12 +69,14 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// Indicates a small tick hit.
|
/// Indicates a small tick hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description(@"S Tick")]
|
[Description(@"S Tick")]
|
||||||
|
[EnumMember(Value = "small_tick_hit")]
|
||||||
[Order(7)]
|
[Order(7)]
|
||||||
SmallTickHit,
|
SmallTickHit,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates a large tick miss.
|
/// Indicates a large tick miss.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[EnumMember(Value = "large_tick_miss")]
|
||||||
[Order(10)]
|
[Order(10)]
|
||||||
LargeTickMiss,
|
LargeTickMiss,
|
||||||
|
|
||||||
@ -73,6 +84,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// Indicates a large tick hit.
|
/// Indicates a large tick hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description(@"L Tick")]
|
[Description(@"L Tick")]
|
||||||
|
[EnumMember(Value = "large_tick_hit")]
|
||||||
[Order(6)]
|
[Order(6)]
|
||||||
LargeTickHit,
|
LargeTickHit,
|
||||||
|
|
||||||
@ -80,6 +92,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// Indicates a small bonus.
|
/// Indicates a small bonus.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("S Bonus")]
|
[Description("S Bonus")]
|
||||||
|
[EnumMember(Value = "small_bonus")]
|
||||||
[Order(9)]
|
[Order(9)]
|
||||||
SmallBonus,
|
SmallBonus,
|
||||||
|
|
||||||
@ -87,18 +100,21 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// Indicates a large bonus.
|
/// Indicates a large bonus.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("L Bonus")]
|
[Description("L Bonus")]
|
||||||
|
[EnumMember(Value = "large_bonus")]
|
||||||
[Order(8)]
|
[Order(8)]
|
||||||
LargeBonus,
|
LargeBonus,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates a miss that should be ignored for scoring purposes.
|
/// Indicates a miss that should be ignored for scoring purposes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[EnumMember(Value = "ignore_miss")]
|
||||||
[Order(13)]
|
[Order(13)]
|
||||||
IgnoreMiss,
|
IgnoreMiss,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates a hit that should be ignored for scoring purposes.
|
/// Indicates a hit that should be ignored for scoring purposes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[EnumMember(Value = "ignore_hit")]
|
||||||
[Order(12)]
|
[Order(12)]
|
||||||
IgnoreHit,
|
IgnoreHit,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user