mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Add maximum statistics to ScoreInfo/SoloScoreInfo
This commit is contained in:
parent
51e607e834
commit
f70af779a4
@ -74,6 +74,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty("statistics")]
|
||||
public Dictionary<HitResult, int> Statistics { get; set; } = new Dictionary<HitResult, int>();
|
||||
|
||||
[JsonProperty("maximum_statistics")]
|
||||
public Dictionary<HitResult, int> MaximumStatistics { get; set; } = new Dictionary<HitResult, int>();
|
||||
|
||||
#region osu-web API additions (not stored to database).
|
||||
|
||||
[JsonProperty("id")]
|
||||
@ -153,6 +156,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
MaxCombo = MaxCombo,
|
||||
Rank = Rank,
|
||||
Statistics = Statistics,
|
||||
MaximumStatistics = MaximumStatistics,
|
||||
Date = EndedAt,
|
||||
Hash = HasReplay ? "online" : string.Empty, // TODO: temporary?
|
||||
Mods = mods,
|
||||
@ -174,6 +178,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
Passed = score.Passed,
|
||||
Mods = score.APIMods,
|
||||
Statistics = score.Statistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value),
|
||||
MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value),
|
||||
};
|
||||
|
||||
public long OnlineID => ID ?? -1;
|
||||
|
@ -405,8 +405,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
return ScoreRank.D;
|
||||
}
|
||||
|
||||
public int GetStatistic(HitResult result) => scoreResultCounts.GetValueOrDefault(result);
|
||||
|
||||
/// <summary>
|
||||
/// Resets this ScoreProcessor to a default state.
|
||||
/// </summary>
|
||||
@ -449,7 +447,10 @@ namespace osu.Game.Rulesets.Scoring
|
||||
score.HitEvents = hitEvents;
|
||||
|
||||
foreach (var result in HitResultExtensions.ALL_TYPES)
|
||||
score.Statistics[result] = GetStatistic(result);
|
||||
score.Statistics[result] = scoreResultCounts.GetValueOrDefault(result);
|
||||
|
||||
foreach (var result in HitResultExtensions.ALL_TYPES)
|
||||
score.MaximumStatistics[result] = maximumResultCounts.GetValueOrDefault(result);
|
||||
|
||||
// Populate total score after everything else.
|
||||
score.TotalScore = (long)Math.Round(ComputeFinalScore(ScoringMode.Standardised, score));
|
||||
|
@ -63,6 +63,9 @@ namespace osu.Game.Scoring
|
||||
[MapTo("Statistics")]
|
||||
public string StatisticsJson { get; set; } = string.Empty;
|
||||
|
||||
[MapTo("MaximumStatistics")]
|
||||
public string MaximumStatisticsJson { get; set; } = string.Empty;
|
||||
|
||||
public ScoreInfo(BeatmapInfo? beatmap = null, RulesetInfo? ruleset = null, RealmUser? realmUser = null)
|
||||
{
|
||||
Ruleset = ruleset ?? new RulesetInfo();
|
||||
@ -181,6 +184,24 @@ namespace osu.Game.Scoring
|
||||
set => statistics = value;
|
||||
}
|
||||
|
||||
private Dictionary<HitResult, int>? maximumStatistics;
|
||||
|
||||
[Ignored]
|
||||
public Dictionary<HitResult, int> MaximumStatistics
|
||||
{
|
||||
get
|
||||
{
|
||||
if (maximumStatistics != null)
|
||||
return maximumStatistics;
|
||||
|
||||
if (!string.IsNullOrEmpty(MaximumStatisticsJson))
|
||||
maximumStatistics = JsonConvert.DeserializeObject<Dictionary<HitResult, int>>(MaximumStatisticsJson);
|
||||
|
||||
return maximumStatistics ??= new Dictionary<HitResult, int>();
|
||||
}
|
||||
set => maximumStatistics = value;
|
||||
}
|
||||
|
||||
private Mod[]? mods;
|
||||
|
||||
[Ignored]
|
||||
|
Loading…
Reference in New Issue
Block a user