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