1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 08:22:56 +08:00

Change statistics type, remove overridability

This commit is contained in:
Dan Balasescu 2023-05-22 12:49:41 +09:00
parent c291d6fc82
commit e1feeded12
2 changed files with 38 additions and 18 deletions

View File

@ -48,7 +48,7 @@ namespace osu.Game.Online.Spectator
/// Additional statistics that guides the score processor to calculate the correct score for this frame. /// Additional statistics that guides the score processor to calculate the correct score for this frame.
/// </summary> /// </summary>
[Key(5)] [Key(5)]
public Dictionary<string, object> ScoreProcessorStatistics { get; set; } public ScoreProcessorStatistics ScoreProcessorStatistics { get; set; }
/// <summary> /// <summary>
/// The time at which this frame was received by the server. /// The time at which this frame was received by the server.
@ -71,13 +71,12 @@ namespace osu.Game.Online.Spectator
// copy for safety // copy for safety
Statistics = new Dictionary<HitResult, int>(score.Statistics); Statistics = new Dictionary<HitResult, int>(score.Statistics);
ScoreProcessorStatistics = new Dictionary<string, object>(); ScoreProcessorStatistics = scoreProcessor.GetScoreProcessorStatistics();
scoreProcessor.WriteScoreProcessorStatistics(ScoreProcessorStatistics);
} }
[JsonConstructor] [JsonConstructor]
[SerializationConstructor] [SerializationConstructor]
public FrameHeader(long totalScore, double accuracy, int combo, int maxCombo, Dictionary<HitResult, int> statistics, Dictionary<string, object> scoreProcessorStatistics, DateTimeOffset receivedTime) public FrameHeader(long totalScore, double accuracy, int combo, int maxCombo, Dictionary<HitResult, int> statistics, ScoreProcessorStatistics scoreProcessorStatistics, DateTimeOffset receivedTime)
{ {
TotalScore = totalScore; TotalScore = totalScore;
Accuracy = accuracy; Accuracy = accuracy;

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using MessagePack;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -397,29 +398,29 @@ namespace osu.Game.Rulesets.Scoring
scoreResultCounts.Clear(); scoreResultCounts.Clear();
scoreResultCounts.AddRange(frame.Header.Statistics); scoreResultCounts.AddRange(frame.Header.Statistics);
ReadScoreProcessorStatistics(frame.Header.ScoreProcessorStatistics); SetScoreProcessorStatistics(frame.Header.ScoreProcessorStatistics);
updateScore(); updateScore();
OnResetFromReplayFrame?.Invoke(); OnResetFromReplayFrame?.Invoke();
} }
public virtual void WriteScoreProcessorStatistics(IDictionary<string, object> statistics) public ScoreProcessorStatistics GetScoreProcessorStatistics() => new ScoreProcessorStatistics
{ {
statistics.Add(nameof(currentMaximumBaseScore), currentMaximumBaseScore); MaximumBaseScore = currentMaximumBaseScore,
statistics.Add(nameof(currentBaseScore), currentBaseScore); BaseScore = currentBaseScore,
statistics.Add(nameof(currentCountBasicJudgements), currentCountBasicJudgements); CountBasicJudgements = currentCountBasicJudgements,
statistics.Add(nameof(currentComboPortion), currentComboPortion); ComboPortion = currentComboPortion,
statistics.Add(nameof(currentBonusPortion), currentBonusPortion); BonusPortion = currentBonusPortion
} };
public virtual void ReadScoreProcessorStatistics(IReadOnlyDictionary<string, object> statistics) public void SetScoreProcessorStatistics(ScoreProcessorStatistics statistics)
{ {
currentMaximumBaseScore = (double)statistics.GetValueOrDefault(nameof(currentMaximumBaseScore), 0); currentMaximumBaseScore = statistics.MaximumBaseScore;
currentBaseScore = (double)statistics.GetValueOrDefault(nameof(currentBaseScore), 0); currentBaseScore = statistics.BaseScore;
currentCountBasicJudgements = (int)statistics.GetValueOrDefault(nameof(currentCountBasicJudgements), 0); currentCountBasicJudgements = statistics.CountBasicJudgements;
currentComboPortion = (double)statistics.GetValueOrDefault(nameof(currentComboPortion), 0); currentComboPortion = statistics.ComboPortion;
currentBonusPortion = (double)statistics.GetValueOrDefault(nameof(currentBonusPortion), 0); currentBonusPortion = statistics.BonusPortion;
} }
#region Static helper methods #region Static helper methods
@ -493,4 +494,24 @@ namespace osu.Game.Rulesets.Scoring
[LocalisableDescription(typeof(GameplaySettingsStrings), nameof(GameplaySettingsStrings.ClassicScoreDisplay))] [LocalisableDescription(typeof(GameplaySettingsStrings), nameof(GameplaySettingsStrings.ClassicScoreDisplay))]
Classic Classic
} }
[Serializable]
[MessagePackObject]
public class ScoreProcessorStatistics
{
[Key(0)]
public double MaximumBaseScore { get; set; }
[Key(1)]
public double BaseScore { get; set; }
[Key(2)]
public int CountBasicJudgements { get; set; }
[Key(3)]
public double ComboPortion { get; set; }
[Key(4)]
public double BonusPortion { get; set; }
}
} }