1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 01:03:02 +08:00
osu-lazer/osu.Game/Online/API/Requests/GetBeatmapDetailsRequest.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2017-04-24 18:17:11 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using Newtonsoft.Json;
2017-07-26 12:22:46 +08:00
using osu.Game.Beatmaps;
2017-04-24 18:17:11 +08:00
namespace osu.Game.Online.API.Requests
{
2017-04-30 20:45:23 +08:00
public class GetBeatmapDetailsRequest : APIRequest<GetBeatmapDetailsResponse>
2017-04-24 18:17:11 +08:00
{
private readonly BeatmapInfo beatmap;
2017-09-23 04:47:26 +08:00
private string lookupString => beatmap.OnlineBeatmapID > 0 ? beatmap.OnlineBeatmapID.ToString() : $@"lookup?checksum={beatmap.Hash}&filename={System.Uri.EscapeUriString(beatmap.Path)}";
2017-04-24 18:17:11 +08:00
2017-04-24 18:33:48 +08:00
public GetBeatmapDetailsRequest(BeatmapInfo beatmap)
2017-04-24 18:17:11 +08:00
{
this.beatmap = beatmap;
}
protected override string Target => $@"beatmaps/{lookupString}";
}
2017-04-30 20:45:23 +08:00
public class GetBeatmapDetailsResponse : BeatmapMetrics
2017-04-24 18:17:11 +08:00
{
//the online API returns some metrics as a nested object.
[JsonProperty(@"failtimes")]
private BeatmapMetrics failTimes
{
set
{
2017-04-24 19:16:31 +08:00
Fails = value.Fails;
Retries = value.Retries;
2017-04-24 18:17:11 +08:00
}
}
//and other metrics in the beatmap set.
[JsonProperty(@"beatmapset")]
private BeatmapMetrics beatmapSet
{
set
{
2017-04-24 19:16:31 +08:00
Ratings = value.Ratings;
2017-04-24 18:17:11 +08:00
}
}
}
}