Add API retrieval support

This commit is contained in:
Dean Herbert
2017-09-14 20:05:43 +09:00
parent 9c4876d135
commit 98b847b025
8 changed files with 131 additions and 13 deletions

View File

@ -7,6 +7,7 @@ using System.Linq;
using Newtonsoft.Json;
using osu.Framework.IO.Network;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Users;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
@ -73,6 +74,9 @@ namespace osu.Game.Online.API.Requests
set { Replay = value; }
}
[JsonProperty(@"mode_int")]
public int OnlineRulesetID { get; set; }
[JsonProperty(@"score_id")]
private long onlineScoreID
{
@ -85,6 +89,18 @@ namespace osu.Game.Online.API.Requests
set { Date = value; }
}
[JsonProperty(@"beatmap")]
private BeatmapInfo beatmap
{
set { Beatmap = value; }
}
[JsonProperty(@"beatmapset")]
private BeatmapMetadata metadata
{
set { Beatmap.Metadata = value; }
}
[JsonProperty(@"statistics")]
private Dictionary<string, dynamic> jsonStats
{
@ -122,7 +138,12 @@ namespace osu.Game.Online.API.Requests
public void ApplyBeatmap(BeatmapInfo beatmap)
{
Beatmap = beatmap;
Ruleset = beatmap.Ruleset;
ApplyRuleset(beatmap.Ruleset);
}
public void ApplyRuleset(RulesetInfo ruleset)
{
Ruleset = ruleset;
// Evaluate the mod string
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();

View File

@ -0,0 +1,28 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
namespace osu.Game.Online.API.Requests
{
public class GetUserScoresRequest : APIRequest<List<OnlineScore>>
{
private readonly long userId;
private readonly ScoreType type;
public GetUserScoresRequest(long userId, ScoreType type)
{
this.userId = userId;
this.type = type;
}
protected override string Target => $@"users/{userId}/scores/{type.ToString().ToLower()}";
}
public enum ScoreType
{
Best,
Firsts,
Recent
}
}