public void Initialize()
        {
            _requester = new Mock <IRateLimitedRequester>();
            var staticEndpointProvider = new Mock <IStaticEndpointProvider>();

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

            _featuredGamesResponse = new FeaturedGames
            {
                GameList = new List <CurrentGame>
                {
                    _currentGameResponse
                },
                ClientRefreshInterval = 30
            };
            _riotApi = new RiotApi(_requester.Object, staticEndpointProvider.Object);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RiotClient"/> class.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        public RiotClient(string apiKey)
        {
            IChampion        champion        = new Champion(apiKey);
            ICurrentGame     currentGame     = new CurrentGame(apiKey);
            IFeaturedGames   featuredGames   = new FeaturedGames(apiKey);
            IGame            game            = new Game(apiKey);
            ILeague          league          = new League(apiKey);
            ILolStaticData   lolStaticData   = new LolStaticData(apiKey);
            ILolStatus       lolStatus       = new LolStatus();
            IMatch           match           = new Match(apiKey);
            IMatchList       matchList       = new MatchList(apiKey);
            IStats           stats           = new Stats(apiKey);
            ISummoner        summoner        = new Summoner(apiKey);
            ITeam            team            = new Team(apiKey);
            IChampionMastery championMastery = new ChampionMastery(apiKey);

            this.Champion        = champion;
            this.CurrentGame     = currentGame;
            this.FeaturedGames   = featuredGames;
            this.Game            = game;
            this.League          = league;
            this.LolStaticData   = lolStaticData;
            this.LolStatus       = lolStatus;
            this.Match           = match;
            this.MatchList       = matchList;
            this.Stats           = stats;
            this.Summoner        = summoner;
            this.Team            = team;
            this.ChampionMastery = championMastery;
        }
Exemplo n.º 3
0
        private void showFeaturedGames(string region)
        {
            if (!featuredGamesByRegion.ContainsKey(region))
            {
                FeaturedGames f = Services.getFeaturedGames(region);
                if (f != null)
                {
                    featuredGamesByRegion.Add(region, Services.getFeaturedGames(region));
                }
            }
            if (featuredGamesByRegion.ContainsKey(region) && featuredGamesByRegion[region].gameList.Length > 0)
            {
                selectedRegion = region;

                selectedFeaturedGames = featuredGamesByRegion[selectedRegion];

                setPage(0);

                Label[] labels = regionLabels.Values.ToArray();

                for (int i = 0; i < labels.Length; i++)
                {
                    labels[i].Font = new Font(labels[i].Font, FontStyle.Regular);
                }

                regionLabels[region].Font = new Font(regionLabels[region].Font, FontStyle.Bold);
            }
            else
            {
                showError("The featured games for " + region.ToUpper() + " couldnt be loaded");
            }
        }
Exemplo n.º 4
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            if (regionComboBox.SelectedItem == null)
            {
                showError("Pick a region");
                return;
            }

            string region = regionComboBox.SelectedItem.ToString().ToLower();
            string summ   = summName.Text;

            CurrentGameInfo game = Services.getCurrentGame(region, summ);

            if (game != null)
            {
                selectedGame          = game;
                selectedRegion        = region;
                selectedFeaturedGames = null;

                singlePage();

                Label[] labels = regionLabels.Values.ToArray();

                for (int i = 0; i < labels.Length; i++)
                {
                    labels[i].Font = new Font(labels[i].Font, FontStyle.Regular);
                }
            }
            else
            {
                showError("The player " + summ + " is not currently in a game.");
            }
        }
Exemplo n.º 5
0
        //Get list of featured games
        public async Task <FeaturedGames> GetMatchTimelineAsync()
        {
            FeaturedGames featured = null;
            string        request  = "/lol/spectator/" + SP_VERSION + "/featured-games";
            string        response = await GET(request);

            featured = JsonConvert.DeserializeObject <FeaturedGames>(response);
            return(featured);
        }
Exemplo n.º 6
0
        private void refreshGamesButton_Click(object sender, EventArgs e)
        {
            renewRefreshTime();

            featuredGamesByRegion = new Dictionary <string, FeaturedGames>();

            selectedGame          = null;
            selectedFeaturedGames = null;

            showFeaturedGames(selectedRegion);
        }
 public static void CheckFeatured(FeaturedGames featured)
 {
     Assert.IsNotNull(featured);
     Assert.IsNotNull(featured.GameList);
     Assert.AreEqual(5, featured.GameList.Length);
     foreach (var gameInfo in featured.GameList)
     {
         Assert.IsNotNull(gameInfo);
         Assert.IsNotNull(gameInfo.Participants);
         Assert.IsTrue(gameInfo.Participants.Length >= 6);
         foreach (var player in gameInfo.Participants)
         {
             Assert.IsNotNull(player);
             Assert.IsNotNull(player.SummonerName);
             Assert.IsTrue(player.SummonerName.Length > 0);
             Assert.IsFalse(player.Bot);
         }
         Assert.IsTrue(gameInfo.GameId > 0);
         Assert.IsNotNull(gameInfo.Observers);
         Assert.IsNotNull(gameInfo.Observers.EncryptionKey);
         Assert.IsTrue(Regex.IsMatch(gameInfo.Observers.EncryptionKey, "[a-zA-Z0-9/+]{32}"));
     }
 }