mirror of
https://github.com/ppy/osu
synced 2024-12-15 19:36:34 +00:00
Merge pull request #19939 from smoogipoo/maximum-statistics-2
Add `maximum_statistics` to `ScoreInfo`
This commit is contained in:
commit
bb0701c457
@ -69,8 +69,9 @@ namespace osu.Game.Database
|
|||||||
/// 21 2022-07-27 Migrate collections to realm (BeatmapCollection).
|
/// 21 2022-07-27 Migrate collections to realm (BeatmapCollection).
|
||||||
/// 22 2022-07-31 Added ModPreset.
|
/// 22 2022-07-31 Added ModPreset.
|
||||||
/// 23 2022-08-01 Added LastLocalUpdate to BeatmapInfo.
|
/// 23 2022-08-01 Added LastLocalUpdate to BeatmapInfo.
|
||||||
|
/// 24 2022-08-22 Added MaximumStatistics to ScoreInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int schema_version = 23;
|
private const int schema_version = 24;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
||||||
|
@ -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;
|
||||||
|
@ -128,8 +128,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
private bool beatmapApplied;
|
private bool beatmapApplied;
|
||||||
|
|
||||||
private readonly Dictionary<HitResult, int> scoreResultCounts = new Dictionary<HitResult, int>();
|
private readonly Dictionary<HitResult, int> scoreResultCounts = new Dictionary<HitResult, int>();
|
||||||
|
private readonly Dictionary<HitResult, int> maximumResultCounts = new Dictionary<HitResult, int>();
|
||||||
private Dictionary<HitResult, int>? maximumResultCounts;
|
|
||||||
|
|
||||||
private readonly List<HitEvent> hitEvents = new List<HitEvent>();
|
private readonly List<HitEvent> hitEvents = new List<HitEvent>();
|
||||||
private HitObject? lastHitObject;
|
private HitObject? lastHitObject;
|
||||||
@ -405,8 +404,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>
|
||||||
@ -421,7 +418,9 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
if (storeResults)
|
if (storeResults)
|
||||||
{
|
{
|
||||||
maximumScoringValues = currentScoringValues;
|
maximumScoringValues = currentScoringValues;
|
||||||
maximumResultCounts = new Dictionary<HitResult, int>(scoreResultCounts);
|
|
||||||
|
maximumResultCounts.Clear();
|
||||||
|
maximumResultCounts.AddRange(scoreResultCounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
scoreResultCounts.Clear();
|
scoreResultCounts.Clear();
|
||||||
@ -449,7 +448,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));
|
||||||
|
@ -73,6 +73,9 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(model.StatisticsJson))
|
if (string.IsNullOrEmpty(model.StatisticsJson))
|
||||||
model.StatisticsJson = JsonConvert.SerializeObject(model.Statistics);
|
model.StatisticsJson = JsonConvert.SerializeObject(model.Statistics);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.MaximumStatisticsJson))
|
||||||
|
model.MaximumStatisticsJson = JsonConvert.SerializeObject(model.MaximumStatistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PostImport(ScoreInfo model, Realm realm, bool batchImport)
|
protected override void PostImport(ScoreInfo model, Realm realm, bool batchImport)
|
||||||
|
@ -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();
|
||||||
@ -133,6 +136,7 @@ namespace osu.Game.Scoring
|
|||||||
var clone = (ScoreInfo)this.Detach().MemberwiseClone();
|
var clone = (ScoreInfo)this.Detach().MemberwiseClone();
|
||||||
|
|
||||||
clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics);
|
clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics);
|
||||||
|
clone.MaximumStatistics = new Dictionary<HitResult, int>(clone.MaximumStatistics);
|
||||||
clone.RealmUser = new RealmUser
|
clone.RealmUser = new RealmUser
|
||||||
{
|
{
|
||||||
OnlineID = RealmUser.OnlineID,
|
OnlineID = RealmUser.OnlineID,
|
||||||
@ -181,6 +185,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