2021-11-09 11:37:12 +00:00
|
|
|
// 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.
|
|
|
|
|
2023-06-16 06:24:30 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2021-11-09 11:37:12 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2023-06-16 06:26:13 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-11-09 11:37:12 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Scoring
|
|
|
|
{
|
|
|
|
public static class ScoreInfoExtensions
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A user-presentable display title representing this score.
|
|
|
|
/// </summary>
|
2023-07-04 05:50:34 +00:00
|
|
|
public static string GetDisplayTitle(this IScoreInfo scoreInfo) => $"{scoreInfo.User.Username} playing {scoreInfo.Beatmap?.GetDisplayTitle() ?? "unknown"}";
|
2023-06-16 06:24:30 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Orders an array of <see cref="ScoreInfo"/>s by total score.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scores">The array of <see cref="ScoreInfo"/>s to reorder.</param>
|
|
|
|
/// <returns>The given <paramref name="scores"/> ordered by decreasing total score.</returns>
|
|
|
|
public static IEnumerable<ScoreInfo> OrderByTotalScore(this IEnumerable<ScoreInfo> scores)
|
|
|
|
=> scores.OrderByDescending(s => s.TotalScore)
|
|
|
|
.ThenBy(s => s.OnlineID)
|
|
|
|
// Local scores may not have an online ID. Fall back to date in these cases.
|
|
|
|
.ThenBy(s => s.Date);
|
2023-06-16 06:26:13 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the maximum achievable combo for the provided score.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="score">The <see cref="ScoreInfo"/> to compute the maximum achievable combo for.</param>
|
|
|
|
/// <returns>The maximum achievable combo.</returns>
|
|
|
|
public static int GetMaximumAchievableCombo(this ScoreInfo score) => score.MaximumStatistics.Where(kvp => kvp.Key.AffectsCombo()).Sum(kvp => kvp.Value);
|
2021-11-09 11:37:12 +00:00
|
|
|
}
|
|
|
|
}
|