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-12-14 18:52:03 +08:00
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Newtonsoft.Json;
|
2020-12-18 13:58:58 +08:00
|
|
|
using NUnit.Framework;
|
2018-12-14 18:52:03 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Screens.Multi.Match.Components;
|
|
|
|
using osu.Game.Users;
|
|
|
|
using osuTK;
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2018-12-14 18:52:03 +08:00
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
public class TestSceneMatchLeaderboard : MultiplayerTestScene
|
2018-12-14 18:52:03 +08:00
|
|
|
{
|
2019-09-13 16:15:33 +08:00
|
|
|
protected override bool UseOnlineAPI => true;
|
2019-08-01 03:44:44 +08:00
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
public TestSceneMatchLeaderboard()
|
2018-12-14 18:52:03 +08:00
|
|
|
{
|
2019-01-08 18:24:55 +08:00
|
|
|
Add(new MatchLeaderboard
|
2018-12-14 18:52:03 +08:00
|
|
|
{
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Size = new Vector2(550f, 450f),
|
|
|
|
Scope = MatchLeaderboardScope.Overall,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-08-01 03:44:44 +08:00
|
|
|
private void load(IAPIProvider api)
|
2018-12-14 18:52:03 +08:00
|
|
|
{
|
|
|
|
var req = new GetRoomScoresRequest();
|
|
|
|
req.Success += v => { };
|
|
|
|
req.Failure += _ => { };
|
|
|
|
|
|
|
|
api.Queue(req);
|
|
|
|
}
|
|
|
|
|
2020-12-18 13:58:58 +08:00
|
|
|
[SetUp]
|
|
|
|
public new void Setup() => Schedule(() =>
|
|
|
|
{
|
|
|
|
Room.RoomID.Value = 3;
|
|
|
|
});
|
|
|
|
|
2018-12-14 18:52:03 +08:00
|
|
|
private class GetRoomScoresRequest : APIRequest<List<RoomScore>>
|
|
|
|
{
|
|
|
|
protected override string Target => "rooms/3/leaderboard";
|
|
|
|
}
|
|
|
|
|
|
|
|
private class RoomScore
|
|
|
|
{
|
|
|
|
[JsonProperty("user")]
|
|
|
|
public User User { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("accuracy")]
|
|
|
|
public double Accuracy { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("total_score")]
|
|
|
|
public int TotalScore { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("pp")]
|
|
|
|
public double PP { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("attempts")]
|
|
|
|
public int TotalAttempts { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("completed")]
|
|
|
|
public int CompletedAttempts { get; set; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|