From eceecde0f8e70f24f54c2de2a42b974a79609f18 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 27 Mar 2019 17:07:18 +0900 Subject: [PATCH 1/3] Make APIScoreInfo derive LegacyScoreInfo --- osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs index ded4ca71ee..0085fff7b9 100644 --- a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs +++ b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs @@ -8,12 +8,12 @@ using Newtonsoft.Json; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Scoring; -using osu.Game.Scoring; +using osu.Game.Scoring.Legacy; using osu.Game.Users; namespace osu.Game.Online.API.Requests.Responses { - public class APIScoreInfo : ScoreInfo + public class APIScoreInfo : LegacyScoreInfo { [JsonProperty(@"score")] private int totalScore @@ -96,7 +96,11 @@ namespace osu.Game.Online.API.Requests.Responses } [JsonProperty(@"mode_int")] - public int OnlineRulesetID { get; set; } + public int OnlineRulesetID + { + get => RulesetID; + set => RulesetID = value; + } [JsonProperty(@"mods")] private string[] modStrings { get; set; } From d2af2cf21d88abcf44f613a010df93fd4b55f4b0 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 27 Mar 2019 17:08:01 +0900 Subject: [PATCH 2/3] Set legacy api score statistics directly --- .../API/Requests/Responses/APIScoreInfo.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs index 0085fff7b9..ef893dfcb7 100644 --- a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs +++ b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs @@ -74,23 +74,27 @@ namespace osu.Game.Online.API.Requests.Responses HitResult newKey; switch (kvp.Key) { + case @"count_geki": + CountGeki = kvp.Value; + break; case @"count_300": - newKey = HitResult.Great; + Count300 = kvp.Value; + break; + case @"count_katu": + CountKatu = kvp.Value; break; case @"count_100": - newKey = HitResult.Good; + Count100 = kvp.Value; break; case @"count_50": - newKey = HitResult.Meh; + Count50 = kvp.Value; break; case @"count_miss": - newKey = HitResult.Miss; + CountMiss = kvp.Value; break; default: continue; } - - Statistics.Add(newKey, kvp.Value); } } } From 012dcc25c923254b5d8895314529663621ebfc40 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 27 Mar 2019 17:08:40 +0900 Subject: [PATCH 3/3] Rename APIScoreInfo -> APILegacyScoreInfo --- .../TestCaseBeatmapScoresContainer.cs | 27 +++++++++---------- .../Online/API/Requests/GetScoresRequest.cs | 6 ++--- .../API/Requests/GetUserScoresRequest.cs | 2 +- ...{APIScoreInfo.cs => APILegacyScoreInfo.cs} | 2 +- .../{APIScores.cs => APILegacyScores.cs} | 4 +-- .../BeatmapSet/Scores/DrawableScore.cs | 4 +-- .../BeatmapSet/Scores/DrawableTopScore.cs | 5 ++-- .../BeatmapSet/Scores/ScoresContainer.cs | 6 ++--- 8 files changed, 27 insertions(+), 29 deletions(-) rename osu.Game/Online/API/Requests/Responses/{APIScoreInfo.cs => APILegacyScoreInfo.cs} (98%) rename osu.Game/Online/API/Requests/Responses/{APIScores.cs => APILegacyScores.cs} (77%) diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs index c7970b6ebb..8de6cc2a88 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Graphics; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet.Scores; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu; @@ -44,9 +43,9 @@ namespace osu.Game.Tests.Visual.SongSelect } }; - IEnumerable scores = new[] + IEnumerable scores = new[] { - new APIScoreInfo + new ScoreInfo { User = new User { @@ -69,7 +68,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 1234567890, Accuracy = 1, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -91,7 +90,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 1234789, Accuracy = 0.9997, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -112,7 +111,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 12345678, Accuracy = 0.9854, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -132,7 +131,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 1234567, Accuracy = 0.8765, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -157,9 +156,9 @@ namespace osu.Game.Tests.Visual.SongSelect s.Statistics.Add(HitResult.Meh, RNG.Next(2000)); } - IEnumerable anotherScores = new[] + IEnumerable anotherScores = new[] { - new APIScoreInfo + new ScoreInfo { User = new User { @@ -181,7 +180,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 1234789, Accuracy = 0.9997, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -204,7 +203,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 1234567890, Accuracy = 1, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -220,7 +219,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 123456, Accuracy = 0.6543, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -241,7 +240,7 @@ namespace osu.Game.Tests.Visual.SongSelect TotalScore = 12345678, Accuracy = 0.9854, }, - new APIScoreInfo + new ScoreInfo { User = new User { @@ -269,7 +268,7 @@ namespace osu.Game.Tests.Visual.SongSelect s.Statistics.Add(HitResult.Meh, RNG.Next(2000)); } - var topScoreInfo = new APIScoreInfo + var topScoreInfo = new ScoreInfo { User = new User { diff --git a/osu.Game/Online/API/Requests/GetScoresRequest.cs b/osu.Game/Online/API/Requests/GetScoresRequest.cs index f6be849b56..0b6f65a0e0 100644 --- a/osu.Game/Online/API/Requests/GetScoresRequest.cs +++ b/osu.Game/Online/API/Requests/GetScoresRequest.cs @@ -10,7 +10,7 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class GetScoresRequest : APIRequest + public class GetScoresRequest : APIRequest { private readonly BeatmapInfo beatmap; private readonly BeatmapLeaderboardScope scope; @@ -31,9 +31,9 @@ namespace osu.Game.Online.API.Requests Success += onSuccess; } - private void onSuccess(APIScores r) + private void onSuccess(APILegacyScores r) { - foreach (APIScoreInfo score in r.Scores) + foreach (APILegacyScoreInfo score in r.Scores) score.Beatmap = beatmap; } diff --git a/osu.Game/Online/API/Requests/GetUserScoresRequest.cs b/osu.Game/Online/API/Requests/GetUserScoresRequest.cs index c5b436f99c..48a43bbbad 100644 --- a/osu.Game/Online/API/Requests/GetUserScoresRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserScoresRequest.cs @@ -6,7 +6,7 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class GetUserScoresRequest : APIRequest> + public class GetUserScoresRequest : APIRequest> { private readonly long userId; private readonly ScoreType type; diff --git a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs similarity index 98% rename from osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs rename to osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs index ef893dfcb7..8ee71ce9ac 100644 --- a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs +++ b/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs @@ -13,7 +13,7 @@ using osu.Game.Users; namespace osu.Game.Online.API.Requests.Responses { - public class APIScoreInfo : LegacyScoreInfo + public class APILegacyScoreInfo : LegacyScoreInfo { [JsonProperty(@"score")] private int totalScore diff --git a/osu.Game/Online/API/Requests/Responses/APIScores.cs b/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs similarity index 77% rename from osu.Game/Online/API/Requests/Responses/APIScores.cs rename to osu.Game/Online/API/Requests/Responses/APILegacyScores.cs index a867d86d9b..15ec5d3b13 100644 --- a/osu.Game/Online/API/Requests/Responses/APIScores.cs +++ b/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs @@ -6,9 +6,9 @@ using Newtonsoft.Json; namespace osu.Game.Online.API.Requests.Responses { - public class APIScores + public class APILegacyScores { [JsonProperty(@"scores")] - public IEnumerable Scores; + public IEnumerable Scores; } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs index c6c8315aeb..e3fb1bc961 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableScore.cs @@ -9,12 +9,12 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Leaderboards; using osu.Game.Overlays.Profile.Sections.Ranks; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; +using osu.Game.Scoring; using osu.Game.Users; namespace osu.Game.Overlays.BeatmapSet.Scores @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly Box background; - public DrawableScore(int index, APIScoreInfo score) + public DrawableScore(int index, ScoreInfo score) { ScoreModsContainer modsContainer; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs index 78e560cdbe..ac4485a410 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/DrawableTopScore.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Leaderboards; using osu.Game.Overlays.Profile.Sections.Ranks; using osu.Game.Rulesets.Mods; @@ -43,9 +42,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly InfoColumn statistics; private readonly ScoreModsContainer modsContainer; - private APIScoreInfo score; + private ScoreInfo score; - public APIScoreInfo Score + public ScoreInfo Score { get => score; set diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 3dd03fcea6..ef3129441b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -11,7 +11,7 @@ using System.Linq; using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.API; -using osu.Game.Online.API.Requests.Responses; +using osu.Game.Scoring; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -29,10 +29,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores set => loadingAnimation.FadeTo(value ? 1 : 0, fade_duration); } - private IEnumerable scores; + private IEnumerable scores; private BeatmapInfo beatmap; - public IEnumerable Scores + public IEnumerable Scores { get => scores; set