Exemplo n.º 1
0
        /// <summary>
        /// Pega partida ranqueada acontecendo
        /// Somente para propósitos de demonstração e teste
        /// </summary>
        /// <returns></returns>
        public async Task <FeaturedGame> RetornarPartidaAleatoriaAsync()
        {
            var api = RiotApi.GetDevelopmentInstance(_apiConfiguration.Key);

            FeaturedGame retorno = null;

            while (retorno == null)
            {
                retorno = (await api.Spectator.GetFeaturedGamesAsync(Region.Br)).GameList.FirstOrDefault(x => x.Platform == Platform.BR1 && x.GameQueueType == _rankedSolo.ToString() && _context.PartidaAtual.Find(k => k.GameId == x.GameId && x.Platform == x.Platform).FirstOrDefault() == null);

                if (retorno == null)
                {
                    _logger.LogInformation("Partida brasileira nao encontrada, tentando novamente em alguns instantes");
                    await Task.Delay(TimeSpan.FromSeconds(10));
                }
            }

            return(retorno);
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            _rateLimitedRequester = new Mock <IRateLimitedRequester>();
            _requester            = new Mock <IRequester>();
            var staticEndpointProvider = new Mock <IStaticEndpointProvider>();

            _currentGameResponse = new CurrentGame
            {
                GameId        = 1,
                GameLength    = TimeSpan.FromSeconds(60),
                GameMode      = "GameMode",
                GameQueueType = "Normal Draft",
                GameType      = GameType.MatchedGame,
                MapType       = MapType.SummonersRift,
                GameStartTime = DateTime.Today,
                Platform      = Platform.EUW1
            };
            _featureGameResponse = new FeaturedGame
            {
                GameId        = 1,
                GameLength    = TimeSpan.FromSeconds(60),
                GameMode      = "GameMode",
                GameQueueType = "Normal Draft",
                GameType      = GameType.MatchedGame,
                MapType       = MapType.SummonersRift,
                GameStartTime = DateTime.Today,
                Platform      = Platform.EUW1
            };

            _featuredGamesResponse = new FeaturedGames
            {
                GameList = new List <FeaturedGame>
                {
                    _featureGameResponse
                },
                ClientRefreshInterval = 30
            };
            _riotApi = new RiotApi(_rateLimitedRequester.Object, _requester.Object, staticEndpointProvider.Object);
        }