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

121 lines
3.7 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;
2018-04-13 17:19:50 +08:00
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Database;
2018-04-13 17:19:50 +08:00
using osu.Game.Rulesets;
#nullable enable
namespace osu.Game.Online.API.Requests.Responses
2018-04-13 17:19:50 +08:00
{
public class APIBeatmapSet : BeatmapMetadata, 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; }
[JsonProperty(@"id")]
public int OnlineID { get; set; }
[JsonProperty(@"status")]
public BeatmapSetOnlineStatus Status { get; set; }
2018-04-13 17:19:50 +08:00
[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
2018-04-13 17:19:50 +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
[JsonProperty(@"bpm")]
public double BPM { get; set; }
2018-04-13 17:19:50 +08:00
[JsonProperty(@"nsfw")]
public bool HasExplicitContent { get; set; }
2018-04-13 17:19:50 +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
2018-04-13 17:19:50 +08:00
[JsonProperty(@"submitted_date")]
public DateTimeOffset Submitted { get; set; }
2018-04-13 17:19:50 +08:00
[JsonProperty(@"ranked_date")]
public DateTimeOffset? Ranked { get; set; }
2018-04-13 17:19:50 +08:00
[JsonProperty(@"last_updated")]
public DateTimeOffset? LastUpdated { get; set; }
2018-04-13 17:19:50 +08:00
2019-06-13 15:52:49 +08:00
[JsonProperty(@"ratings")]
private int[] ratings { get; set; } = Array.Empty<int>();
2019-06-13 15:52:49 +08:00
[JsonProperty(@"track_id")]
public int? TrackId { get; set; }
2018-04-13 17:19:50 +08:00
[JsonProperty(@"user_id")]
private int creatorId
2018-06-08 11:04:33 +08:00
{
set => Author.Id = 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; }
2018-04-13 17:19:50 +08:00
[JsonProperty(@"beatmaps")]
private IEnumerable<APIBeatmap> beatmaps { get; set; } = Array.Empty<APIBeatmap>();
2018-04-13 17:19:50 +08:00
public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
2018-04-13 17:19:50 +08:00
{
var beatmapSet = new BeatmapSetInfo
2018-04-13 17:19:50 +08:00
{
OnlineBeatmapSetID = OnlineID,
2018-04-13 17:19:50 +08:00
Metadata = this,
Status = Status,
Metrics = new BeatmapSetMetrics { Ratings = ratings },
OnlineInfo = this
2018-04-13 17:19:50 +08:00
};
beatmapSet.Beatmaps = beatmaps.Select(b =>
{
2021-10-02 23:55:29 +08:00
var beatmap = b.ToBeatmapInfo(rulesets);
beatmap.BeatmapSet = beatmapSet;
beatmap.Metadata = beatmapSet.Metadata;
return beatmap;
}).ToList();
return beatmapSet;
2018-04-13 17:19:50 +08:00
}
#region Implementation of IBeatmapSetInfo
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => beatmaps;
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => this;
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();
double IBeatmapSetInfo.MaxBPM => throw new NotImplementedException();
#endregion
2018-04-13 17:19:50 +08:00
}
}