Ejemplo n.º 1
0
        public void TestHttpCreator()
        {
            var riotClient = RiotApiLoader.CreateHttpClient("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!");
        }
Ejemplo n.º 2
0
        private static void SaveData(string inputDirectory, string outputDirectory)
        {
            bool                 timeline   = true;
            string               key        = ConfigurationManager.AppSettings["APIKey"];
            RiotClient           riotClient = RiotApiLoader.CreateHttpClient(key);
            IEnumerable <string> filenames  = Directory.EnumerateFiles(inputDirectory, "*", SearchOption.AllDirectories);

            File.WriteAllText(outputDirectory + "matches.csv", "Id,Duration,Region,Patch,Queue" + Environment.NewLine);
            File.WriteAllText(outputDirectory + "teams.csv", "MatchId,Id,Winner" + Environment.NewLine);
            File.WriteAllText(outputDirectory + "bans.csv", "MatchId,ChampionId" + Environment.NewLine);
            File.WriteAllText(outputDirectory + "participants.csv", "MatchId,TeamId,ParticipantId,ChampionId,HighestAchievedSeasonTier,Lane,Role,Assists,Deaths,FirstBloodKill,GoldEarned,Item0,Item1,Item2,Item3,Item4,Item5,Item6,Kills,MagicDamageDealt,MagicDamageDealtToChampions,MagicDamageTaken,MinionsKilled,NeutralMinionsKilled,PhysicalDamageDealt,PhysicalDamageDealtToChampions,PhysicalDamageTaken,SightWardsBoughtInGame,TotalDamageDealt,TotalDamageDealtToChampions,TotalDamageTaken,TotalHeal,TotalTimeCrowdControlDealt,TotalUnitsHealed,TrueDamageDealt,TrueDamageDealtToChampions,TrueDamageTaken,VisionWardsBoughtInGame,WardsKilled,WardsPlaced,CreepsPerMinDeltas010,GoldPerMinDeltas010,CreepsPerMinDeltas1020,GoldPerMinDeltas1020,CreepsPerMinDeltas2030,GoldPerMinDeltas2030,CreepsPerMinDeltas30,GoldPerMinDeltas30,SummonerId,SummonerName" + Environment.NewLine);
            File.WriteAllText(outputDirectory + "events.csv", "MatchId,ParticipantId,EventType,ItemAfter,ItemBefore,ItemId,LevelUpType,SkillSlot,Timestamp" + Environment.NewLine);
            File.WriteAllText(outputDirectory + "participantFrames.csv", "MatchId,ParticipantId,CurrentGold,Level,MinionsKilled,TotalGold,Xp,Timestamp" + Environment.NewLine);

            File.WriteAllText(outputDirectory + "error.csv", "MatchId,Message,StackTrace,Timestamp" + Environment.NewLine);

            foreach (string inputFileName in filenames)
            {
                string   matchIdsString = File.ReadAllText(inputFileName);
                string[] parts          = inputFileName.Split('\\');
                string   region         = parts[parts.Length - 1].Replace(".json", "");
                foreach (string s in matchIdsString.Split(',', '[', ']', '\r', '\n', ' ', '\t'))
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }
                    long matchId = long.Parse(s);
                    try
                    {
                        MatchInfo match = GetMatchInfo(region, matchId, timeline, key, riotClient);
                        File.AppendAllText(outputDirectory + "matches.csv", match.Match.ToString() + Environment.NewLine);
                        File.AppendAllLines(outputDirectory + "teams.csv", match.Teams.Select(t => t.ToString()));
                        File.AppendAllLines(outputDirectory + "bans.csv", match.Bans.Select(b => b.ToString()));
                        File.AppendAllLines(outputDirectory + "participants.csv", match.Participants.Select(p => p.ToString()));
                        File.AppendAllLines(outputDirectory + "events.csv", match.Events.Select(e => e.ToString()));
                        File.AppendAllLines(outputDirectory + "participantFrames.csv", match.ParticipantFrames.Select(pf => pf.ToString()));
                        Thread.Sleep(1500);
                    }
                    catch (Exception e)
                    {
                        File.AppendAllText(outputDirectory + "error.csv", "\"" + matchId + "\",\"" + DateTime.Now + "\",\"" + e.Message + "\",\"" + e.StackTrace + "\"");
                        Console.WriteLine(matchId + "\n" + e.Message + "\n" + e.StackTrace);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void GlueNinjectModules()
 {
     RiotHttpClient = RiotApiLoader.CreateHttpClient(ConfigurationManager.AppSettings["ApiKey"]);
 }