mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:03:08 +08:00
separate GetUserBeatmapsRequest and GetUserMostPlayedBeatmapsRequest
This commit is contained in:
parent
02fa1f9dd6
commit
4c68090e59
@ -1,19 +1,18 @@
|
||||
// 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;
|
||||
using Humanizer;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public abstract class GetUserBeatmapsRequest<T> : APIRequest<List<T>>
|
||||
public class GetUserBeatmapsRequest : APIRequest<List<GetBeatmapSetsResponse>>
|
||||
{
|
||||
private readonly long userId;
|
||||
private readonly int offset;
|
||||
private readonly BeatmapSetType type;
|
||||
|
||||
protected GetUserBeatmapsRequest(long userId, BeatmapSetType type, int offset = 0)
|
||||
public GetUserBeatmapsRequest(long userId, BeatmapSetType type, int offset = 0)
|
||||
{
|
||||
this.userId = userId;
|
||||
this.offset = offset;
|
||||
@ -23,19 +22,8 @@ namespace osu.Game.Online.API.Requests
|
||||
protected override string Target => $@"users/{userId}/beatmapsets/{type.ToString().Underscore()}?offset={offset}";
|
||||
}
|
||||
|
||||
public class GetUserBeatmapsRequest : GetUserBeatmapsRequest<GetBeatmapSetsResponse>
|
||||
{
|
||||
public GetUserBeatmapsRequest(long userID, BeatmapSetType type, int offset = 0)
|
||||
: base(userID, type, offset)
|
||||
{
|
||||
if(type == BeatmapSetType.MostPlayed)
|
||||
throw new ArgumentException("Please use " + nameof(GetUserMostPlayedBeatmapsRequest) + " instead");
|
||||
}
|
||||
}
|
||||
|
||||
public enum BeatmapSetType
|
||||
{
|
||||
MostPlayed,
|
||||
Favourite,
|
||||
RankedAndApproved,
|
||||
Unranked,
|
||||
|
@ -1,21 +1,25 @@
|
||||
// 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;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserMostPlayedBeatmapsRequest : GetUserBeatmapsRequest<UserMostPlayedBeatmapsResponse>
|
||||
public class GetUserMostPlayedBeatmapsRequest : APIRequest<List<UserMostPlayedBeatmapsResponse>>
|
||||
{
|
||||
public GetUserMostPlayedBeatmapsRequest(long userID, BeatmapSetType type, int offset = 0)
|
||||
: base(userID, type, offset)
|
||||
private readonly long userId;
|
||||
private readonly int offset;
|
||||
|
||||
public GetUserMostPlayedBeatmapsRequest(long userId, int offset = 0)
|
||||
{
|
||||
if (type != BeatmapSetType.MostPlayed)
|
||||
throw new ArgumentException("Please use " + nameof(GetUserBeatmapsRequest) + " instead");
|
||||
this.userId = userId;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
protected override string Target => $@"users/{userId}/beatmapsets/most_played?offset={offset}";
|
||||
}
|
||||
|
||||
public class UserMostPlayedBeatmapsResponse
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
base.ShowMore();
|
||||
|
||||
var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, BeatmapSetType.MostPlayed, VisiblePages++ * ItemsPerPage);
|
||||
var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
||||
|
||||
req.Success += beatmaps =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user