Exemplo n.º 1
0
        public async Task GetThirdPartyCodeAsyncTest()
        {
            IRiotClient client = RiotClient.ForPlatform(PlatformId.EUW1);
            string      code   = await client.GetThirdPartyCodeAsync(encryptedSummonerId);

            Assert.That(code, Is.Not.Null.And.Not.Empty);
        }
Exemplo n.º 2
0
 public Balancer()
 {
     client = new RiotClient(new RiotClientSettings
     {
         ApiKey = StaticValues.ApiKey
     });
 }
Exemplo n.º 3
0
        public async Task GetThirdPartyCodeAsyncTest()
        {
            IRiotClient client = RiotClient.ForPlatform(PlatformId.NA1);
            string      code   = await client.GetThirdPartyCodeAsync(34172230);

            Assert.That(code, Is.Not.Null.And.Not.Empty);
        }
Exemplo n.º 4
0
 public void InitializeClient()
 {
     _client = new RiotClient(new RiotClientSettings
     {
         ApiKey = LCGB.Key.apikey
     });
 }
Exemplo n.º 5
0
 public void GlueNinjectModules()
 {
     //first check the environmental variable if presented, that means we are in an continuous integration environment
     var apiKey = Environment.GetEnvironmentVariable("ApiKey") ?? ConfigurationManager.AppSettings["ApiKey"];
     //load a Riot Http module with an Api key into your kernel of your app
     IKernel kernel = new StandardKernel(new RiotHttpClientModule(apiKey));
     //get back the riot client from your application kernel using ninject
     RiotHttpClient = kernel.Get<RiotClient>();
 }
        private Task MaxOutRateLimit(IRiotClient client, int requestCount = 20)
        {
            var tasks = new List <Task>();

            for (var i = 0; i < requestCount; ++i)
            {
                tasks.Add(client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5));
            }
            return(Task.WhenAny(tasks));
        }
Exemplo n.º 7
0
        public void GlueNinjectModules()
        {
            //first check the environmental variable if presented, that means we are in an continuous integration environment
            var apiKey = Environment.GetEnvironmentVariable("ApiKey") ?? ConfigurationManager.AppSettings["ApiKey"];
            //load a Riot Http module with an Api key into your kernel of your app
            IKernel kernel = new StandardKernel(new RiotHttpClientModule(apiKey));

            //get back the riot client from your application kernel using ninject
            RiotHttpClient = kernel.Get <RiotClient>();
        }
Exemplo n.º 8
0
        public async Task GetShardDataAsyncTest_WithClientPlatformId()
        {
            IRiotClient client = RiotClient.ForPlatform(PlatformId.LA2);
            ShardStatus shard  = await client.GetShardDataAsync();

            Assert.That(shard, Is.Not.Null);
            Assert.That(shard.Name, Is.EqualTo("Latin America South"));
            Assert.That(shard.Slug, Is.EqualTo("las"));
            Assert.That(shard.RegionTag, Is.EqualTo("la2"));
        }
Exemplo n.º 9
0
        public SummonerHelper(SqliteContext context)
        {
            db     = context;
            client = new RiotClient();
            Champion c = db.Champion.FirstOrDefault();

            if (c == null)
            {
                Task.Run(PopulateChampionsAsync);
            }
        }
Exemplo n.º 10
0
        static async Task TestAsync(long MatchID)
        {
            IRiotClient client = new RiotClient(new RiotClientSettings
            {
                ApiKey = "############" // Replace this with your API key, of course.
            });

            cli = client;

            Match match = await client.GetMatchAsync(MatchID, PlatformId.NA1).ConfigureAwait(false);

            T1 = match;
        }
Exemplo n.º 11
0
        public void RetrieveChampionMasterScoreBehaviour()
        {
            //Arrange
            _mockClient.Setup(x => x.ChampionMastery.RetrieveChampionMasterScore(It.IsAny <RiotApiConfig.Regions>(), It.IsAny <long>()))
            .Returns(1);

            //Act
            IRiotClient client = _mockClient.Object;
            int         score  = client.ChampionMastery.RetrieveChampionMasterScore(RiotApiConfig.Regions.NA, 1);

            //Assert
            Assert.AreEqual(1, score);
        }
Exemplo n.º 12
0
        public void RetrieveTopChampionsBehaviour()
        {
            //Arrange
            _mockClient.Setup(x => x.ChampionMastery.RetrieveTopChampions(It.IsAny <RiotApiConfig.Regions>(), It.IsAny <long>(), It.IsAny <int>()))
            .Returns(new List <ChampionMasteryDto>());

            //Act
            IRiotClient client = _mockClient.Object;
            List <ChampionMasteryDto> dtoList = (List <ChampionMasteryDto>)client.ChampionMastery.RetrieveTopChampions(RiotApiConfig.Regions.NA, 1, null);

            //Assert
            Assert.IsInstanceOf <List <ChampionMasteryDto> >(dtoList);
            Assert.NotNull(dtoList);
        }
Exemplo n.º 13
0
        public void RetrieveChampionMasteryByIDBehaviour()
        {
            //Arrange
            _mockClient.Setup(x => x.ChampionMastery.RetrieveChampionMasteryByID(It.IsAny <RiotApiConfig.Regions>(), It.IsAny <long>(), It.IsAny <long>()))
            .Returns(new ChampionMasteryDto());

            //Act
            IRiotClient        client = _mockClient.Object;
            ChampionMasteryDto dto    = client.ChampionMastery.RetrieveChampionMasteryByID(RiotApiConfig.Regions.NA, 1, 1);

            //Assert
            Assert.IsInstanceOf <ChampionMasteryDto>(dto);
            Assert.NotNull(dto);
        }
Exemplo n.º 14
0
        public void RetrieveAllChampionsBehaviour()
        {
            //Arrange
            _mockClient.Setup(x => x.Champion.RetrieveAllChampions(It.IsAny <RiotApiConfig.Regions>(), It.IsAny <bool>()))
            .Returns(new ChampionListDto());

            //Act
            IRiotClient     client = _mockClient.Object;
            ChampionListDto dto    = client.Champion.RetrieveAllChampions(RiotApiConfig.Regions.EUNE, true);

            //Assert
            Assert.IsInstanceOf <ChampionListDto>(dto);
            Assert.NotNull(dto);
        }
Exemplo n.º 15
0
        public void GetCurrentGameInformationForSummonerIdBehaviour()
        {
            //Arrange
            _mockClient.Setup(x => x.CurrentGame.GetCurrentGameInformationForSummonerId(It.IsAny <RiotApiConfig.Platforms>(), It.IsAny <long>()))
            .Returns(new CurrentGameInfo());

            //Act
            IRiotClient     client = _mockClient.Object;
            CurrentGameInfo dto    = client.CurrentGame.GetCurrentGameInformationForSummonerId(
                RiotApiConfig.Platforms.EUN1, 1);

            //Assert
            Assert.IsInstanceOf <CurrentGameInfo>(dto);
            Assert.NotNull(dto);
        }
Exemplo n.º 16
0
        public async Task GetStaticRealmAsyncTest_EUW()
        {
            IRiotClient client = RiotClient.ForPlatform(PlatformId.EUW1);
            var         realm  = await client.GetStaticRealmAsync();

            Assert.That(realm, Is.Not.Null);
            Assert.That(realm.Cdn, Is.Not.Null.And.Not.Empty);
            Assert.That(realm.Css, Is.Not.Null.And.Not.Empty);
            Assert.That(realm.Dd, Is.Not.Null.And.Not.Empty);
            Assert.That(realm.L, Is.EqualTo(Locale.en_GB));
            Assert.That(realm.Lg, Is.Not.Null.And.Not.Empty);
            Assert.That(realm.N, Is.Not.Null.And.Not.Empty);
            Assert.That(realm.ProfileIconMax, Is.GreaterThan(0));
            Assert.That(realm.V, Is.Not.Null.And.Not.Empty);
        }
Exemplo n.º 17
0
        public async Task MainAsync()
        {
            botInstance = this;
            database    = new Database();
            database.Load();

            RiotClient.DefaultPlatformId = RiotNet.Models.PlatformId.NA1;
            riotInstance = new RiotClient(new RiotClientSettings
            {
                ApiKey = Keys.RIOT_KEY
            });

            string bot_token = Keys.DISCORD_KEY;

            client = new DiscordSocketClient();

            handler = new CommandHandler(client, new CommandService());


            client.Log   += Log;
            client.Ready += () =>
            {
                Console.WriteLine("Bot is connected!");
                return(Task.CompletedTask);
            };

            await client.LoginAsync(TokenType.Bot, bot_token);

            await client.StartAsync();

            await handler.InstallCommandsAsync();

            dbSaveTimer    = new System.Threading.Timer(SaveDatabase, null, 1000, 1000 * 5);    //10 seconds
            gameFetchTimer = new System.Threading.Timer(FetchGames, null, 5000, 1000 * 60 * 1); //1 minutes

            client.Disconnected += (evt) =>
            {
                database.Save();
                return(Task.CompletedTask);
            };

            await Task.Delay(-1);
        }
Exemplo n.º 18
0
 public void GlueNinjectModules()
 {
     RiotHttpClient = RiotApiLoader.CreateHttpClient(ConfigurationManager.AppSettings["ApiKey"]);
 }
Exemplo n.º 19
0
 public ChampionsController(IRiotClient riotClient, ICacheManager cacheManager, IMemoryCache memoryCache)
 {
     _riotClient   = riotClient;
     _cacheManager = cacheManager;
     _memoryCache  = memoryCache;
 }
Exemplo n.º 20
0
 public InitialEnityLoaders(IRiotClient riotClient, ICacheManager cacheManager)
 {
     _riotClient   = riotClient;
     _cacheManager = cacheManager;
 }
Exemplo n.º 21
0
 public LeaderboardController(IRiotClient riotClient, ICacheManager cacheManager, IMemoryCache memoryCache)
 {
     _riotClient = riotClient;
     _cacheManager = cacheManager;
     _memoryCache = memoryCache;
 }
Exemplo n.º 22
0
 public ChampionsController(IRiotClient riotClient, ICacheManager cacheManager, IMemoryCache memoryCache)
 {
     _riotClient = riotClient;
     _cacheManager = cacheManager;
     _memoryCache = memoryCache;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gets the status of the shard for the specified platform. This is an alias for <see cref="IRiotClient.GetShardDataAsync"/>.
 /// </summary>
 /// <param name="riotClient">The IRiotClient instance.</param>
 /// <param name="platformId">The platform ID of the server to connect to. This should equal one of the <see cref="Models.PlatformId"/> values. If unspecified, the <see cref="IRiotClient.PlatformId"/> property will be used.</param>
 /// <param name="token">The cancellation token to cancel the operation.</param>
 /// <returns>A task representing the asynchronous operation.</returns>
 public static Task <ShardStatus> GetShardStatusAsync(this IRiotClient riotClient, string platformId = null, CancellationToken token = default(CancellationToken))
 {
     return(riotClient.GetShardDataAsync(platformId, token));
 }
Exemplo n.º 24
0
 private async Task MaxOutRateLimit(IRiotClient client)
 {
     for (var i = 0; i < 11; ++i)
         await client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5);
 }
Exemplo n.º 25
0
 public LeaderboardController(IRiotClient riotClient, ICacheManager cacheManager, IMemoryCache memoryCache)
 {
     _riotClient   = riotClient;
     _cacheManager = cacheManager;
     _memoryCache  = memoryCache;
 }
Exemplo n.º 26
0
        private async void StoreMatches()
        {
            _client = new RiotClient(RiotNet.Models.Region.EUW);
            string filePath = Path.GetFullPath(@"=****;");
            List<long> MatchIDs;
            using (StreamReader sr = new StreamReader(filePath))
            {
                MatchIDs = JsonConvert.DeserializeObject<List<long>>(sr.ReadToEnd());
            }

            MySqlConnection conn = null;
            string cs = @"server=****;userid==****;password==****;database==****;";
            conn = new MySqlConnection(cs);

            try
            {
                conn.Open();
                foreach (long id in MatchIDs)
                {
                    Console.WriteLine(id);
                    RiotNet.Models.MatchDetail Match = await _client.GetMatchAsync(id);
                    if (Match != null)
                    {
                        foreach (RiotNet.Models.MatchTeam team in Match.Teams)
                        {
                            MySqlCommand cmd = new MySqlCommand();
                            cmd.Connection = conn;
                            cmd.CommandText = String.Format(@"INSERT INTO `Team`(
                                            `Winner`, `inhibitorKills`, `towerKills`, `firstTower`, `firstBlood`,
                                            `firstBaron`, `firstInhibitor`, `firstDragon`, `baronKills`, `dragonKills`) 
                                            VALUES (
                                            {0},{1},{2},{3},{4},
                                            {5},{6},{7},{8},{9})", team.Winner, team.InhibitorKills, team.TowerKills, team.FirstTower, team.FirstBlood, team.FirstBaron, team.FirstInhibitor, team.FirstDragon, team.BaronKills, team.DragonKills);
                            cmd.Prepare();
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());

            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

        }
Exemplo n.º 27
0
 public void GlueNinjectModules()
 {
     RiotHttpClient = RiotApiLoader.CreateHttpClient(ConfigurationManager.AppSettings["ApiKey"]);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Gets information about the current game a summoner is playing. This is an alias for <see cref="IRiotClient.GetActiveGameBySummonerIdAsync"/>.
 /// </summary>
 /// <param name="riotClient">The IRiotClient instance.</param>
 /// <param name="summonerId">The summoner ID.</param>
 /// <param name="platformId">The platform ID of the server to connect to. This should equal one of the <see cref="Models.PlatformId"/> values. If unspecified, the <see cref="IRiotClient.PlatformId"/> property will be used.</param>
 /// <param name="token">The cancellation token to cancel the operation.</param>
 /// <returns>A task representing the asynchronous operation.</returns>
 public static Task <CurrentGameInfo> GetCurrentGameBySummonerIdAsync(this IRiotClient riotClient, long summonerId, string platformId = null, CancellationToken token = default(CancellationToken))
 {
     return(riotClient.GetActiveGameBySummonerIdAsync(summonerId, platformId, token));
 }
Exemplo n.º 29
0
 public InitialEnityLoaders(IRiotClient riotClient, ICacheManager cacheManager)
 {
     _riotClient = riotClient;
     _cacheManager = cacheManager;
 }