mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 22:33:05 +08:00
Extract tuple into class
This commit is contained in:
parent
338b4c56ce
commit
d6d0bd90a3
41
osu.Game/Scoring/HitResultDisplayStatistic.cs
Normal file
41
osu.Game/Scoring/HitResultDisplayStatistic.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// 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 osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Scoring
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Compiled result data for a specific <see cref="HitResult"/> in a score.
|
||||||
|
/// </summary>
|
||||||
|
public class HitResultDisplayStatistic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The associated result type.
|
||||||
|
/// </summary>
|
||||||
|
public HitResult Result { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The count of successful hits of this type.
|
||||||
|
/// </summary>
|
||||||
|
public int Count { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum achievable hits of this type. May be null if undetermined.
|
||||||
|
/// </summary>
|
||||||
|
public int? MaxCount { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A custom display name for the result type. May be provided by rulesets to give better clarity.
|
||||||
|
/// </summary>
|
||||||
|
public string DisplayName { get; }
|
||||||
|
|
||||||
|
public HitResultDisplayStatistic(HitResult result, int count, int? maxCount, string displayName)
|
||||||
|
{
|
||||||
|
Result = result;
|
||||||
|
Count = count;
|
||||||
|
MaxCount = maxCount;
|
||||||
|
DisplayName = displayName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -213,22 +213,22 @@ namespace osu.Game.Scoring
|
|||||||
set => isLegacyScore = value;
|
set => isLegacyScore = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<(HitResult result, int count, int? maxCount)> GetStatisticsForDisplay()
|
public IEnumerable<HitResultDisplayStatistic> GetStatisticsForDisplay()
|
||||||
{
|
{
|
||||||
foreach (var key in OrderAttributeUtils.GetValuesInOrder<HitResult>())
|
foreach (var r in Ruleset.CreateInstance().GetHitResults())
|
||||||
{
|
{
|
||||||
if (key.IsBonus())
|
if (r.result.IsBonus())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int value = Statistics.GetOrDefault(key);
|
int value = Statistics.GetOrDefault(r.result);
|
||||||
|
|
||||||
switch (key)
|
switch (r.result)
|
||||||
{
|
{
|
||||||
case HitResult.SmallTickHit:
|
case HitResult.SmallTickHit:
|
||||||
{
|
{
|
||||||
int total = value + Statistics.GetOrDefault(HitResult.SmallTickMiss);
|
int total = value + Statistics.GetOrDefault(HitResult.SmallTickMiss);
|
||||||
if (total > 0)
|
if (total > 0)
|
||||||
yield return (key, value, total);
|
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
int total = value + Statistics.GetOrDefault(HitResult.LargeTickMiss);
|
int total = value + Statistics.GetOrDefault(HitResult.LargeTickMiss);
|
||||||
if (total > 0)
|
if (total > 0)
|
||||||
yield return (key, value, total);
|
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -247,8 +247,7 @@ namespace osu.Game.Scoring
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (value > 0 || key == HitResult.Miss)
|
yield return new HitResultDisplayStatistic(r.result, value, null, r.displayName);
|
||||||
yield return (key, value, null);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user