mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 09:09:52 +08:00
f0ca3304b8
more productive than adjusting every single test
79 lines
3.2 KiB
C#
79 lines
3.2 KiB
C#
// 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 System.Collections.Generic;
|
|
using osu.Game.Beatmaps;
|
|
|
|
namespace osu.Game.Rulesets.Edit
|
|
{
|
|
/// <summary>
|
|
/// Represents the context provided by the beatmap verifier to the checks it runs.
|
|
/// Contains information about what is being checked and how it should be checked.
|
|
/// </summary>
|
|
public class BeatmapVerifierContext
|
|
{
|
|
/// <summary>
|
|
/// A record containing the <see cref="IWorkingBeatmap"/> and playable <see cref="IBeatmap"/> versions of a beatmap.
|
|
/// </summary>
|
|
public record VerifiedBeatmap(IWorkingBeatmap Working, IBeatmap Playable);
|
|
|
|
/// <summary>
|
|
/// The difficulty level which the current beatmap is considered to be.
|
|
/// </summary>
|
|
public DifficultyRating InterpretedDifficulty;
|
|
|
|
/// <summary>
|
|
/// The current beatmap being checked.
|
|
/// </summary>
|
|
public readonly VerifiedBeatmap CurrentDifficulty;
|
|
|
|
/// <summary>
|
|
/// Other beatmaps in the same beatmapset.
|
|
/// </summary>
|
|
public readonly IReadOnlyList<VerifiedBeatmap> OtherDifficulties;
|
|
|
|
/// <summary>
|
|
/// All beatmaps in the same beatmapset.
|
|
/// </summary>
|
|
public IEnumerable<VerifiedBeatmap> AllDifficulties => [CurrentDifficulty, ..OtherDifficulties];
|
|
|
|
public BeatmapVerifierContext(VerifiedBeatmap currentDifficulty, DifficultyRating difficultyRating = DifficultyRating.ExpertPlus, IReadOnlyList<VerifiedBeatmap>? otherDifficulties = null)
|
|
{
|
|
CurrentDifficulty = currentDifficulty;
|
|
InterpretedDifficulty = difficultyRating;
|
|
OtherDifficulties = otherDifficulties ?? new List<VerifiedBeatmap>();
|
|
}
|
|
|
|
public BeatmapVerifierContext(IBeatmap beatmap, IWorkingBeatmap workingBeatmap, DifficultyRating difficultyRating = DifficultyRating.ExpertPlus)
|
|
: this(new VerifiedBeatmap(workingBeatmap, beatmap), difficultyRating)
|
|
{
|
|
}
|
|
|
|
public static BeatmapVerifierContext Create(IBeatmap beatmap, IWorkingBeatmap workingBeatmap, DifficultyRating difficultyRating = DifficultyRating.ExpertPlus, BeatmapManager? beatmapManager = null)
|
|
{
|
|
var beatmapSet = beatmap.BeatmapInfo.BeatmapSet;
|
|
|
|
var current = new VerifiedBeatmap(workingBeatmap, beatmap);
|
|
|
|
if (beatmapSet?.Beatmaps == null || beatmapSet.Beatmaps.Count == 1)
|
|
return new BeatmapVerifierContext(current, difficultyRating);
|
|
|
|
var others = new List<VerifiedBeatmap>();
|
|
|
|
foreach (var info in beatmapSet.Beatmaps)
|
|
{
|
|
if (info.Equals(beatmap.BeatmapInfo))
|
|
continue;
|
|
|
|
var otherWorking = beatmapManager?.GetWorkingBeatmap(info);
|
|
var otherPlayable = otherWorking?.GetPlayableBeatmap(info.Ruleset);
|
|
|
|
if (otherWorking != null && otherPlayable != null)
|
|
others.Add(new VerifiedBeatmap(otherWorking, otherPlayable));
|
|
}
|
|
|
|
return new BeatmapVerifierContext(current, difficultyRating);
|
|
}
|
|
}
|
|
}
|