1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 19:27:24 +08:00
osu-lazer/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs
2021-10-21 16:58:42 +09:00

110 lines
3.2 KiB
C#

// 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.
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIBeatmapSet : BeatmapMetadata, IBeatmapSetOnlineInfo
{
[JsonProperty(@"covers")]
public BeatmapSetOnlineCovers Covers { get; set; }
private int? onlineBeatmapSetID;
[JsonProperty(@"id")]
public int? OnlineBeatmapSetID
{
get => onlineBeatmapSetID;
set => onlineBeatmapSetID = value > 0 ? value : null;
}
[JsonProperty(@"status")]
public BeatmapSetOnlineStatus Status { get; set; }
[JsonProperty(@"preview_url")]
public string Preview { get; set; }
[JsonProperty(@"has_favourited")]
public bool HasFavourited { get; set; }
[JsonProperty(@"play_count")]
public int PlayCount { get; set; }
[JsonProperty(@"favourite_count")]
public int FavouriteCount { get; set; }
[JsonProperty(@"bpm")]
public double BPM { get; set; }
[JsonProperty(@"nsfw")]
public bool HasExplicitContent { get; set; }
[JsonProperty(@"video")]
public bool HasVideo { get; set; }
[JsonProperty(@"storyboard")]
public bool HasStoryboard { get; set; }
[JsonProperty(@"submitted_date")]
public DateTimeOffset Submitted { get; set; }
[JsonProperty(@"ranked_date")]
public DateTimeOffset? Ranked { get; set; }
[JsonProperty(@"last_updated")]
public DateTimeOffset? LastUpdated { get; set; }
[JsonProperty(@"ratings")]
private int[] ratings { get; set; }
[JsonProperty(@"track_id")]
public int? TrackId { get; set; }
[JsonProperty(@"user_id")]
private int creatorId
{
set => Author.Id = value;
}
[JsonProperty(@"availability")]
public BeatmapSetOnlineAvailability Availability { get; set; }
[JsonProperty(@"genre")]
public BeatmapSetOnlineGenre Genre { get; set; }
[JsonProperty(@"language")]
public BeatmapSetOnlineLanguage Language { get; set; }
[JsonProperty(@"beatmaps")]
private IEnumerable<APIBeatmap> beatmaps { get; set; }
public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
{
var beatmapSet = new BeatmapSetInfo
{
OnlineBeatmapSetID = OnlineBeatmapSetID,
Metadata = this,
Status = Status,
Metrics = ratings == null ? null : new BeatmapSetMetrics { Ratings = ratings },
OnlineInfo = this
};
beatmapSet.Beatmaps = beatmaps?.Select(b =>
{
var beatmap = b.ToBeatmapInfo(rulesets);
beatmap.BeatmapSet = beatmapSet;
beatmap.Metadata = beatmapSet.Metadata;
return beatmap;
}).ToList();
return beatmapSet;
}
}
}