1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 09:07:25 +08:00
osu-lazer/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

166 lines
5.2 KiB
C#
Raw Normal View History

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