mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 04:53:06 +08:00
Move out APIBeatmap
This commit is contained in:
parent
8cc31aca54
commit
1716975a37
78
osu.Game/Online/API/Requests/Responses/APIBeatmap.cs
Normal file
78
osu.Game/Online/API/Requests/Responses/APIBeatmap.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests.Responses
|
||||||
|
{
|
||||||
|
public class APIBeatmap : BeatmapMetadata
|
||||||
|
{
|
||||||
|
[JsonProperty(@"id")]
|
||||||
|
private int onlineBeatmapID { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"playcount")]
|
||||||
|
private int playCount { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"passcount")]
|
||||||
|
private int passCount { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"mode_int")]
|
||||||
|
private int ruleset { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"difficulty_rating")]
|
||||||
|
private double starDifficulty { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"drain")]
|
||||||
|
private float drainRate { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"cs")]
|
||||||
|
private float circleSize { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"ar")]
|
||||||
|
private float approachRate { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"accuracy")]
|
||||||
|
private float overallDifficulty { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"total_length")]
|
||||||
|
private double length { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"count_circles")]
|
||||||
|
private int circleCount { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"count_sliders")]
|
||||||
|
private int sliderCount { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"version")]
|
||||||
|
private string version { get; set; }
|
||||||
|
|
||||||
|
public BeatmapInfo ToBeatmap(RulesetStore rulesets)
|
||||||
|
{
|
||||||
|
return new BeatmapInfo
|
||||||
|
{
|
||||||
|
Metadata = this,
|
||||||
|
Ruleset = rulesets.GetRuleset(ruleset),
|
||||||
|
StarDifficulty = starDifficulty,
|
||||||
|
OnlineBeatmapID = onlineBeatmapID,
|
||||||
|
Version = version,
|
||||||
|
BaseDifficulty = new BeatmapDifficulty
|
||||||
|
{
|
||||||
|
DrainRate = drainRate,
|
||||||
|
CircleSize = circleSize,
|
||||||
|
ApproachRate = approachRate,
|
||||||
|
OverallDifficulty = overallDifficulty,
|
||||||
|
},
|
||||||
|
OnlineInfo = new BeatmapOnlineInfo
|
||||||
|
{
|
||||||
|
PlayCount = playCount,
|
||||||
|
PassCount = passCount,
|
||||||
|
Length = length,
|
||||||
|
CircleCount = circleCount,
|
||||||
|
SliderCount = sliderCount,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -46,12 +46,13 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
private DateTimeOffset lastUpdated { get; set; }
|
private DateTimeOffset lastUpdated { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"user_id")]
|
[JsonProperty(@"user_id")]
|
||||||
private long creatorId {
|
private long creatorId
|
||||||
|
{
|
||||||
set { Author.Id = value; }
|
set { Author.Id = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty(@"beatmaps")]
|
[JsonProperty(@"beatmaps")]
|
||||||
private IEnumerable<APIResponseBeatmap> beatmaps { get; set; }
|
private IEnumerable<APIBeatmap> beatmaps { get; set; }
|
||||||
|
|
||||||
public BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
|
public BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
@ -76,74 +77,5 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
Beatmaps = beatmaps?.Select(b => b.ToBeatmap(rulesets)).ToList(),
|
Beatmaps = beatmaps?.Select(b => b.ToBeatmap(rulesets)).ToList(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class APIResponseBeatmap : BeatmapMetadata
|
|
||||||
{
|
|
||||||
[JsonProperty(@"id")]
|
|
||||||
private int onlineBeatmapID { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"playcount")]
|
|
||||||
private int playCount { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"passcount")]
|
|
||||||
private int passCount { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"mode_int")]
|
|
||||||
private int ruleset { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"difficulty_rating")]
|
|
||||||
private double starDifficulty { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"drain")]
|
|
||||||
private float drainRate { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"cs")]
|
|
||||||
private float circleSize { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"ar")]
|
|
||||||
private float approachRate { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"accuracy")]
|
|
||||||
private float overallDifficulty { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"total_length")]
|
|
||||||
private double length { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"count_circles")]
|
|
||||||
private int circleCount { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"count_sliders")]
|
|
||||||
private int sliderCount { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty(@"version")]
|
|
||||||
private string version { get; set; }
|
|
||||||
|
|
||||||
public BeatmapInfo ToBeatmap(RulesetStore rulesets)
|
|
||||||
{
|
|
||||||
return new BeatmapInfo
|
|
||||||
{
|
|
||||||
Metadata = this,
|
|
||||||
Ruleset = rulesets.GetRuleset(ruleset),
|
|
||||||
StarDifficulty = starDifficulty,
|
|
||||||
OnlineBeatmapID = onlineBeatmapID,
|
|
||||||
Version = version,
|
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
|
||||||
{
|
|
||||||
DrainRate = drainRate,
|
|
||||||
CircleSize = circleSize,
|
|
||||||
ApproachRate = approachRate,
|
|
||||||
OverallDifficulty = overallDifficulty,
|
|
||||||
},
|
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
|
||||||
{
|
|
||||||
PlayCount = playCount,
|
|
||||||
PassCount = passCount,
|
|
||||||
Length = length,
|
|
||||||
CircleCount = circleCount,
|
|
||||||
SliderCount = sliderCount,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user