Exemplo n.º 1
0
 public void Example1()
 {
     IRiotClient riotClient = new RiotClient("your api key here");
     //retrieve all current free to play champions
     var championList = riotClient.Champion.RetrieveAllChampions(RiotApiConfig.Regions.NA, freeToPlay: true);
     //print the number of free to play champions
     Console.WriteLine($"There are {championList.Champions.Count()} free to play champions to play with!");
 }
Exemplo n.º 2
0
 public void Example2()
 {
     IRiotClient riotClient = new RiotClient("your api key here");
     //retrieve xeyanord and fnatictop summoners with one call
     var summoners = riotClient.Summoner.GetSummonersByName(RiotApiConfig.Regions.EUNE, "xeyanord", "fnatictop");
     var xeyanord = summoners["xeyanord"];
     var fnatictop = summoners["fnatictop"];
     //print the following statement about the two summoners
     Console.WriteLine(
         $"{fnatictop.Name} is level {fnatictop.SummonerLevel} and {xeyanord.Name} is {xeyanord.SummonerLevel}, its because {xeyanord.Name} is a slacker!");
 }
Exemplo n.º 3
0
        static void AddData(RiotClient riotClient, string version = null)
        {
            int tryCount = 0;
            bool gotData = false;
            ChampionListDto champData = null;
            ItemListDto itemData = null;
            do
            {
                try
                {
                    champData = riotClient.LolStaticData.GetChampionList(RiotApiConfig.Regions.EUW, null, null, version, "all");
                    gotData = true;
                }

                catch (Exception ex)
                {
                    tryCount += 1;
                    if (tryCount % 3 == 0)
                    {
                        System.Threading.Thread.Sleep(60000);
                    }
                }
            } while (gotData == false);

            version = champData.Version;
            // reset loop variables
            gotData = false;
            tryCount = 0;
            // ---------------------
            do
            {
                try
                {
                    itemData = riotClient.LolStaticData.GetItemList(RiotApiConfig.Regions.EUW, null, version, "all");
                    gotData = true;
                }
                catch
                {
                    tryCount += 1;
                    if (tryCount % 3 == 0)
                    {
                        System.Threading.Thread.Sleep(60000);
                    }
                }
            } while (gotData == false);

            if (itemData != null && champData != null)
            {
                PatchContext context = new PatchContext();
                context.PatchList.Add(new Patch(champData, itemData));
                context.SaveChanges();
                MailControl.SendMail("Added Patch", $"Patch {version} was successfully added to the database at {DateTime.Now}.");
            }
        }
Exemplo n.º 4
0
        private static MatchInfo GetMatchInfo(string region, long matchId, bool timeline, string key, RiotClient riotClient)
        {
            MatchDetail matchDetail = DownloadMatch(region, matchId, timeline, key, riotClient);
            Match match = new Match(matchDetail);

            List<Team> teams = matchDetail.Teams.Select(team => new Team(team)
            {
                MatchId = match.Id
            }).ToList();

            List<Ban> bans = matchDetail.Teams.SelectMany(team => team.Bans == null ? new List<Ban>() : team.Bans.Select(champ => new Ban(champ)
            {
                MatchId = match.Id
            })).ToList();

            long? nullLong = null;
            string nullString = null;
            List<Participant> participants = matchDetail.Participants.Select(p => new Participant(p)
            {
                MatchId = match.Id,
                SummonerId = (matchDetail.ParticipantIdentities.First(pi => p.ParticipantId.Equals(pi.ParticipantId)).Player == null) ? nullLong : (matchDetail.ParticipantIdentities.First(pi => p.ParticipantId.Equals(pi.ParticipantId)).Player.SummonerId),
                SummonerName = (matchDetail.ParticipantIdentities.First(pi => p.ParticipantId.Equals(pi.ParticipantId)).Player == null) ? nullString : (matchDetail.ParticipantIdentities.First(pi => p.ParticipantId.Equals(pi.ParticipantId)).Player.SummonerName)
            }).ToList();

            List<Event> events = matchDetail.Timeline.Frames.SelectMany(frame => frame.Events == null ? new List<Event>() : frame.Events.Where(e => e.EventType.Equals(Enums.EventType.ITEM_PURCHASED) || e.EventType.Equals(Enums.EventType.SKILL_LEVEL_UP)).Select(e => new Event(e)
            {
                MatchId = match.Id
            })).ToList();

            List<ParticipantFrame> participantFrames = matchDetail.Timeline.Frames.SelectMany(frame => frame.ParticipantFrames.Select(pf => new ParticipantFrame(pf.Value)
            {
                MatchId = match.Id,
                Timestamp = frame.Timestamp
            })).ToList();

            MatchInfo matchInfo = new MatchInfo
            {
                Match = match,
                Teams = teams,
                Bans = bans,
                Participants = participants,
                Events = events,
                ParticipantFrames = participantFrames
            };
            return matchInfo;
        }
Exemplo n.º 5
0
        // GET: matches/Details/5
        public ActionResult Details(string search)
        {
            //SimpleMemberService test = new SimpleMemberService();
            ////simplemember s = test.GetById(12);
            //ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
            //var mail = user.Email;

            //var aaaa = test.GetMany(m => m.email == mail);

            //var s = test.GetById(aaaa.First().Id);

            IRiotClient riotClient = new RiotClient("f5e474de-885a-477a-8b74-fa16f5915741");

                var cham = riotClient.Summoner.GetSummonersByName(RiotApiConfig.Regions.EUW, search);
                long tt = cham.First().Value.Id;

                var sts = riotClient.Stats.GetPlayerStatsBySummonerId(RiotApiConfig.Regions.EUW, tt);
                var sss = sts.PlayerStatSummaries.First();

                ViewBag.sum = sss;
                return View(sss);
        }
Exemplo n.º 6
0
 public void Example3()
 {
     IRiotClient riotClient = new RiotClient("your api key here");
     //get challeger tier league for ranked solo 5x5
     var challengers = riotClient.League.GetChallengerTierLeagues(RiotApiConfig.Regions.EUNE,
         Enums.GameQueueType.RANKED_SOLO_5x5);
     //get top 5 leaderboard using LINQ
     var top5 = challengers.Entries.OrderByDescending(x => x.LeaguePoints).Take(5).ToList();
     //Print top 5 leaderboard
     top5.ForEach(
         topEntry =>
             Console.WriteLine(
                 $"{topEntry.PlayerOrTeamName} - wins:{topEntry.Wins}  loss:{topEntry.Losses} points:{topEntry.LeaguePoints}"));
 }
Exemplo n.º 7
0
 private static string DownloadMatchString(string region, long matchId, bool timeline, string key, RiotClient riotClient)
 {
     return DownloadMatch(region, matchId, timeline, key, riotClient).ToString();
 }
Exemplo n.º 8
0
 private static MatchDetail DownloadMatch(string region, long matchId, bool timeline, string key, RiotClient riotClient)
 {
     return riotClient.Match.GetMatchById((RiotApiConfig.Regions)Enum.Parse(typeof(RiotApiConfig.Regions), region.ToUpper()), matchId, timeline);
 }
Exemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="apiKey">Your Riot API Key</param>
        /// <param name="version">The version to process, This can be left null to check the latest version.</param>
        static void StartProcessing(string apiKey, RiotClient riotClient = null, string version = null)
        {
            if (riotClient == null)
            {
                riotClient = RiotApiLoader.CreateHttpClient(apiKey);
            }

            ChampionListDto champData = null;
            int tryCount = 0;
            bool gotData = false;
            do
            {
                try
                {
                    champData = riotClient.LolStaticData.GetChampionList(RiotApiConfig.Regions.EUW, null, null, version, null);
                    gotData = true;
                }

                catch (Exception ex)
                {
                    tryCount += 1;
                    if (tryCount % 3 == 0)
                    {
                        System.Threading.Thread.Sleep(60000);
                    }
                }
            } while (gotData == false);
            version = champData.Version;
            if (isNewVersion(version))
            {
                AddData(riotClient, version);
            }
        }