mirror of
https://github.com/ppy/osu
synced 2025-02-05 21:01:37 +00:00
Move raw ScoreProcessor values into ScoringValues struct
This commit is contained in:
parent
132c94c1b5
commit
af0f934e1a
@ -88,17 +88,20 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
private readonly double accuracyPortion;
|
private readonly double accuracyPortion;
|
||||||
private readonly double comboPortion;
|
private readonly double comboPortion;
|
||||||
|
|
||||||
private int maxAchievableCombo;
|
/// <summary>
|
||||||
|
/// Maximum achievable scoring values.
|
||||||
|
/// </summary>
|
||||||
|
private ScoringValues maximumScoringValues;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum achievable base score.
|
/// Maximum achievable scoring values up to the current point in time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private double maxBaseScore;
|
private ScoringValues rollingMaximumScoringValues;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum number of basic (non-tick and non-bonus) hitobjects.
|
/// Scoring values for the current play.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int maxBasicHitObjects;
|
private ScoringValues currentScoringValues;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum <see cref="HitResult"/> of a basic (non-tick and non-bonus) hitobject.
|
/// The maximum <see cref="HitResult"/> of a basic (non-tick and non-bonus) hitobject.
|
||||||
@ -106,9 +109,6 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private HitResult? maxBasicResult;
|
private HitResult? maxBasicResult;
|
||||||
|
|
||||||
private double rollingMaxBaseScore;
|
|
||||||
private double baseScore;
|
|
||||||
private int basicHitObjects;
|
|
||||||
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>();
|
||||||
@ -164,23 +164,42 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) + 1;
|
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) + 1;
|
||||||
|
|
||||||
if (!result.Type.IsScorable())
|
if (!result.Type.IsScorable())
|
||||||
return;
|
{
|
||||||
|
// The inverse of non-scorable (ignore) judgements may be bonus judgements.
|
||||||
|
if (result.Judgement.MaxResult.IsBonus())
|
||||||
|
rollingMaximumScoringValues.BonusScore += result.Judgement.MaxNumericResult;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update rolling combo.
|
||||||
if (result.Type.IncreasesCombo())
|
if (result.Type.IncreasesCombo())
|
||||||
Combo.Value++;
|
Combo.Value++;
|
||||||
else if (result.Type.BreaksCombo())
|
else if (result.Type.BreaksCombo())
|
||||||
Combo.Value = 0;
|
Combo.Value = 0;
|
||||||
|
|
||||||
double scoreIncrease = result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
// Update maximum combo.
|
||||||
|
currentScoringValues.MaxCombo = HighestCombo.Value;
|
||||||
|
rollingMaximumScoringValues.MaxCombo += result.Judgement.MaxResult.AffectsCombo() ? 1 : 0;
|
||||||
|
|
||||||
if (!result.Type.IsBonus())
|
// Update base/bonus score.
|
||||||
|
if (result.Type.IsBonus())
|
||||||
{
|
{
|
||||||
baseScore += scoreIncrease;
|
currentScoringValues.BonusScore += result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
rollingMaxBaseScore += result.Judgement.MaxNumericResult;
|
rollingMaximumScoringValues.BonusScore += result.Judgement.MaxNumericResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentScoringValues.BaseScore += result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
|
rollingMaximumScoringValues.BaseScore += result.Judgement.MaxNumericResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update hitobject count.
|
||||||
if (result.Type.IsBasic())
|
if (result.Type.IsBasic())
|
||||||
basicHitObjects++;
|
{
|
||||||
|
currentScoringValues.HitObjects++;
|
||||||
|
rollingMaximumScoringValues.HitObjects++;
|
||||||
|
}
|
||||||
|
|
||||||
hitEvents.Add(CreateHitEvent(result));
|
hitEvents.Add(CreateHitEvent(result));
|
||||||
lastHitObject = result.HitObject;
|
lastHitObject = result.HitObject;
|
||||||
@ -207,18 +226,36 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) - 1;
|
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) - 1;
|
||||||
|
|
||||||
if (!result.Type.IsScorable())
|
if (!result.Type.IsScorable())
|
||||||
return;
|
|
||||||
|
|
||||||
double scoreIncrease = result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
|
||||||
|
|
||||||
if (!result.Type.IsBonus())
|
|
||||||
{
|
{
|
||||||
baseScore -= scoreIncrease;
|
// The inverse of non-scorable (ignore) judgements may be bonus judgements.
|
||||||
rollingMaxBaseScore -= result.Judgement.MaxNumericResult;
|
if (result.Judgement.MaxResult.IsBonus())
|
||||||
|
rollingMaximumScoringValues.BonusScore -= result.Judgement.MaxNumericResult;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update maximum combo.
|
||||||
|
currentScoringValues.MaxCombo = HighestCombo.Value;
|
||||||
|
rollingMaximumScoringValues.MaxCombo -= result.Judgement.MaxResult.AffectsCombo() ? 1 : 0;
|
||||||
|
|
||||||
|
// Update base/bonus score.
|
||||||
|
if (result.Type.IsBonus())
|
||||||
|
{
|
||||||
|
currentScoringValues.BonusScore -= result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
|
rollingMaximumScoringValues.BonusScore -= result.Judgement.MaxNumericResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentScoringValues.BaseScore -= result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
|
rollingMaximumScoringValues.BaseScore -= result.Judgement.MaxNumericResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update hitobject count.
|
||||||
if (result.Type.IsBasic())
|
if (result.Type.IsBasic())
|
||||||
basicHitObjects--;
|
{
|
||||||
|
currentScoringValues.HitObjects--;
|
||||||
|
rollingMaximumScoringValues.HitObjects--;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Assert(hitEvents.Count > 0);
|
Debug.Assert(hitEvents.Count > 0);
|
||||||
lastHitObject = hitEvents[^1].LastHitObject;
|
lastHitObject = hitEvents[^1].LastHitObject;
|
||||||
@ -229,12 +266,12 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
|
|
||||||
private void updateScore()
|
private void updateScore()
|
||||||
{
|
{
|
||||||
double rollingAccuracyRatio = rollingMaxBaseScore > 0 ? baseScore / rollingMaxBaseScore : 1;
|
double rollingAccuracyRatio = rollingMaximumScoringValues.BaseScore > 0 ? currentScoringValues.BaseScore / rollingMaximumScoringValues.BaseScore : 1;
|
||||||
double accuracyRatio = maxBaseScore > 0 ? baseScore / maxBaseScore : 1;
|
double accuracyRatio = maximumScoringValues.BaseScore > 0 ? currentScoringValues.BaseScore / maximumScoringValues.BaseScore : 1;
|
||||||
double comboRatio = maxAchievableCombo > 0 ? (double)HighestCombo.Value / maxAchievableCombo : 1;
|
double comboRatio = maximumScoringValues.MaxCombo > 0 ? currentScoringValues.MaxCombo / maximumScoringValues.MaxCombo : 1;
|
||||||
|
|
||||||
Accuracy.Value = rollingAccuracyRatio;
|
Accuracy.Value = rollingAccuracyRatio;
|
||||||
TotalScore.Value = ComputeScore(Mode.Value, accuracyRatio, comboRatio, getBonusScore(scoreResultCounts), maxBasicHitObjects);
|
TotalScore.Value = ComputeScore(Mode.Value, accuracyRatio, comboRatio, getBonusScore(scoreResultCounts), maximumScoringValues.HitObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -286,10 +323,10 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
out _,
|
out _,
|
||||||
out _);
|
out _);
|
||||||
|
|
||||||
double accuracyRatio = maxBaseScore > 0 ? extractedBaseScore / maxBaseScore : 1;
|
double accuracyRatio = maximumScoringValues.BaseScore > 0 ? extractedBaseScore / maximumScoringValues.BaseScore : 1;
|
||||||
double comboRatio = maxAchievableCombo > 0 ? (double)scoreInfo.MaxCombo / maxAchievableCombo : 1;
|
double comboRatio = maximumScoringValues.MaxCombo > 0 ? (double)scoreInfo.MaxCombo / maximumScoringValues.MaxCombo : 1;
|
||||||
|
|
||||||
return ComputeScore(mode, accuracyRatio, comboRatio, getBonusScore(scoreInfo.Statistics), maxBasicHitObjects);
|
return ComputeScore(mode, accuracyRatio, comboRatio, getBonusScore(scoreInfo.Statistics), maximumScoringValues.HitObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -398,15 +435,10 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
lastHitObject = null;
|
lastHitObject = null;
|
||||||
|
|
||||||
if (storeResults)
|
if (storeResults)
|
||||||
{
|
maximumScoringValues = currentScoringValues;
|
||||||
maxAchievableCombo = HighestCombo.Value;
|
|
||||||
maxBaseScore = baseScore;
|
|
||||||
maxBasicHitObjects = basicHitObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
baseScore = 0;
|
currentScoringValues = default;
|
||||||
rollingMaxBaseScore = 0;
|
rollingMaximumScoringValues = default;
|
||||||
basicHitObjects = 0;
|
|
||||||
|
|
||||||
TotalScore.Value = 0;
|
TotalScore.Value = 0;
|
||||||
Accuracy.Value = 1;
|
Accuracy.Value = 1;
|
||||||
@ -440,7 +472,10 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
if (frame.Header == null)
|
if (frame.Header == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
extractFromStatistics(frame.Header.Statistics, out baseScore, out rollingMaxBaseScore, out _, out _);
|
extractFromStatistics(frame.Header.Statistics, out double baseScore, out double rollingMaxBaseScore, out _, out _);
|
||||||
|
currentScoringValues.BaseScore = baseScore;
|
||||||
|
rollingMaximumScoringValues.BaseScore = rollingMaxBaseScore;
|
||||||
|
|
||||||
HighestCombo.Value = frame.Header.MaxCombo;
|
HighestCombo.Value = frame.Header.MaxCombo;
|
||||||
|
|
||||||
scoreResultCounts.Clear();
|
scoreResultCounts.Clear();
|
||||||
|
38
osu.Game/Scoring/ScoringValues.cs
Normal file
38
osu.Game/Scoring/ScoringValues.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using MessagePack;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Scoring
|
||||||
|
{
|
||||||
|
[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 double 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 double 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 HitObjects;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user