Exemple #1
0
        public static async Task <string> ShowChampion(string query)
        {
            string input            = UppercaseFirst(query);
            var    lolChampionModel = await AsyncCalls.LoLChampionAsync();

            Dictionary <string, Champion> championDictionary = lolChampionModel.data;
            var sC = new Champion();

            try
            {
                sC = championDictionary[input];
            }
            catch
            {
                return("Wrong input, sorry");
            }

            string result;

            result =
                $"Name:{sC.id}\n" +
                $"{UppercaseFirst(sC.title)}\n" +
                $"{sC.tags[0]},{sC.tags[1]}\n" +
                $"Stats\n" +
                $"HP = {sC.stats.hp}";

            return(result);
        }
Exemple #2
0
        public static async Task <List <string> > TopChamps(string query)
        {
            string[]      querylist  = query.Split(' ');
            int           nrOfChamps = Int32.Parse(querylist[0]);
            List <string> endResult  = new List <string>();

            //if input number is between 1-10
            if (nrOfChamps >= 1 && nrOfChamps <= 10)
            {
                var LoLSummonerModel = await AsyncCalls.LoLSummonerAsync(querylist[1]);

                if (LoLSummonerModel == null)
                {
                    endResult.Add("No such player");
                    return(endResult);
                }
                var lolMasteryModel = await AsyncCalls.LoLMasteryAsync(LoLSummonerModel.id);

                var lolChampionModel = await AsyncCalls.LoLChampionAsync();


                lolMasteryModel.OrderBy(o => o.championPoints).ToList();
                Dictionary <string, string> champId     = new Dictionary <string, string>();
                Dictionary <int, string>    pointsNames = new Dictionary <int, string>();

                //add champion id and the total mastery points to dictionary
                for (int i = 0; nrOfChamps - 1 >= i; i++)
                {
                    champId.Add(lolMasteryModel[i].championId.ToString(), lolMasteryModel[i].championPoints.ToString());
                }

                //to dictionary add the total mastery points and champion names(instead of ID)
                foreach (var champion in lolChampionModel.data.Values)
                {
                    if (champId.ContainsKey(champion.key))
                    {
                        pointsNames.Add(Int32.Parse(champId[champion.key]), champion.name);
                    }
                }
                //sort dictionary
                SortedDictionary <int, string> sortedEndResult = new SortedDictionary <int, string>(pointsNames);

                foreach (var item in sortedEndResult)
                {
                    endResult.Add($"Name:{item.Value} Points:{String.Format("{0:##,#}", item.Key)}");
                }
                return(endResult);
            }
            else
            {
                endResult.Add("Max 10 champs plz");
                return(endResult);
            }
        }