示例#1
0
        public async Task ShowLeaderboard(LeaderboardType type = LeaderboardType.Global)
        {
            if (type == LeaderboardType.Global)
            {
                var top = _leaderboard.GetTopRank(15);
                await ReplyAsync(embed : await FormatLeaderboard(top));
            }
            else if (type == LeaderboardType.Current)
            {
                var challenge = await _challenges.GetCurrentChallenge();

                if (challenge == null)
                {
                    await ReplyAsync("There is no currently running challenge");

                    return;
                }

                await DisplayChallengeLeaderboard(challenge);
            }
            else if (type == LeaderboardType.Trueskill)
            {
                var top = _skills.GetTopRanks(15);
                await ReplyAsync(embed : await FormatLeaderboard(top));
            }
            else
            {
                throw new InvalidOperationException("Unknown leaderboard type");
            }
        }
示例#2
0
        public async Task ShowLeaderboard(LeaderboardType type = LeaderboardType.Global)
        {
            if (type == LeaderboardType.Global)
            {
                var top = _leaderboard.GetTopRank(15);
                await ReplyAsync(embed : await FormatLeaderboard(top));
            }
            else if (type == LeaderboardType.Current)
            {
                var challenge = await _challenges.GetCurrentChallenge();

                if (challenge == null)
                {
                    await ReplyAsync("There is no currently running challenge");

                    return;
                }

                // Get the top N solutions
                var top5 = _solutions.GetSolutions(challenge.Id, 20).Select(a => new RankInfo(a.Solution.UserId, a.Rank, a.Solution.Score));

                // Get your own rank
                var self = await _solutions.GetRank(challenge.Id, Context.User.Id);

                RankInfo?selfRank = null;
                if (self.HasValue)
                {
                    selfRank = new RankInfo(self.Value.Solution.UserId, self.Value.Rank, self.Value.Solution.Score);
                }

                await ReplyAsync(embed : await FormatLeaderboard(top5, selfRank));
            }
            else
            {
                throw new InvalidOperationException("Unknown leaderboard type");
            }
        }