1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 10:33:22 +08:00

fix test issues

This commit is contained in:
minisbett 2024-11-17 23:58:36 +01:00
parent 109a5ad3d7
commit c5d5a5b342
No known key found for this signature in database
GPG Key ID: 2DB6D529C95A0403
3 changed files with 16 additions and 3 deletions

View File

@ -209,7 +209,7 @@ namespace osu.Game.Tests.Visual.UserInterface
} }
protected override IDifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) protected override IDifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
=> new IDifficultyAttributes(mods, mods.OfType<TestMod>().SingleOrDefault()?.Difficulty.Value ?? 0); => new EmptyDifficultyAttributes();
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
=> Array.Empty<DifficultyHitObject>(); => Array.Empty<DifficultyHitObject>();
@ -226,7 +226,7 @@ namespace osu.Game.Tests.Visual.UserInterface
} }
protected override IPerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, IDifficultyAttributes attributes) protected override IPerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, IDifficultyAttributes attributes)
=> new IPerformanceAttributes { Total = score.Mods.OfType<TestMod>().SingleOrDefault()?.Performance.Value ?? 0 }; => new EmptyPerformanceAttributes();
} }
private class TestMod : Mod private class TestMod : Mod

View File

@ -252,7 +252,7 @@ namespace osu.Game.Beatmaps
var performanceCalculator = ruleset.CreatePerformanceCalculator(); var performanceCalculator = ruleset.CreatePerformanceCalculator();
if (performanceCalculator == null) if (performanceCalculator == null)
return new StarDifficulty(difficulty, new PerformanceAttributes()); return new StarDifficulty(difficulty, new EmptyPerformanceAttributes());
ScoreProcessor scoreProcessor = ruleset.CreateScoreProcessor(); ScoreProcessor scoreProcessor = ruleset.CreateScoreProcessor();
scoreProcessor.Mods.Value = key.OrderedMods; scoreProcessor.Mods.Value = key.OrderedMods;

View File

@ -21,4 +21,17 @@ namespace osu.Game.Rulesets.Difficulty
/// <returns></returns> /// <returns></returns>
public IEnumerable<PerformanceDisplayAttribute> GetAttributesForDisplay(); public IEnumerable<PerformanceDisplayAttribute> GetAttributesForDisplay();
} }
/// <summary>
/// Represents a full, minimal implementation of <see cref="IPerformanceAttributes"/>.
/// </summary>
public class EmptyPerformanceAttributes : IPerformanceAttributes
{
public double Total { get; set; }
public IEnumerable<PerformanceDisplayAttribute> GetAttributesForDisplay()
{
yield return new PerformanceDisplayAttribute(nameof(Total), "Achieved PP", Total);
}
}
} }