From c5d5a5b342b8b06e5fbaabf5f45b2a4ada43be81 Mon Sep 17 00:00:00 2001 From: minisbett <39670899+minisbett@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:58:36 +0100 Subject: [PATCH] fix test issues --- .../UserInterface/TestSceneBeatmapAttributeText.cs | 4 ++-- osu.Game/Beatmaps/BeatmapDifficultyCache.cs | 2 +- .../Rulesets/Difficulty/IPerformanceAttributes.cs | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapAttributeText.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapAttributeText.cs index 236a0c5946..58469d956f 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapAttributeText.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapAttributeText.cs @@ -209,7 +209,7 @@ namespace osu.Game.Tests.Visual.UserInterface } protected override IDifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) - => new IDifficultyAttributes(mods, mods.OfType().SingleOrDefault()?.Difficulty.Value ?? 0); + => new EmptyDifficultyAttributes(); protected override IEnumerable CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) => Array.Empty(); @@ -226,7 +226,7 @@ namespace osu.Game.Tests.Visual.UserInterface } protected override IPerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, IDifficultyAttributes attributes) - => new IPerformanceAttributes { Total = score.Mods.OfType().SingleOrDefault()?.Performance.Value ?? 0 }; + => new EmptyPerformanceAttributes(); } private class TestMod : Mod diff --git a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs index fc4175415c..ef08314066 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs @@ -252,7 +252,7 @@ namespace osu.Game.Beatmaps var performanceCalculator = ruleset.CreatePerformanceCalculator(); if (performanceCalculator == null) - return new StarDifficulty(difficulty, new PerformanceAttributes()); + return new StarDifficulty(difficulty, new EmptyPerformanceAttributes()); ScoreProcessor scoreProcessor = ruleset.CreateScoreProcessor(); scoreProcessor.Mods.Value = key.OrderedMods; diff --git a/osu.Game/Rulesets/Difficulty/IPerformanceAttributes.cs b/osu.Game/Rulesets/Difficulty/IPerformanceAttributes.cs index bf4e8bd247..d98bc42c47 100644 --- a/osu.Game/Rulesets/Difficulty/IPerformanceAttributes.cs +++ b/osu.Game/Rulesets/Difficulty/IPerformanceAttributes.cs @@ -21,4 +21,17 @@ namespace osu.Game.Rulesets.Difficulty /// public IEnumerable GetAttributesForDisplay(); } + + /// + /// Represents a full, minimal implementation of . + /// + public class EmptyPerformanceAttributes : IPerformanceAttributes + { + public double Total { get; set; } + + public IEnumerable GetAttributesForDisplay() + { + yield return new PerformanceDisplayAttribute(nameof(Total), "Achieved PP", Total); + } + } }