Beispiel #1
0
        private void ValidateRankedInfo(string[] objects)
        {
            bool valid       = true;
            int  arrayLength = objects.Length;
            int  numberOfRankedGames;

            if (!int.TryParse(objects[arrayLength - 1], out numberOfRankedGames))
            {
                valid = false;
            }
            if (numberOfRankedGames > 10)
            {
                valid = false;
            }
            if (!RiotApiService.ValidReigon(objects[arrayLength - 2]))
            {
                valid = false;
            }

            if (!valid)
            {
                throw new ArgumentException("Arguments should be the following:\n1: Summoner Name\n" +
                                            "2: Reigon\n" +
                                            "3: Number of Ranked Games (10 max)");
            }
        }
Beispiel #2
0
        public async Task GetLiveMatchDataAsync(params string[] objects)
        {
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i <= objects.Length - 2; i++)
            {
                stringBuilder.Append(objects[i] + " ");
            }
            string summonerName = stringBuilder.ToString().Substring(0, stringBuilder.ToString().Length - 1);
            string reigon       = objects[objects.Length - 1];

            if (RiotApiService.ValidReigon(reigon) == false)
            {
                throw new ArgumentException("Arguments should be the following:\n1: Summoner Name\n" +
                                            "2: Reigon\n");
            }
            await ReplyAsync("Obtaining summoner info for summoner : " + summonerName + " ...");

            CurrentGameInfo currentGameInfo = await RiotApiService.GetLiveMatchDataAsync(summonerName, reigon);

            var           blueSide          = currentGameInfo.Participants.Where(player => player.TeamId == 100);
            var           redSide           = currentGameInfo.Participants.Where(player => player.TeamId == 200);
            var           summonerIcon      = currentGameInfo.Participants.First(player => player.SummonerName == summonerName).ProfileIconId;
            StringBuilder blueStringBuilder = new StringBuilder();

            foreach (var participant in blueSide)
            {
                blueStringBuilder.AppendLine(participant.SummonerName + " : " + RiotApiService.MakeBold(((Champion)participant.ChampionId).Name()));
            }
            StringBuilder redStringBuilder = new StringBuilder();

            foreach (var participant in redSide)
            {
                redStringBuilder.AppendLine(participant.SummonerName + " : " + RiotApiService.MakeBold(((Champion)participant.ChampionId).Name()));
            }
            var embed = new EmbedBuilder
            {
                Title        = $"Live Match Data for {summonerName}",
                Color        = Color.Green,
                ThumbnailUrl = DataDragonService.GetMapURL(currentGameInfo.MapId.ToString()),
            };

            embed.AddField("Game Type", currentGameInfo.GameMode);
            embed.AddField("Blue Side", blueStringBuilder.ToString(), true);
            embed.AddField("Red Side", redStringBuilder.ToString(), true);
            embed.WithCurrentTimestamp();
            await ReplyAsync(embed : embed.Build());
        }
Beispiel #3
0
        public async Task GetSummonerInfoAsync(params string[] objects)
        {
            if (RiotApiService.ValidReigon(objects[objects.Length - 1]) == false)
            {
                throw new ArgumentException("Arguments should be the following:\n1: Summoner Name\n" +
                                            "2: Reigon\n");
            }
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i <= objects.Length - 2; i++)
            {
                stringBuilder.Append(objects[i] + " ");
            }
            string summonerName = stringBuilder.ToString().Substring(0, stringBuilder.ToString().Length - 1);

            await ReplyAsync("Obtaining summoner info for summoner : " + summonerName + " ...");

            var result = await RiotApiService.GetSummonerInfoAsync(summonerName, objects[objects.Length - 1]);

            var embed = new EmbedBuilder();

            embed.WithAuthor(author);
            embed.Color = Color.Green;
            embed.Title = summonerName;
            embed.AddField("Level", result["Level"]);
            if (result.ContainsKey("RANKED_FLEX_SR"))
            {
                embed.AddField("Flex Rank", GetRankedLogo(result["RANKED_FLEX_SR"]) + " " + result["RANKED_FLEX_SR"], true);
                embed.AddField("Flex WR", result["RANKED_FLEX_SRWR"], true);
            }
            if (result.ContainsKey("RANKED_SOLO_5x5"))
            {
                embed.AddField("Solo Rank", GetRankedLogo(result["RANKED_SOLO_5x5"]) + " " + result["RANKED_SOLO_5x5"], true);
                embed.AddField("Solo WR", result["RANKED_SOLO_5x5WR"], true);
            }
            embed.AddField("Highest Champion Mastery",
                           result["ChampMastery"] + " " + result["ChampMasteryScore"] + " points");
            embed.ImageUrl     = DataDragonService.GetChampionImageURL(result["ChampMastery"]);
            embed.ThumbnailUrl = DataDragonService.GetSummonerIconURL(result["IconID"]);
            embed.WithCurrentTimestamp();

            await ReplyAsync(embed : embed.Build());
        }