2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
|
2018-06-08 11:41:54 +09:00
|
|
|
|
using System;
|
2017-05-28 02:26:25 -03:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Newtonsoft.Json;
|
2017-07-26 13:22:46 +09:00
|
|
|
|
using osu.Game.Beatmaps;
|
2021-10-21 18:54:21 +09:00
|
|
|
|
using osu.Game.Database;
|
2021-11-16 14:13:47 +09:00
|
|
|
|
using osu.Game.Extensions;
|
2021-11-22 15:52:55 +09:00
|
|
|
|
using osu.Game.Models;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-06-08 11:41:54 +09:00
|
|
|
|
namespace osu.Game.Online.API.Requests.Responses
|
2017-05-28 02:26:25 -03:00
|
|
|
|
{
|
2021-10-21 21:32:07 +09:00
|
|
|
|
public class APIBeatmapSet : IBeatmapSetOnlineInfo, IBeatmapSetInfo
|
2017-05-28 02:26:25 -03:00
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"covers")]
|
2021-10-21 19:34:01 +09:00
|
|
|
|
public BeatmapSetOnlineCovers Covers { get; set; }
|
2018-06-08 12:46:34 +09:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"id")]
|
2021-10-21 18:54:21 +09:00
|
|
|
|
public int OnlineID { get; set; }
|
2018-06-08 12:46:34 +09:00
|
|
|
|
|
2018-09-13 11:57:33 +02:00
|
|
|
|
[JsonProperty(@"status")]
|
2021-11-24 18:42:47 +09:00
|
|
|
|
public BeatmapOnlineStatus Status { get; set; }
|
2018-09-13 11:57:33 +02:00
|
|
|
|
|
2017-11-15 13:15:20 +09:00
|
|
|
|
[JsonProperty(@"preview_url")]
|
2021-10-21 18:54:21 +09:00
|
|
|
|
public string Preview { get; set; } = string.Empty;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-07-21 21:41:07 +03:00
|
|
|
|
[JsonProperty(@"has_favourited")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public bool HasFavourited { get; set; }
|
2019-07-21 21:41:07 +03:00
|
|
|
|
|
2017-05-28 02:26:25 -03:00
|
|
|
|
[JsonProperty(@"play_count")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public int PlayCount { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-05-28 02:26:25 -03:00
|
|
|
|
[JsonProperty(@"favourite_count")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public int FavouriteCount { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-11-10 03:01:11 +03:00
|
|
|
|
[JsonProperty(@"bpm")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public double BPM { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-01-12 18:13:05 +03:00
|
|
|
|
[JsonProperty(@"nsfw")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public bool HasExplicitContent { get; set; }
|
2021-01-12 18:13:05 +03:00
|
|
|
|
|
2022-05-14 19:46:13 +03:00
|
|
|
|
[JsonProperty(@"spotlight")]
|
|
|
|
|
public bool FeaturedInSpotlight { get; set; }
|
|
|
|
|
|
2017-11-10 03:01:11 +03:00
|
|
|
|
[JsonProperty(@"video")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public bool HasVideo { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-05-31 08:09:19 -07:00
|
|
|
|
[JsonProperty(@"storyboard")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public bool HasStoryboard { get; set; }
|
2018-05-31 08:09:19 -07:00
|
|
|
|
|
2017-11-10 03:01:11 +03:00
|
|
|
|
[JsonProperty(@"submitted_date")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public DateTimeOffset Submitted { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-11-10 03:01:11 +03:00
|
|
|
|
[JsonProperty(@"ranked_date")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public DateTimeOffset? Ranked { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-11-10 03:01:11 +03:00
|
|
|
|
[JsonProperty(@"last_updated")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public DateTimeOffset? LastUpdated { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-10-25 14:44:49 +09:00
|
|
|
|
[JsonProperty("ratings")]
|
|
|
|
|
public int[] Ratings { get; set; } = Array.Empty<int>();
|
2019-06-13 16:52:49 +09:00
|
|
|
|
|
2021-09-08 12:21:24 +09:00
|
|
|
|
[JsonProperty(@"track_id")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public int? TrackId { get; set; }
|
2021-09-08 12:21:24 +09:00
|
|
|
|
|
2021-10-17 20:55:06 +02:00
|
|
|
|
[JsonProperty(@"hype")]
|
|
|
|
|
public BeatmapSetHypeStatus? HypeStatus { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"nominations_summary")]
|
|
|
|
|
public BeatmapSetNominationStatus? NominationStatus { get; set; }
|
|
|
|
|
|
2021-10-21 21:32:07 +09: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;
|
|
|
|
|
|
2021-11-04 18:22:21 +09:00
|
|
|
|
public APIUser Author = new APIUser();
|
2021-10-21 21:32:07 +09:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-11-04 18:02:44 +09:00
|
|
|
|
/// Helper property to deserialize a username to <see cref="APIUser"/>.
|
2021-10-21 21:32:07 +09:00
|
|
|
|
/// </summary>
|
2017-09-25 23:34:56 +08:00
|
|
|
|
[JsonProperty(@"user_id")]
|
2021-10-21 21:32:07 +09:00
|
|
|
|
public int AuthorID
|
|
|
|
|
{
|
2021-11-04 18:22:21 +09:00
|
|
|
|
get => Author.Id;
|
|
|
|
|
set => Author.Id = value;
|
2021-10-21 21:32:07 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-11-04 18:02:44 +09:00
|
|
|
|
/// Helper property to deserialize a username to <see cref="APIUser"/>.
|
2021-10-21 21:32:07 +09:00
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonProperty(@"creator")]
|
|
|
|
|
public string AuthorString
|
2018-06-08 12:04:33 +09:00
|
|
|
|
{
|
2021-11-04 18:22:21 +09:00
|
|
|
|
get => Author.Username;
|
|
|
|
|
set => Author.Username = value;
|
2017-10-13 20:25:27 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-06-10 13:18:38 +03:00
|
|
|
|
[JsonProperty(@"availability")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public BeatmapSetOnlineAvailability Availability { get; set; }
|
2019-06-10 13:18:38 +03:00
|
|
|
|
|
2019-08-29 12:29:31 +03:00
|
|
|
|
[JsonProperty(@"genre")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public BeatmapSetOnlineGenre Genre { get; set; }
|
2019-07-11 16:44:48 +03:00
|
|
|
|
|
2019-08-29 12:29:31 +03:00
|
|
|
|
[JsonProperty(@"language")]
|
2021-10-20 18:43:48 +09:00
|
|
|
|
public BeatmapSetOnlineLanguage Language { get; set; }
|
2019-07-11 16:44:48 +03:00
|
|
|
|
|
2022-12-29 21:17:24 -08:00
|
|
|
|
[JsonProperty(@"current_nominations")]
|
2023-01-07 11:04:42 -08:00
|
|
|
|
public BeatmapSetOnlineNomination[]? CurrentNominations { get; set; }
|
2022-12-29 21:17:24 -08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"related_users")]
|
2023-01-07 11:04:42 -08:00
|
|
|
|
public APIUser[]? RelatedUsers { get; set; }
|
2022-12-29 21:17:24 -08:00
|
|
|
|
|
2021-10-21 21:32:07 +09:00
|
|
|
|
public string Source { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"tags")]
|
|
|
|
|
public string Tags { get; set; } = string.Empty;
|
|
|
|
|
|
2017-05-28 02:26:25 -03:00
|
|
|
|
[JsonProperty(@"beatmaps")]
|
2021-11-04 16:44:05 +09:00
|
|
|
|
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2023-01-13 16:08:34 -08:00
|
|
|
|
[JsonProperty(@"converts")]
|
2023-01-15 12:46:41 -08:00
|
|
|
|
public APIBeatmap[]? Converts { get; set; }
|
2023-01-13 16:08:34 -08:00
|
|
|
|
|
2021-10-21 21:32:07 +09:00
|
|
|
|
private BeatmapMetadata metadata => new BeatmapMetadata
|
|
|
|
|
{
|
|
|
|
|
Title = Title,
|
|
|
|
|
TitleUnicode = TitleUnicode,
|
|
|
|
|
Artist = Artist,
|
|
|
|
|
ArtistUnicode = ArtistUnicode,
|
2021-11-22 15:52:55 +09:00
|
|
|
|
Author = new RealmUser
|
|
|
|
|
{
|
|
|
|
|
OnlineID = Author.OnlineID,
|
|
|
|
|
Username = Author.Username
|
|
|
|
|
},
|
2021-10-21 21:32:07 +09:00
|
|
|
|
Source = Source,
|
|
|
|
|
Tags = Tags,
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-21 18:54:21 +09:00
|
|
|
|
#region Implementation of IBeatmapSetInfo
|
|
|
|
|
|
2021-10-25 13:47:12 +09:00
|
|
|
|
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
2021-10-21 18:54:21 +09:00
|
|
|
|
|
2021-10-21 21:32:07 +09:00
|
|
|
|
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => metadata;
|
2021-10-21 18:54:21 +09:00
|
|
|
|
|
|
|
|
|
DateTimeOffset IBeatmapSetInfo.DateAdded => throw new NotImplementedException();
|
2021-11-25 16:35:42 +09:00
|
|
|
|
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => throw new NotImplementedException();
|
2021-10-21 18:54:21 +09:00
|
|
|
|
double IBeatmapSetInfo.MaxStarDifficulty => throw new NotImplementedException();
|
|
|
|
|
double IBeatmapSetInfo.MaxLength => throw new NotImplementedException();
|
2021-10-27 17:09:51 +09:00
|
|
|
|
double IBeatmapSetInfo.MaxBPM => BPM;
|
2021-10-21 18:54:21 +09:00
|
|
|
|
|
|
|
|
|
#endregion
|
2021-11-16 12:25:37 +09:00
|
|
|
|
|
2021-11-16 14:13:47 +09:00
|
|
|
|
public bool Equals(IBeatmapSetInfo? other) => other is APIBeatmapSet b && this.MatchesOnlineID(b);
|
2022-11-04 03:20:14 +03:00
|
|
|
|
|
|
|
|
|
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
|
|
|
|
public override int GetHashCode() => OnlineID.GetHashCode();
|
2017-05-28 02:26:25 -03:00
|
|
|
|
}
|
|
|
|
|
}
|