示例#1
0
        public Form1()
        {
            InitializeComponent();

            string key = File.ReadAllText(@"D:\Riot\RIOT\RIOT\key_file.txt");
            api = RiotApi.GetInstance(key, 3000, 180000);
        }
示例#2
0
        public MatchPipeline(RiotApi riotApi, RiotQuerySettings querySettings, IMatchDetailProcessor matchDetailProcessor)
        {
            api = riotApi;
            this.querySettings = querySettings;
            this.matchDetailProcessor = matchDetailProcessor;

            queryQueues.Add(querySettings.Queue);

            // Create match producer
            if (!querySettings.NoDownload)
            {
                playerMatchProducer = new PlayerMatchProducer(api, querySettings, queryQueues, testSynchronizer);

                // Create blocks
                ConsumeMatchBlock = new TransformBlock<MatchSummary, MatchDetail>(
                    async match => await ConsumeMatch(match),
                    new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = 5 });
            }
            ConsumeMatchDetailBlock = new ActionBlock<MatchDetail>(
                async match => await matchDetailProcessor.ConsumeMatchDetail(match),
                new ExecutionDataflowBlockOptions() {
                    MaxDegreeOfParallelism = matchDetailProcessor.MaxDegreeOfParallelism
                });

            // Link blocks
            if (!querySettings.NoDownload)
            {
                playerMatchProducer.MatchProducerBlock.LinkTo(ConsumeMatchBlock, new DataflowLinkOptions() { PropagateCompletion = false });
                ConsumeMatchBlock.LinkTo(ConsumeMatchDetailBlock, new DataflowLinkOptions() { PropagateCompletion = false }, match => match != null);
                ConsumeMatchBlock.LinkTo(DataflowBlock.NullTarget<MatchDetail>(), new DataflowLinkOptions() { PropagateCompletion = false });
            }
        }
示例#3
0
 /// <summary>
 /// Get the instance of RiotApi.
 /// </summary>
 /// <param name="apiKey">The api key.</param>
 /// <param name="isProdApi">Indicates if this is a production api or not.</param>
 /// <returns>The instance of RiotApi.</returns>
 public static RiotApi GetInstance(string apiKey, bool isProdApi)
 {
     if (instance == null || apiKey != RateLimitedRequester.ApiKey || isProdApi != RateLimitedRequester.IsProdApi)
     {
         instance = new RiotApi(apiKey, isProdApi);
     }
     return instance;
 }
示例#4
0
 /// <summary>
 /// Get the instance of RiotApi.
 /// </summary>
 /// <param name="apiKey">The api key.</param>
 /// <param name="rateLimitPer10s">The 10 seconds rate limit for your production api key.</param>
 /// <param name="rateLimitPer10m">The 10 minutes rate limit for your production api key.</param>
 /// <returns>The instance of RiotApi.</returns>
 public static RiotApi GetInstance(string apiKey, int rateLimitPer10s = 10, int rateLimitPer10m = 500)
 {
     if (instance == null || apiKey != RateLimitedRequester.ApiKey ||
         rateLimitPer10s != RateLimitedRequester.RateLimitPer10S ||
         rateLimitPer10m != RateLimitedRequester.RateLimitPer10M)
     {
         instance = new RiotApi(apiKey, rateLimitPer10s, rateLimitPer10m);
     }
     return instance;
 }
        // Comprobar la conexión
        public static bool Comprobar_Conexion(string key, string nombreInvocador, RiotSharp.Misc.Region region)
        {
            RiotSharp.RiotApi api = RiotApi.GetDevelopmentInstance(key);

            try { api.GetSummonerByName(region, nombreInvocador);
                  _NombreInvocador = nombreInvocador;
                  _Key             = key;
                  _Region          = region;
                  return(true); }
            catch (RiotSharpException) { return(false); }
        }
		private bool IsSummoned() {
			bool success = true;
			try {
				api = RiotApi.GetInstance(VortexConfig.GetRiotApi());
				staticApi = StaticRiotApi.GetInstance(VortexConfig.GetRiotApi());
				region = (Region)Enum.Parse(typeof(Region), VortexConfig.GetRegion());
				oSummoner = api.GetSummoner(region, txtSearchBar.Text);
			}
			catch {
				success = false;
			}
			return success;
		}
示例#7
0
        public PlayerMatchProducer(RiotApi riotApi, RiotQuerySettings querySettings, List<Queue> queryQueues, MatchDownloadLimiter testSynchronizer)
        {
            api = riotApi;
            this.querySettings = querySettings;
            this.queryQueues = queryQueues;
            this.testSynchronizer = testSynchronizer;

            // Create blocks
            PlayerBufferBlock = new BufferBlock<PlayerEntry>();
            PlayerToMatchesBlock = new TransformManyBlock<PlayerEntry, MatchSummary>(
                async player => await ConsumePlayerAsync(player),
                new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = 2 });

            // Link blocks
            PlayerBufferBlock.LinkTo(PlayerToMatchesBlock, new DataflowLinkOptions() { PropagateCompletion = true });
        }
        public RiotApiScrapeJob()
        {
            var key = WebConfigurationManager.AppSettings["RiotApiKey"];
            var rateLimit1 = int.Parse(WebConfigurationManager.AppSettings["RateLimitPer10Seconds"]);
            var rateLimit2 = int.Parse(WebConfigurationManager.AppSettings["RateLimitPer10Minutes"]);

            _api = RiotApi.GetInstance(key, rateLimit1, rateLimit2);

            // For summoner statistics, always 1 hour
            var intervalSummoners = new TimeSpan(1, 0, 0);
            // For matches, every minute
            var intervalMatches = new TimeSpan(0, 1, 0);

            //new Timer(ScrapeSummoners, null, new TimeSpan(0, 0, 0, 0, 0), intervalSummoners);
            new Timer(ScrapeMatches, null, new TimeSpan(0, 0, 0, 0, 0), intervalMatches);
        }
        public static void Obtener_Enemigos()
        {
            RiotSharp.RiotApi       Api       = RiotApi.GetDevelopmentInstance(_Key);
            RiotSharp.StaticRiotApi StaticApi = StaticRiotApi.GetInstance(_Key);

            try
            {
                RiotSharp.SummonerEndpoint.Summoner            Summoner     = Api.GetSummonerByName(_Region, _NombreInvocador);
                List <RiotSharp.SpectatorEndpoint.Participant> Participants = Api.GetCurrentGame(_Region, Summoner.Id).Participants;

                // --- ## Diccionarios para cargar los campeones & hechizos ## --- //

                Dictionary <string, RiotSharp.StaticDataEndpoint.Champion.ChampionStatic> .ValueCollection championlist =
                    StaticApi.GetChampions(_Region, RiotSharp.StaticDataEndpoint.ChampionData.All).Champions.Values;

                Dictionary <string, RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic> .ValueCollection SummonerSpell =
                    StaticApi.GetSummonerSpells(_Region, RiotSharp.StaticDataEndpoint.SummonerSpellData.All).SummonerSpells.Values;

                // --- ## Diccionarios para cargar los campeones & hechizos ## --- //

                int total = Participants.Count;
                int index = Participants.FindIndex(a => a.SummonerName == _NombreInvocador);

                if (index > (total / 2) - 1)
                {
                    for (int i = 0; i <= (total / 2) - 1; i++)
                    {
                        IEnumerable <RiotSharp.StaticDataEndpoint.Champion.ChampionStatic>
                        CampeonWhere = championlist.Where(yourself => yourself.Id == Participants[i].ChampionId);

                        IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic>
                        Spell1Where = SummonerSpell.Where(yourself => yourself.Id == Participants[i].SummonerSpell1);

                        IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic>
                        Spell2Where = SummonerSpell.Where(yourself => yourself.Id == Participants[i].SummonerSpell2);

                        Enemigos.Add(CampeonWhere.First());
                        Hechizos.Add(Spell1Where.First());
                        Hechizos.Add(Spell2Where.First());
                    }
                }
                else
                {
                    for (int i = 0; i <= (total / 2) - 1; i++)
                    {
                        IEnumerable <RiotSharp.StaticDataEndpoint.Champion.ChampionStatic>
                        CampeonWhere = championlist.Where(yourself => yourself.Id == Participants[total / 2 + i].ChampionId);

                        IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic>
                        Spell1Where = SummonerSpell.Where(yourself => yourself.Id == Participants[total / 2 + i].SummonerSpell1);

                        IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic>
                        Spell2Where = SummonerSpell.Where(yourself => yourself.Id == Participants[total / 2 + i].SummonerSpell2);


                        Enemigos.Add(CampeonWhere.First());
                        Hechizos.Add(Spell1Where.First());
                        Hechizos.Add(Spell2Where.First());
                    }
                }
            }
            catch (RiotSharpException e)
            {
                _controlar_excepcion = e.Message;
            }
        }
示例#10
0
        public void LoadPlayer(Region reg, RiotSharp.RiotApi api, Participant p, string champion)
        {
            try
            {
                SummonerName = p.Name;
                Rank         = "Unranked";
                WinRate      = 0;
                RankedWins   = "0";
                RankedLosses = "0";
                Id           = 0;
                Spell1       = p.Spell1Id;
                Spell2       = p.Spell2Id;
                Champion     = champion;

                Summoner sum = api.GetSummoner(reg, SummonerName);
                Id    = sum.Id;
                Level = sum.Level;

                List <PlayerStatsSummary> sp = api.GetStatsSummaries(reg, Id);
                foreach (PlayerStatsSummary ps in sp)

                {
                    if (ps.PlayerStatSummaryType == PlayerStatsSummaryType.RankedSolo5x5)
                    {
                        RankedWins   = ps.Wins.ToString();
                        RankedLosses = ps.Losses.ToString();
                    }
                    else if (ps.PlayerStatSummaryType == PlayerStatsSummaryType.Unranked)
                    {
                        Wins = ps.Wins.ToString();
                    }
                }

                try
                {
                    foreach (ChampionStats ci in api.GetStatsRanked(reg, Id))
                    {
                        if (ci.ChampionId == p.ChampionId)
                        {
                            ChampStat = ci;
                            WinRate   = (double)ci.Stats.TotalSessionsWon / ci.Stats.TotalSessionsPlayed;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Success   = false;
                    ChampStat = null;
                }
                try
                {
                    List <long> asum = new List <long>(); asum.Add(p.SummonerId);
                    Dictionary <long, List <RiotSharp.LeagueEndpoint.League> > league = api.GetLeagues(reg, asum);

                    if (league.Count > 0)
                    {
                        foreach (League l in league[p.SummonerId])
                        {
                            if (l.Queue == RiotSharp.Queue.RankedSolo5x5)
                            {
                                // tier
                                Rank         = l.Tier.ToString();
                                RankedLeague = l.Entries[0];

                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Rank         = "Unranked";
                    RankedLeague = null;
                    Success      = false;
                }
            }
            catch (Exception ex)
            {
                Success      = false;
                SummonerName = "Error occured";
            }
            if (Success && ApiCache.ForceDodge.Contains(Id))
            {
                ApiCache.ForceDodge.Remove(Id);
            }

            else if (!ApiCache.ForceDodge.Contains(Id) && !Success)
            {
                ApiCache.ForceDodge.Add(Id);
            }
        }
示例#11
0
        public LeagueService()
        {
            this._api = RiotApi.GetInstance(Config.Riot.RiotApiKey, Config.Riot.RiotApiRateLimitPer10Seconds, Config.Riot.RiotApiRateLimitPer10Minutes);
            this._staticApi = StaticRiotApi.GetInstance(Config.Riot.RiotApiKey);

            this._regionMapping = new Dictionary<Region, RiotSharp.Region>
            {
                [Region.Br] = RiotSharp.Region.br,
                [Region.Eune] = RiotSharp.Region.eune,
                [Region.Euw] = RiotSharp.Region.euw,
                [Region.Na] = RiotSharp.Region.na,
                [Region.Kr] = RiotSharp.Region.kr,
                [Region.Lan] = RiotSharp.Region.lan,
                [Region.Las] = RiotSharp.Region.las,
                [Region.Oce] = RiotSharp.Region.oce,
                [Region.Ru] = RiotSharp.Region.ru,
                [Region.Tr] = RiotSharp.Region.tr,
            };
            this._regionToPlatformMapping = new Dictionary<Region, Platform>
            {
                [Region.Br] = Platform.BR1,
                [Region.Eune] = Platform.EUN1,
                [Region.Euw] = Platform.EUW1,
                [Region.Na] = Platform.NA1,
                [Region.Kr] = Platform.KR,
                [Region.Lan] = Platform.LA1,
                [Region.Las] = Platform.LA2,
                [Region.Oce] = Platform.OC1,
                [Region.Ru] = Platform.RU,
                [Region.Tr] = Platform.TR1,
            };
            this._gameQueueTypeMapping = new Dictionary<GameQueueType, RiotSharp.CurrentGameEndpoint.Converters.GameQueueType>
            {
                [GameQueueType.Custom] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Custom,
                [GameQueueType.Normal5x5Blind] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Normal5x5Blind,
                [GameQueueType.RankedSolo5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedSolo5x5,
                [GameQueueType.RankedPremade5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedPremade5x5,
                [GameQueueType.Bot5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5,
                [GameQueueType.Normal3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Normal3x3,
                [GameQueueType.RankedPremade3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedPremade3x3,
                [GameQueueType.Normal5x5Draft] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Normal5x5Draft,
                [GameQueueType.Odin5x5Blind] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Odin5x5Blind,
                [GameQueueType.Odin5x5Draft] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Odin5x5Draft,
                [GameQueueType.BotOdin5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BotOdin5x5,
                [GameQueueType.Bot5x5Intro] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5Intro,
                [GameQueueType.Bot5x5Beginner] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5Beginner,
                [GameQueueType.Bot5x5Intermediate] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5Intermediate,
                [GameQueueType.RankedTeam3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedTeam3x3,
                [GameQueueType.RankedTeam5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedTeam5x5,
                [GameQueueType.BotTt3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BotTt3x3,
                [GameQueueType.GroupFinder5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.GroupFinder5x5,
                [GameQueueType.Aram5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Aram5x5,
                [GameQueueType.Oneforall5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Oneforall5x5,
                [GameQueueType.Firstblood1x1] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Firstblood1x1,
                [GameQueueType.Firstblood2x2] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Firstblood2x2,
                [GameQueueType.Sr6x6] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Sr6x6,
                [GameQueueType.Urf5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Urf5x5,
                [GameQueueType.BotUrf5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BotUrf5x5,
                [GameQueueType.NightmareBot5x5Rank1] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.NightmareBot5x5Rank1,
                [GameQueueType.NightmareBot5x5Rank2] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.NightmareBot5x5Rank2,
                [GameQueueType.NightmareBot5x5Rank5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.NightmareBot5x5Rank5,
                [GameQueueType.Ascension5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Ascension5x5,
                [GameQueueType.Hexakill] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Hexakill,
                [GameQueueType.BilgewaterAram5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BilgewaterAram5x5,
                [GameQueueType.KingPoro5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.KingPoro5x5,
                [GameQueueType.Bilgewater5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bilgewater5x5,
                [GameQueueType.TeamBuilderDraftRanked] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.TeamBuilderDraftRanked,
                [GameQueueType.TeamBuilderDraftUnranked] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.TeamBuilderDraftUnranked,
            };
            this._gameModeMapping = new Dictionary<GameMode, RiotSharp.GameMode>
            {
                [GameMode.Classic] = RiotSharp.GameMode.Classic,
                [GameMode.Dominion] = RiotSharp.GameMode.Dominion,
                [GameMode.Aram] = RiotSharp.GameMode.Aram,
                [GameMode.Tutorial] = RiotSharp.GameMode.Tutorial,
                [GameMode.OneForAll] = RiotSharp.GameMode.OneForAll,
                [GameMode.FirstBlood] = RiotSharp.GameMode.FirstBlood,
                [GameMode.Ascension] = RiotSharp.GameMode.Ascension,
                [GameMode.Intro] = RiotSharp.GameMode.Intro,
                [GameMode.KingPoro] = RiotSharp.GameMode.KingPoro,
            };
            this._mapTypeMapping = new Dictionary<MapType, RiotSharp.MapType>
            {
                [MapType.SummonersRiftSummerVariant] = RiotSharp.MapType.SummonersRiftSummerVariant,
                [MapType.SummonersRiftAutumnVariant] = RiotSharp.MapType.SummonersRiftAutumnVariant,
                [MapType.TheProvingGrounds] = RiotSharp.MapType.TheProvingGrounds,
                [MapType.TwistedTreelineOriginal] = RiotSharp.MapType.TwistedTreelineOriginal,
                [MapType.TheCrystalScar] = RiotSharp.MapType.TheCrystalScar,
                [MapType.TwistedTreelineCurrent] = RiotSharp.MapType.TwistedTreelineCurrent,
                [MapType.SummonersRift] = RiotSharp.MapType.SummonersRift,
                [MapType.HowlingAbyss] = RiotSharp.MapType.HowlingAbyss,
            };
            this._gameTypeMapping = new Dictionary<GameType, RiotSharp.GameType>
            {
                [GameType.Custom] = RiotSharp.GameType.CustomGame,
                [GameType.Matched] = RiotSharp.GameType.MatchedGame,
                [GameType.Tutorial] = RiotSharp.GameType.TutorialGame
            };
            this._laneMapping = new Dictionary<RiotSharp.MatchEndpoint.Lane, Lane>
            {
                [RiotSharp.MatchEndpoint.Lane.Bot] = Lane.Bot,
                [RiotSharp.MatchEndpoint.Lane.Bottom] = Lane.Bot,
                [RiotSharp.MatchEndpoint.Lane.Jungle] = Lane.Jungle,
                [RiotSharp.MatchEndpoint.Lane.Mid] = Lane.Mid,
                [RiotSharp.MatchEndpoint.Lane.Middle] = Lane.Mid,
                [RiotSharp.MatchEndpoint.Lane.Top] = Lane.Top,
            };
            this._roleMapping = new Dictionary<RiotSharp.MatchEndpoint.Role, Role>
            {
                [RiotSharp.MatchEndpoint.Role.Duo] = Role.Duo,
                [RiotSharp.MatchEndpoint.Role.DuoCarry] = Role.DuoCarry,
                [RiotSharp.MatchEndpoint.Role.DuoSupport] = Role.DuoSupport,
                [RiotSharp.MatchEndpoint.Role.None] = Role.None,
                [RiotSharp.MatchEndpoint.Role.Solo] = Role.Solo,
            };
        }