mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 16:03:21 +08:00
Moved all online related score parsing to its class
This commit is contained in:
parent
e71f907f89
commit
01553fc9ef
@ -23,7 +23,12 @@ namespace osu.Game.Online.API.Requests
|
|||||||
private void onSuccess(GetScoresResponse r)
|
private void onSuccess(GetScoresResponse r)
|
||||||
{
|
{
|
||||||
foreach (OnlineScore score in r.Scores)
|
foreach (OnlineScore score in r.Scores)
|
||||||
score.GetModsFor(beatmap.Ruleset);
|
{
|
||||||
|
score.Beatmap = beatmap;
|
||||||
|
score.Ruleset = beatmap.Ruleset;
|
||||||
|
|
||||||
|
score.ResolveModString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override WebRequest CreateWebRequest()
|
protected override WebRequest CreateWebRequest()
|
||||||
|
@ -1,19 +1,90 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osu.Game.Rulesets.Replays;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Scoring
|
namespace osu.Game.Rulesets.Scoring
|
||||||
{
|
{
|
||||||
public class OnlineScore : Score
|
public class OnlineScore : Score
|
||||||
{
|
{
|
||||||
|
[JsonProperty(@"score")]
|
||||||
|
private double totalScore
|
||||||
|
{
|
||||||
|
set { TotalScore = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonProperty(@"max_combo")]
|
||||||
|
private int maxCombo
|
||||||
|
{
|
||||||
|
set { MaxCombo = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonProperty(@"user")]
|
||||||
|
private User user
|
||||||
|
{
|
||||||
|
set { User = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonProperty(@"replay_data")]
|
||||||
|
private Replay replay
|
||||||
|
{
|
||||||
|
set { Replay = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonProperty(@"score_id")]
|
||||||
|
private long onlineScoreID
|
||||||
|
{
|
||||||
|
set { OnlineScoreID = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonProperty(@"created_at")]
|
||||||
|
private DateTimeOffset date
|
||||||
|
{
|
||||||
|
set { Date = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonProperty(@"statistics")]
|
||||||
|
private Dictionary<string, dynamic> jsonStats
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
foreach (var kvp in value)
|
||||||
|
{
|
||||||
|
string key = kvp.Key;
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case @"count_300":
|
||||||
|
key = @"300";
|
||||||
|
break;
|
||||||
|
case @"count_100":
|
||||||
|
key = @"100";
|
||||||
|
break;
|
||||||
|
case @"count_50":
|
||||||
|
key = @"50";
|
||||||
|
break;
|
||||||
|
case @"count_miss":
|
||||||
|
key = @"x";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Statistics.Add(key, kvp.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[JsonProperty(@"mods")]
|
[JsonProperty(@"mods")]
|
||||||
private string[] modStrings { get; set; }
|
private string[] modStrings { get; set; }
|
||||||
|
|
||||||
public void GetModsFor(RulesetInfo ruleset)
|
public void ResolveModString()
|
||||||
{
|
{
|
||||||
Mods = ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
|
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -15,14 +14,12 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
{
|
{
|
||||||
public ScoreRank Rank { get; set; }
|
public ScoreRank Rank { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"score")]
|
|
||||||
public double TotalScore { get; set; }
|
public double TotalScore { get; set; }
|
||||||
|
|
||||||
public double Accuracy { get; set; }
|
public double Accuracy { get; set; }
|
||||||
|
|
||||||
public double Health { get; set; } = 1;
|
public double Health { get; set; } = 1;
|
||||||
|
|
||||||
[JsonProperty(@"max_combo")]
|
|
||||||
public int MaxCombo { get; set; }
|
public int MaxCombo { get; set; }
|
||||||
|
|
||||||
public int Combo { get; set; }
|
public int Combo { get; set; }
|
||||||
@ -31,51 +28,16 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
|
|
||||||
public Mod[] Mods { get; set; }
|
public Mod[] Mods { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"user")]
|
|
||||||
public User User;
|
public User User;
|
||||||
|
|
||||||
[JsonProperty(@"replay_data")]
|
|
||||||
public Replay Replay;
|
public Replay Replay;
|
||||||
|
|
||||||
public BeatmapInfo Beatmap;
|
public BeatmapInfo Beatmap;
|
||||||
|
|
||||||
[JsonProperty(@"score_id")]
|
|
||||||
public long OnlineScoreID;
|
public long OnlineScoreID;
|
||||||
|
|
||||||
[JsonProperty(@"created_at")]
|
|
||||||
public DateTimeOffset Date;
|
public DateTimeOffset Date;
|
||||||
|
|
||||||
[JsonProperty(@"statistics")]
|
|
||||||
private Dictionary<string, dynamic> jsonStats
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
foreach (var kvp in value)
|
|
||||||
{
|
|
||||||
string key = kvp.Key;
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case @"count_300":
|
|
||||||
key = @"300";
|
|
||||||
break;
|
|
||||||
case @"count_100":
|
|
||||||
key = @"100";
|
|
||||||
break;
|
|
||||||
case @"count_50":
|
|
||||||
key = @"50";
|
|
||||||
break;
|
|
||||||
case @"count_miss":
|
|
||||||
key = @"x";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Statistics.Add(key, kvp.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, dynamic> Statistics = new Dictionary<string, dynamic>();
|
public Dictionary<string, dynamic> Statistics = new Dictionary<string, dynamic>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user