2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-08 10:41:54 +08:00
|
|
|
|
using System;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2021-10-21 17:54:21 +08:00
|
|
|
|
using osu.Game.Database;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2021-10-21 20:32:07 +08:00
|
|
|
|
using osu.Game.Users;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-21 17:54:21 +08:00
|
|
|
|
#nullable enable
|
|
|
|
|
|
2018-06-08 10:41:54 +08:00
|
|
|
|
namespace osu.Game.Online.API.Requests.Responses
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-21 20:32:07 +08:00
|
|
|
|
public class APIBeatmapSet : IBeatmapSetOnlineInfo, IBeatmapSetInfo
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"covers")]
|
2021-10-21 18:34:01 +08:00
|
|
|
|
public BeatmapSetOnlineCovers Covers { get; set; }
|
2018-06-08 11:46:34 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"id")]
|
2021-10-21 17:54:21 +08:00
|
|
|
|
public int OnlineID { get; set; }
|
2018-06-08 11:46:34 +08:00
|
|
|
|
|
2018-09-13 17:57:33 +08:00
|
|
|
|
[JsonProperty(@"status")]
|
|
|
|
|
public BeatmapSetOnlineStatus Status { get; set; }
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"preview_url")]
|
2021-10-21 17:54:21 +08:00
|
|
|
|
public string Preview { get; set; } = string.Empty;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-07-22 02:41:07 +08:00
|
|
|
|
[JsonProperty(@"has_favourited")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public bool HasFavourited { get; set; }
|
2019-07-22 02:41:07 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"play_count")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public int PlayCount { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"favourite_count")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public int FavouriteCount { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"bpm")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public double BPM { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-01-12 23:13:05 +08:00
|
|
|
|
[JsonProperty(@"nsfw")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public bool HasExplicitContent { get; set; }
|
2021-01-12 23:13:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"video")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public bool HasVideo { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-05-31 23:09:19 +08:00
|
|
|
|
[JsonProperty(@"storyboard")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public bool HasStoryboard { get; set; }
|
2018-05-31 23:09:19 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"submitted_date")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public DateTimeOffset Submitted { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"ranked_date")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public DateTimeOffset? Ranked { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"last_updated")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public DateTimeOffset? LastUpdated { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-25 13:44:49 +08:00
|
|
|
|
[JsonProperty("ratings")]
|
|
|
|
|
public int[] Ratings { get; set; } = Array.Empty<int>();
|
2019-06-13 15:52:49 +08:00
|
|
|
|
|
2021-09-08 11:21:24 +08:00
|
|
|
|
[JsonProperty(@"track_id")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public int? TrackId { get; set; }
|
2021-09-08 11:21:24 +08:00
|
|
|
|
|
2021-10-21 20:32:07 +08:00
|
|
|
|
public string Title { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[JsonProperty("title_unicode")]
|
|
|
|
|
public string TitleUnicode { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public string Artist { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[JsonProperty("artist_unicode")]
|
|
|
|
|
public string ArtistUnicode { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public User? Author = new User();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Helper property to deserialize a username to <see cref="User"/>.
|
|
|
|
|
/// </summary>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"user_id")]
|
2021-10-21 20:32:07 +08:00
|
|
|
|
public int AuthorID
|
|
|
|
|
{
|
|
|
|
|
get => Author?.Id ?? 1;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Author ??= new User();
|
|
|
|
|
Author.Id = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Helper property to deserialize a username to <see cref="User"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty(@"creator")]
|
|
|
|
|
public string AuthorString
|
2018-06-08 11:04:33 +08:00
|
|
|
|
{
|
2021-10-21 20:32:07 +08:00
|
|
|
|
get => Author?.Username ?? string.Empty;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Author ??= new User();
|
|
|
|
|
Author.Username = value;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-10 18:18:38 +08:00
|
|
|
|
[JsonProperty(@"availability")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public BeatmapSetOnlineAvailability Availability { get; set; }
|
2019-06-10 18:18:38 +08:00
|
|
|
|
|
2019-08-29 17:29:31 +08:00
|
|
|
|
[JsonProperty(@"genre")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public BeatmapSetOnlineGenre Genre { get; set; }
|
2019-07-11 21:44:48 +08:00
|
|
|
|
|
2019-08-29 17:29:31 +08:00
|
|
|
|
[JsonProperty(@"language")]
|
2021-10-20 17:43:48 +08:00
|
|
|
|
public BeatmapSetOnlineLanguage Language { get; set; }
|
2019-07-11 21:44:48 +08:00
|
|
|
|
|
2021-10-21 20:32:07 +08:00
|
|
|
|
public string Source { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"tags")]
|
|
|
|
|
public string Tags { get; set; } = string.Empty;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"beatmaps")]
|
2021-10-25 12:47:12 +08:00
|
|
|
|
public IEnumerable<APIBeatmap> Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-01-26 04:41:05 +08:00
|
|
|
|
public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-12-21 16:11:30 +08:00
|
|
|
|
var beatmapSet = new BeatmapSetInfo
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-21 17:54:21 +08:00
|
|
|
|
OnlineBeatmapSetID = OnlineID,
|
2021-10-21 20:32:07 +08:00
|
|
|
|
Metadata = metadata,
|
2018-09-13 17:57:33 +08:00
|
|
|
|
Status = Status,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
2020-12-21 16:11:30 +08:00
|
|
|
|
|
2021-10-25 12:47:12 +08:00
|
|
|
|
beatmapSet.Beatmaps = Beatmaps.Select(b =>
|
2020-12-21 16:11:30 +08:00
|
|
|
|
{
|
2021-10-02 23:55:29 +08:00
|
|
|
|
var beatmap = b.ToBeatmapInfo(rulesets);
|
2020-12-21 16:11:30 +08:00
|
|
|
|
beatmap.BeatmapSet = beatmapSet;
|
|
|
|
|
beatmap.Metadata = beatmapSet.Metadata;
|
|
|
|
|
return beatmap;
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return beatmapSet;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2021-10-21 17:54:21 +08:00
|
|
|
|
|
2021-10-21 20:32:07 +08:00
|
|
|
|
private BeatmapMetadata metadata => new BeatmapMetadata
|
|
|
|
|
{
|
|
|
|
|
Title = Title,
|
|
|
|
|
TitleUnicode = TitleUnicode,
|
|
|
|
|
Artist = Artist,
|
|
|
|
|
ArtistUnicode = ArtistUnicode,
|
|
|
|
|
AuthorID = AuthorID,
|
|
|
|
|
Author = Author,
|
|
|
|
|
Source = Source,
|
|
|
|
|
Tags = Tags,
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-21 17:54:21 +08:00
|
|
|
|
#region Implementation of IBeatmapSetInfo
|
|
|
|
|
|
2021-10-25 12:47:12 +08:00
|
|
|
|
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
2021-10-21 17:54:21 +08:00
|
|
|
|
|
2021-10-21 20:32:07 +08:00
|
|
|
|
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => metadata;
|
2021-10-21 17:54:21 +08:00
|
|
|
|
|
|
|
|
|
DateTimeOffset IBeatmapSetInfo.DateAdded => throw new NotImplementedException();
|
|
|
|
|
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => throw new NotImplementedException();
|
|
|
|
|
double IBeatmapSetInfo.MaxStarDifficulty => throw new NotImplementedException();
|
|
|
|
|
double IBeatmapSetInfo.MaxLength => throw new NotImplementedException();
|
2021-10-27 16:09:51 +08:00
|
|
|
|
double IBeatmapSetInfo.MaxBPM => BPM;
|
2021-10-21 17:54:21 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|