Beispiel #1
0
        public async Task TestLeaderboard(GameMode mode, LeaderboardType type, uint expectedUser, uint pages = 1)
        {
            OsuUserLeaderboard leaderboard = null;

            do
            {
                leaderboard = await Client.GetLeaderboard(mode, type, last : leaderboard);

                pages--;
            } while (pages > 0);

            Assert.IsTrue(leaderboard.Ranking.Select(x => x.User?.Id).Contains(expectedUser));
        }
        /// <summary>
        /// Get the leaderboard for a specific mode and criteria
        /// </summary>
        /// <param name="client">The <see cref="OrbitClient"/> to use</param>
        /// <param name="mode">The <see cref="GameMode"/> to get rankings for</param>
        /// <param name="type">The <see cref="LeaderboardType"/> to return</param>
        /// <param name="filter">Optional <see cref="LeaderboardFilterMode"/></param>
        /// <param name="country">Optional ISO3166-1 country code to filter users by</param>
        /// <param name="spotlight">Optional spotlight id to return entries for</param>
        /// <param name="variant"><see cref="LeaderboardVariant"/> for osu!mania 4/7 keys</param>
        /// <param name="last">Optional previous response that is used to get the next set</param>
        public static Task <OsuUserLeaderboard> GetLeaderboard(this OrbitClient client, GameMode mode, LeaderboardType type, LeaderboardFilterMode?filter = null, string country = null,
                                                               int?spotlight = null,
                                                               LeaderboardVariant?variant = null, OsuUserLeaderboard last = null)
        {
            if (type == LeaderboardType.Country)
            {
                throw new NotSupportedException($"use {nameof(GetCountryLeaderboard)} instead");
            }

            var request = new OsuLeaderboardRequest(mode, type)
            {
                Filter    = filter,
                Country   = country,
                Spotlight = spotlight,
                Variant   = variant,

                Cursor = last?.Cursor
            };

            return(client.PerformAsync <OsuUserLeaderboard>(request));
        }