mirror of
https://github.com/osukey/osukey.git
synced 2025-06-08 12:58:01 +09:00
Add helper to construct APIBeatmap
This commit is contained in:
parent
539cbe62c6
commit
a5183cec77
@ -225,12 +225,24 @@ namespace osu.Game.Tests.Visual
|
|||||||
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a sample API Beatmap with BeatmapSet populated.
|
/// Returns a sample API beatmap with a populated beatmap set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
|
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
|
||||||
protected APIBeatmap CreateAPIBeatmap(RulesetInfo ruleset = null)
|
protected APIBeatmap CreateAPIBeatmap(RulesetInfo ruleset = null) => CreateAPIBeatmap(CreateBeatmap(ruleset ?? Ruleset.Value).BeatmapInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a sample API beatmap set containing a beatmap.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
|
||||||
|
protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset = null) => CreateAPIBeatmapSet(CreateBeatmap(ruleset ?? Ruleset.Value).BeatmapInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a sample API beatmap with a populated beatmap set from a given source beatmap.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="original">The source beatmap.</param>
|
||||||
|
public static APIBeatmap CreateAPIBeatmap(IBeatmapInfo original)
|
||||||
{
|
{
|
||||||
var beatmapSet = CreateAPIBeatmapSet(ruleset ?? Ruleset.Value);
|
var beatmapSet = CreateAPIBeatmapSet(original);
|
||||||
|
|
||||||
// Avoid circular reference.
|
// Avoid circular reference.
|
||||||
var beatmap = beatmapSet.Beatmaps.First();
|
var beatmap = beatmapSet.Beatmaps.First();
|
||||||
@ -243,18 +255,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a sample API BeatmapSet with beatmaps populated.
|
/// Constructs a sample API beatmap set containing a beatmap from a given source beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
|
/// <param name="original">The source beatmap.</param>
|
||||||
protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset = null)
|
public static APIBeatmapSet CreateAPIBeatmapSet(IBeatmapInfo original)
|
||||||
{
|
{
|
||||||
var beatmap = CreateBeatmap(ruleset ?? Ruleset.Value).BeatmapInfo;
|
Debug.Assert(original.BeatmapSet != null);
|
||||||
|
|
||||||
Debug.Assert(beatmap.BeatmapSet != null);
|
|
||||||
|
|
||||||
return new APIBeatmapSet
|
return new APIBeatmapSet
|
||||||
{
|
{
|
||||||
OnlineID = ((IBeatmapSetInfo)beatmap.BeatmapSet).OnlineID,
|
OnlineID = original.BeatmapSet.OnlineID,
|
||||||
Status = BeatmapOnlineStatus.Ranked,
|
Status = BeatmapOnlineStatus.Ranked,
|
||||||
Covers = new BeatmapSetOnlineCovers
|
Covers = new BeatmapSetOnlineCovers
|
||||||
{
|
{
|
||||||
@ -262,29 +272,29 @@ namespace osu.Game.Tests.Visual
|
|||||||
Card = "https://assets.ppy.sh/beatmaps/163112/covers/card.jpg",
|
Card = "https://assets.ppy.sh/beatmaps/163112/covers/card.jpg",
|
||||||
List = "https://assets.ppy.sh/beatmaps/163112/covers/list.jpg"
|
List = "https://assets.ppy.sh/beatmaps/163112/covers/list.jpg"
|
||||||
},
|
},
|
||||||
Title = beatmap.Metadata.Title,
|
Title = original.Metadata.Title,
|
||||||
TitleUnicode = beatmap.Metadata.TitleUnicode,
|
TitleUnicode = original.Metadata.TitleUnicode,
|
||||||
Artist = beatmap.Metadata.Artist,
|
Artist = original.Metadata.Artist,
|
||||||
ArtistUnicode = beatmap.Metadata.ArtistUnicode,
|
ArtistUnicode = original.Metadata.ArtistUnicode,
|
||||||
Author = new APIUser
|
Author = new APIUser
|
||||||
{
|
{
|
||||||
Username = beatmap.Metadata.Author.Username,
|
Username = original.Metadata.Author.Username,
|
||||||
Id = beatmap.Metadata.Author.OnlineID
|
Id = original.Metadata.Author.OnlineID
|
||||||
},
|
},
|
||||||
Source = beatmap.Metadata.Source,
|
Source = original.Metadata.Source,
|
||||||
Tags = beatmap.Metadata.Tags,
|
Tags = original.Metadata.Tags,
|
||||||
Beatmaps = new[]
|
Beatmaps = new[]
|
||||||
{
|
{
|
||||||
new APIBeatmap
|
new APIBeatmap
|
||||||
{
|
{
|
||||||
OnlineID = ((IBeatmapInfo)beatmap).OnlineID,
|
OnlineID = original.OnlineID,
|
||||||
OnlineBeatmapSetID = ((IBeatmapSetInfo)beatmap.BeatmapSet).OnlineID,
|
OnlineBeatmapSetID = original.BeatmapSet.OnlineID,
|
||||||
Status = beatmap.Status,
|
Status = ((BeatmapInfo)original).Status,
|
||||||
Checksum = beatmap.MD5Hash,
|
Checksum = original.MD5Hash,
|
||||||
AuthorID = beatmap.Metadata.Author.OnlineID,
|
AuthorID = original.Metadata.Author.OnlineID,
|
||||||
RulesetID = beatmap.Ruleset.OnlineID,
|
RulesetID = original.Ruleset.OnlineID,
|
||||||
StarRating = beatmap.StarRating,
|
StarRating = original.StarRating,
|
||||||
DifficultyName = beatmap.DifficultyName,
|
DifficultyName = original.DifficultyName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user