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-06-08 11:04:33 +08:00
|
|
|
|
|
2019-07-09 22:53:34 +08:00
|
|
|
|
using System;
|
2018-06-08 11:04:33 +08:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2021-11-16 13:13:47 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2018-06-08 11:04:33 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Online.API.Requests.Responses
|
|
|
|
|
{
|
2021-10-25 13:44:49 +08:00
|
|
|
|
public class APIBeatmap : IBeatmapInfo, IBeatmapOnlineInfo
|
2018-06-08 11:04:33 +08:00
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"id")]
|
2021-10-21 18:14:31 +08:00
|
|
|
|
public int OnlineID { get; set; }
|
2018-06-08 11:46:34 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"beatmapset_id")]
|
|
|
|
|
public int OnlineBeatmapSetID { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
2018-09-13 17:57:33 +08:00
|
|
|
|
[JsonProperty(@"status")]
|
2021-11-24 17:42:47 +08:00
|
|
|
|
public BeatmapOnlineStatus Status { get; set; }
|
2018-09-13 17:57:33 +08:00
|
|
|
|
|
2021-10-21 15:43:46 +08:00
|
|
|
|
[JsonProperty("checksum")]
|
2021-10-21 18:14:31 +08:00
|
|
|
|
public string Checksum { get; set; } = string.Empty;
|
2021-10-21 15:43:46 +08:00
|
|
|
|
|
2021-10-21 20:48:14 +08:00
|
|
|
|
[JsonProperty(@"user_id")]
|
|
|
|
|
public int AuthorID { get; set; }
|
|
|
|
|
|
2018-09-13 17:57:33 +08:00
|
|
|
|
[JsonProperty(@"beatmapset")]
|
2021-10-21 18:14:31 +08:00
|
|
|
|
public APIBeatmapSet? BeatmapSet { get; set; }
|
2018-09-13 17:57:33 +08:00
|
|
|
|
|
2018-06-08 11:04:33 +08:00
|
|
|
|
[JsonProperty(@"playcount")]
|
2021-10-25 14:12:11 +08:00
|
|
|
|
public int PlayCount { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"passcount")]
|
2021-10-25 14:12:11 +08:00
|
|
|
|
public int PassCount { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"mode_int")]
|
2021-10-21 18:14:31 +08:00
|
|
|
|
public int RulesetID { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"difficulty_rating")]
|
2021-10-21 18:14:31 +08:00
|
|
|
|
public double StarRating { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"drain")]
|
2021-10-29 16:49:31 +08:00
|
|
|
|
public float DrainRate { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"cs")]
|
2021-10-29 16:49:31 +08:00
|
|
|
|
public float CircleSize { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"ar")]
|
2021-10-29 16:49:31 +08:00
|
|
|
|
public float ApproachRate { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"accuracy")]
|
2021-10-29 16:49:31 +08:00
|
|
|
|
public float OverallDifficulty { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
2021-10-26 11:44:14 +08:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public double Length { get; set; }
|
2021-10-22 14:54:40 +08:00
|
|
|
|
|
2018-06-08 11:04:33 +08:00
|
|
|
|
[JsonProperty(@"total_length")]
|
2021-10-26 11:44:14 +08:00
|
|
|
|
private double lengthInSeconds
|
|
|
|
|
{
|
|
|
|
|
get => TimeSpan.FromMilliseconds(Length).TotalSeconds;
|
|
|
|
|
set => Length = TimeSpan.FromSeconds(value).TotalMilliseconds;
|
|
|
|
|
}
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"count_circles")]
|
2021-10-25 14:12:11 +08:00
|
|
|
|
public int CircleCount { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"count_sliders")]
|
2021-10-25 14:12:11 +08:00
|
|
|
|
public int SliderCount { get; set; }
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
2022-06-27 14:01:53 +08:00
|
|
|
|
[JsonProperty(@"count_spinners")]
|
|
|
|
|
public int SpinnerCount { get; set; }
|
|
|
|
|
|
2018-06-08 11:04:33 +08:00
|
|
|
|
[JsonProperty(@"version")]
|
2021-10-21 18:14:31 +08:00
|
|
|
|
public string DifficultyName { get; set; } = string.Empty;
|
2018-06-08 11:04:33 +08:00
|
|
|
|
|
2019-06-13 15:39:38 +08:00
|
|
|
|
[JsonProperty(@"failtimes")]
|
2021-10-25 14:34:41 +08:00
|
|
|
|
public APIFailTimes? FailTimes { get; set; }
|
2019-06-13 15:39:38 +08:00
|
|
|
|
|
2020-02-20 00:58:41 +08:00
|
|
|
|
[JsonProperty(@"max_combo")]
|
2021-10-25 13:44:49 +08:00
|
|
|
|
public int? MaxCombo { get; set; }
|
2020-02-20 00:58:41 +08:00
|
|
|
|
|
2022-07-19 18:39:51 +08:00
|
|
|
|
[JsonProperty(@"last_updated")]
|
|
|
|
|
public DateTimeOffset LastUpdated { get; set; }
|
|
|
|
|
|
2021-10-25 15:44:52 +08:00
|
|
|
|
public double BPM { get; set; }
|
|
|
|
|
|
2021-10-21 18:14:31 +08:00
|
|
|
|
#region Implementation of IBeatmapInfo
|
|
|
|
|
|
2021-10-22 14:00:31 +08:00
|
|
|
|
public IBeatmapMetadataInfo Metadata => (BeatmapSet as IBeatmapSetInfo)?.Metadata ?? new BeatmapMetadata();
|
2021-10-21 18:14:31 +08:00
|
|
|
|
|
|
|
|
|
public IBeatmapDifficultyInfo Difficulty => new BeatmapDifficulty
|
|
|
|
|
{
|
2021-10-29 16:49:31 +08:00
|
|
|
|
DrainRate = DrainRate,
|
|
|
|
|
CircleSize = CircleSize,
|
|
|
|
|
ApproachRate = ApproachRate,
|
|
|
|
|
OverallDifficulty = OverallDifficulty,
|
2021-10-21 18:14:31 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IBeatmapSetInfo? IBeatmapInfo.BeatmapSet => BeatmapSet;
|
|
|
|
|
|
|
|
|
|
public string MD5Hash => Checksum;
|
|
|
|
|
|
2022-02-11 13:02:51 +08:00
|
|
|
|
public IRulesetInfo Ruleset => new APIRuleset { OnlineID = RulesetID };
|
2021-10-21 18:14:31 +08:00
|
|
|
|
|
2021-10-25 15:44:52 +08:00
|
|
|
|
[JsonIgnore]
|
2021-10-21 18:14:31 +08:00
|
|
|
|
public string Hash => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
#endregion
|
2021-11-16 11:25:37 +08:00
|
|
|
|
|
2021-11-16 13:13:47 +08:00
|
|
|
|
public bool Equals(IBeatmapInfo? other) => other is APIBeatmap b && this.MatchesOnlineID(b);
|
2022-02-11 13:02:51 +08:00
|
|
|
|
|
2022-09-15 15:39:59 +08:00
|
|
|
|
public class APIRuleset : IRulesetInfo
|
2022-02-11 13:02:51 +08:00
|
|
|
|
{
|
|
|
|
|
public int OnlineID { get; set; } = -1;
|
|
|
|
|
|
|
|
|
|
public string Name => $@"{nameof(APIRuleset)} (ID: {OnlineID})";
|
2022-02-17 20:04:59 +08:00
|
|
|
|
|
|
|
|
|
public string ShortName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// TODO: this should really not exist.
|
|
|
|
|
switch (OnlineID)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "osu";
|
|
|
|
|
|
|
|
|
|
case 1: return "taiko";
|
|
|
|
|
|
2022-02-17 20:12:51 +08:00
|
|
|
|
case 2: return "fruits";
|
2022-02-17 20:04:59 +08:00
|
|
|
|
|
2022-02-17 20:12:51 +08:00
|
|
|
|
case 3: return "mania";
|
2022-02-17 20:04:59 +08:00
|
|
|
|
|
|
|
|
|
default: throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-11 13:02:51 +08:00
|
|
|
|
public string InstantiationInfo => string.Empty;
|
|
|
|
|
|
|
|
|
|
public Ruleset CreateInstance() => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
public bool Equals(IRulesetInfo? other) => other is APIRuleset r && this.MatchesOnlineID(r);
|
|
|
|
|
|
|
|
|
|
public int CompareTo(IRulesetInfo other)
|
|
|
|
|
{
|
|
|
|
|
if (!(other is APIRuleset ruleset))
|
|
|
|
|
throw new ArgumentException($@"Object is not of type {nameof(APIRuleset)}.", nameof(other));
|
|
|
|
|
|
|
|
|
|
return OnlineID.CompareTo(ruleset.OnlineID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
|
|
|
|
public override int GetHashCode() => OnlineID;
|
|
|
|
|
}
|
2018-06-08 11:04:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|