mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Change statistics type, remove overridability
This commit is contained in:
parent
c291d6fc82
commit
e1feeded12
@ -48,7 +48,7 @@ namespace osu.Game.Online.Spectator
|
||||
/// Additional statistics that guides the score processor to calculate the correct score for this frame.
|
||||
/// </summary>
|
||||
[Key(5)]
|
||||
public Dictionary<string, object> ScoreProcessorStatistics { get; set; }
|
||||
public ScoreProcessorStatistics ScoreProcessorStatistics { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time at which this frame was received by the server.
|
||||
@ -71,13 +71,12 @@ namespace osu.Game.Online.Spectator
|
||||
// copy for safety
|
||||
Statistics = new Dictionary<HitResult, int>(score.Statistics);
|
||||
|
||||
ScoreProcessorStatistics = new Dictionary<string, object>();
|
||||
scoreProcessor.WriteScoreProcessorStatistics(ScoreProcessorStatistics);
|
||||
ScoreProcessorStatistics = scoreProcessor.GetScoreProcessorStatistics();
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
[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;
|
||||
Accuracy = accuracy;
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -397,29 +398,29 @@ namespace osu.Game.Rulesets.Scoring
|
||||
scoreResultCounts.Clear();
|
||||
scoreResultCounts.AddRange(frame.Header.Statistics);
|
||||
|
||||
ReadScoreProcessorStatistics(frame.Header.ScoreProcessorStatistics);
|
||||
SetScoreProcessorStatistics(frame.Header.ScoreProcessorStatistics);
|
||||
|
||||
updateScore();
|
||||
|
||||
OnResetFromReplayFrame?.Invoke();
|
||||
}
|
||||
|
||||
public virtual void WriteScoreProcessorStatistics(IDictionary<string, object> statistics)
|
||||
public ScoreProcessorStatistics GetScoreProcessorStatistics() => new ScoreProcessorStatistics
|
||||
{
|
||||
statistics.Add(nameof(currentMaximumBaseScore), currentMaximumBaseScore);
|
||||
statistics.Add(nameof(currentBaseScore), currentBaseScore);
|
||||
statistics.Add(nameof(currentCountBasicJudgements), currentCountBasicJudgements);
|
||||
statistics.Add(nameof(currentComboPortion), currentComboPortion);
|
||||
statistics.Add(nameof(currentBonusPortion), currentBonusPortion);
|
||||
}
|
||||
MaximumBaseScore = currentMaximumBaseScore,
|
||||
BaseScore = currentBaseScore,
|
||||
CountBasicJudgements = currentCountBasicJudgements,
|
||||
ComboPortion = currentComboPortion,
|
||||
BonusPortion = currentBonusPortion
|
||||
};
|
||||
|
||||
public virtual void ReadScoreProcessorStatistics(IReadOnlyDictionary<string, object> statistics)
|
||||
public void SetScoreProcessorStatistics(ScoreProcessorStatistics statistics)
|
||||
{
|
||||
currentMaximumBaseScore = (double)statistics.GetValueOrDefault(nameof(currentMaximumBaseScore), 0);
|
||||
currentBaseScore = (double)statistics.GetValueOrDefault(nameof(currentBaseScore), 0);
|
||||
currentCountBasicJudgements = (int)statistics.GetValueOrDefault(nameof(currentCountBasicJudgements), 0);
|
||||
currentComboPortion = (double)statistics.GetValueOrDefault(nameof(currentComboPortion), 0);
|
||||
currentBonusPortion = (double)statistics.GetValueOrDefault(nameof(currentBonusPortion), 0);
|
||||
currentMaximumBaseScore = statistics.MaximumBaseScore;
|
||||
currentBaseScore = statistics.BaseScore;
|
||||
currentCountBasicJudgements = statistics.CountBasicJudgements;
|
||||
currentComboPortion = statistics.ComboPortion;
|
||||
currentBonusPortion = statistics.BonusPortion;
|
||||
}
|
||||
|
||||
#region Static helper methods
|
||||
@ -493,4 +494,24 @@ namespace osu.Game.Rulesets.Scoring
|
||||
[LocalisableDescription(typeof(GameplaySettingsStrings), nameof(GameplaySettingsStrings.ClassicScoreDisplay))]
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user