mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:33:01 +08:00
Inline ScoringValues
and make some more methods private
inside ScoreProcessor
This commit is contained in:
parent
7a54bcac57
commit
df94af4495
@ -264,7 +264,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
private void updateScore()
|
private void updateScore()
|
||||||
{
|
{
|
||||||
Accuracy.Value = currentMaximumScoringValues.BaseScore > 0 ? (double)currentScoringValues.BaseScore / currentMaximumScoringValues.BaseScore : 1;
|
Accuracy.Value = currentMaximumScoringValues.BaseScore > 0 ? (double)currentScoringValues.BaseScore / currentMaximumScoringValues.BaseScore : 1;
|
||||||
TotalScore.Value = ComputeScore(Mode.Value, currentScoringValues, maximumScoringValues);
|
TotalScore.Value = computeScore(Mode.Value, currentScoringValues, maximumScoringValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -299,9 +299,9 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
if (!ruleset.RulesetInfo.Equals(scoreInfo.Ruleset))
|
if (!ruleset.RulesetInfo.Equals(scoreInfo.Ruleset))
|
||||||
throw new ArgumentException($"Unexpected score ruleset. Expected \"{ruleset.RulesetInfo.ShortName}\" but was \"{scoreInfo.Ruleset.ShortName}\".");
|
throw new ArgumentException($"Unexpected score ruleset. Expected \"{ruleset.RulesetInfo.ShortName}\" but was \"{scoreInfo.Ruleset.ShortName}\".");
|
||||||
|
|
||||||
ExtractScoringValues(scoreInfo, out var current, out var maximum);
|
extractScoringValues(scoreInfo, out var current, out var maximum);
|
||||||
|
|
||||||
return ComputeScore(mode, current, maximum);
|
return computeScore(mode, current, maximum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -312,7 +312,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// <param name="maximum">The maximum scoring values.</param>
|
/// <param name="maximum">The maximum scoring values.</param>
|
||||||
/// <returns>The total score computed from the given scoring values.</returns>
|
/// <returns>The total score computed from the given scoring values.</returns>
|
||||||
[Pure]
|
[Pure]
|
||||||
public long ComputeScore(ScoringMode mode, ScoringValues current, ScoringValues maximum)
|
private long computeScore(ScoringMode mode, ScoringValues current, ScoringValues maximum)
|
||||||
{
|
{
|
||||||
double accuracyRatio = maximum.BaseScore > 0 ? (double)current.BaseScore / maximum.BaseScore : 1;
|
double accuracyRatio = maximum.BaseScore > 0 ? (double)current.BaseScore / maximum.BaseScore : 1;
|
||||||
double comboRatio = maximum.MaxCombo > 0 ? (double)current.MaxCombo / maximum.MaxCombo : 1;
|
double comboRatio = maximum.MaxCombo > 0 ? (double)current.MaxCombo / maximum.MaxCombo : 1;
|
||||||
@ -470,14 +470,14 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// Consumers are expected to more accurately fill in the above values through external means.
|
/// Consumers are expected to more accurately fill in the above values through external means.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// <b>Ensure</b> to fill in the maximum <see cref="ScoringValues.CountBasicHitObjects"/> for use in
|
/// <b>Ensure</b> to fill in the maximum <see cref="ScoringValues.CountBasicHitObjects"/> for use in
|
||||||
/// <see cref="ComputeScore(osu.Game.Rulesets.Scoring.ScoringMode,osu.Game.Scoring.ScoringValues,osu.Game.Scoring.ScoringValues)"/>.
|
/// <see cref="computeScore(osu.Game.Rulesets.Scoring.ScoringMode,ScoringValues,ScoringValues)"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="scoreInfo">The score to extract scoring values from.</param>
|
/// <param name="scoreInfo">The score to extract scoring values from.</param>
|
||||||
/// <param name="current">The "current" scoring values, representing the hit statistics as they appear.</param>
|
/// <param name="current">The "current" scoring values, representing the hit statistics as they appear.</param>
|
||||||
/// <param name="maximum">The "maximum" scoring values, representing the hit statistics as if the maximum hit result was attained each time.</param>
|
/// <param name="maximum">The "maximum" scoring values, representing the hit statistics as if the maximum hit result was attained each time.</param>
|
||||||
[Pure]
|
[Pure]
|
||||||
internal void ExtractScoringValues(ScoreInfo scoreInfo, out ScoringValues current, out ScoringValues maximum)
|
private void extractScoringValues(ScoreInfo scoreInfo, out ScoringValues current, out ScoringValues maximum)
|
||||||
{
|
{
|
||||||
extractScoringValues(scoreInfo.Statistics, out current, out maximum);
|
extractScoringValues(scoreInfo.Statistics, out current, out maximum);
|
||||||
current.MaxCombo = scoreInfo.MaxCombo;
|
current.MaxCombo = scoreInfo.MaxCombo;
|
||||||
@ -560,6 +560,32 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
hitEvents.Clear();
|
hitEvents.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stores the required scoring data that fulfils the minimum requirements for a <see cref="ScoreProcessor"/> to calculate score.
|
||||||
|
/// </summary>
|
||||||
|
private struct ScoringValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The sum of all "basic" <see cref="HitObject"/> scoring values. See: <see cref="HitResultExtensions.IsBasic"/> and <see cref="Judgement.ToNumericResult"/>.
|
||||||
|
/// </summary>
|
||||||
|
public long BaseScore;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sum of all "bonus" <see cref="HitObject"/> scoring values. See: <see cref="HitResultExtensions.IsBonus"/> and <see cref="Judgement.ToNumericResult"/>.
|
||||||
|
/// </summary>
|
||||||
|
public long BonusScore;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The highest achieved combo.
|
||||||
|
/// </summary>
|
||||||
|
public int MaxCombo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The count of "basic" <see cref="HitObject"/>s. See: <see cref="HitResultExtensions.IsBasic"/>.
|
||||||
|
/// </summary>
|
||||||
|
public int CountBasicHitObjects;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ScoringMode
|
public enum ScoringMode
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using MessagePack;
|
|
||||||
using osu.Game.Rulesets.Judgements;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
|
|
||||||
namespace osu.Game.Scoring
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Stores the required scoring data that fulfils the minimum requirements for a <see cref="ScoreProcessor"/> to calculate score.
|
|
||||||
/// </summary>
|
|
||||||
[MessagePackObject]
|
|
||||||
public struct ScoringValues
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The sum of all "basic" <see cref="HitObject"/> scoring values. See: <see cref="HitResultExtensions.IsBasic"/> and <see cref="Judgement.ToNumericResult"/>.
|
|
||||||
/// </summary>
|
|
||||||
[Key(0)]
|
|
||||||
public long BaseScore;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The sum of all "bonus" <see cref="HitObject"/> scoring values. See: <see cref="HitResultExtensions.IsBonus"/> and <see cref="Judgement.ToNumericResult"/>.
|
|
||||||
/// </summary>
|
|
||||||
[Key(1)]
|
|
||||||
public long BonusScore;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The highest achieved combo.
|
|
||||||
/// </summary>
|
|
||||||
[Key(2)]
|
|
||||||
public int MaxCombo;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The count of "basic" <see cref="HitObject"/>s. See: <see cref="HitResultExtensions.IsBasic"/>.
|
|
||||||
/// </summary>
|
|
||||||
[Key(3)]
|
|
||||||
public int CountBasicHitObjects;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user