Exemplo n.º 1
0
        public void displayLeaderBoard(ref league_v2_3 leaguePlayers)
        {
            int index          = 0;
            int divisionLadder = 0;

            // Determines if the list is empty.
            bool isEmpty = false;

            if (leaguePlayers.leaderBoard == null)
            {
                isEmpty = true;
            }

            // Deterimines if is ranked or not
            if (!isEmpty)
            {
                if (leaguePlayers.leaderBoard != null)
                {
                    if (leaguePlayers.leaderBoard[index].queue == "RANKED_SOLO_5x5")
                    {
                        Console.WriteLine("RANKED_SOLO_5x5");

                        // Displays Tier One
                        for (divisionLadder = 0; divisionLadder < leaguePlayers.leaderBoard[index].entries.Count; divisionLadder++)
                        {
                            Console.WriteLine("Name: " + leaguePlayers.leaderBoard[index].entries[divisionLadder].playerOrTeamName);
                            Console.WriteLine("Tier: " + leaguePlayers.leaderBoard[index].entries[divisionLadder].tier);
                            Console.WriteLine("League Points: " + leaguePlayers.leaderBoard[index].entries[divisionLadder].leaguePoints);
                            Console.WriteLine("League Name: " + leaguePlayers.leaderBoard[index].entries[divisionLadder].leagueName);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Not in any League.");
                }
            }
            else
            {
                Console.WriteLine("Leader board is empty.");
            }

            Console.WriteLine("End leader board.");
        }
Exemplo n.º 2
0
        public void getLeaguePlayersFromAPI(ref league_v2_3 leaguePlayers)
        {
            WebRequest request_Games;

            // redesign or get rid of this whole method
            string API_URL = "http://prod.api.pvp.net/api/lol/na/v2.2/league/by-summoner/23549704";

            // Open stream and generate URI request
            Console.Write("\n");
            Console.Write("Getting League Players from API");
            Console.WriteLine("Opening URL");

            try
            {
                request_Games             = WebRequest.Create(API_URL);
                request_Games.Credentials = CredentialCache.DefaultCredentials;

                // Get Response
                // Setting 'Timeout' property in Milliseconds
                request_Games.Timeout = 30000;
                Console.WriteLine("\nThe Timeout time of the request before setting is : {0} milliseconds", request_Games.Timeout);
                Console.Write("Waiting on Web Response: ");

                // This request will throw a WebException if it reaches the timeout limit before it is able to fetch the resource.
                WebResponse response = request_Games.GetResponse();
                Console.WriteLine(((HttpWebResponse)response).StatusDescription);

                // Get the stream contaning content returned by the server.
                Stream       dataStream = response.GetResponseStream();
                StreamReader reader     = new StreamReader(dataStream);

                // Reading content from server
                Console.WriteLine("Converting stream to string.");
                string responseFromServer = reader.ReadToEnd();


                // Parse Data from server
                Console.WriteLine("Parsing Data");
                leaguePlayers = JsonConvert.DeserializeObject <league_v2_3>(responseFromServer);

                Console.WriteLine("Closing Stream");
                reader.Close();
                response.Close();
            }
            catch (WebException e)
            {
                // For error code to send back
                // errorConnection = true;
                Console.WriteLine("This program can't comminicate with the Web Server." +
                                  "\n\nException Message :" + e.Message);
                if (e.Status == WebExceptionStatus.ProtocolError)
                {
                    Console.WriteLine("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode);
                    Console.WriteLine("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            mainMenu menuObject      = new mainMenu();
            bool     menuLoop        = true;
            bool     errorConnection = false;
            bool     fileCreate      = false;
            int      menuItem        = 0;
            string   fileSettings    = "Settings.ini";

            // Json objects from servers
            ChampionListDto   liveChampionList     = new ChampionListDto();
            GameObject        pastGames            = new GameObject();
            league_v2_3       summonerLeagueLadder = new league_v2_3();
            API_Call          Operator             = new API_Call();
            summonerProfile   summonerStats        = new summonerProfile();
            stats_v1_2_Ranked testStats            = new stats_v1_2_Ranked();
            ChampionListDTO   listOfChampions      = new ChampionListDTO();


            // Operator makes call and grabs data from Riot.
            Operator.MakeCall(ref liveChampionList);

            Console.WriteLine("Calling pastGames");
            Operator.MakeCall(ref pastGames);

            Console.WriteLine("Calling summonerLeagueLadder");
            Operator.MakeCall(ref summonerLeagueLadder);
            Operator.MakeCall(ref testStats);
            Operator.MakeCall(ref listOfChampions);

            // Determines if user has run the program before.
            fileCreate = menuObject.checkFile(fileSettings);

            // Creates a file for user; mostly ini
            if (fileCreate)
            {
            }

            if (!errorConnection)
            {
                while (menuLoop)
                {
                    menuObject.displayMenu(ref menuItem);

                    switch (menuItem)
                    {
                    case 1:
                        // Display Active Roster
                        menuObject.displayActiveRoster(liveChampionList, listOfChampions);
                        break;

                    case 2:
                        //Display Free to Play Roster
                        // menuObject.displayFreeToPlay(liveChampionList);
                        break;

                    case 3:
                        // Change Current Region
                        // menuObject.displayBotChampions(liveChampionList);
                        break;

                    case 4:
                        // Displays last 10 games from user.
                        // menuObject.displayGamesPlayed(pastGames, liveChampionList);
                        break;

                    case 5:
                        // Display players in current league of player
                        menuObject.displayLeaderBoard(ref summonerLeagueLadder);
                        break;

                    case 6:
                        // Display Summary Stats
                        menuObject.displaySummaryStats(summonerStats);
                        break;

                    default:
                        menuLoop = false;
                        break;
                    }

                    // Exit program by user.
                    if (menuItem == 0)
                    {
                        menuLoop = false;
                    }
                }
            }
            else
            {
                Console.WriteLine("Closing program.");
            }

            Console.WriteLine("Hit any-key");
            Console.Read();
        }
Exemplo n.º 4
0
        /******************************************************************************************
        * Method Name: void MakeCall()
        * Arguements: league_v2_3 summonerLeaderBoard.
        * Purpose: Calls Riot Servers to grab list of the current leader board the summoner is currently
        *          in.
        * PreConditions: Assumes that API Key and Region have been set to desired location.
        * PostConditions: Fills current object with JSON parsed data recieved from Data Set.
        ******************************************************************************************/
        public void MakeCall(ref league_v2_3 summonerLeaderBoard)
        {
            WebRequest request_champ_stream;
            string     responseFromServer;
            string     API_URL = requestUrl_LeaderBoard_v2_3 + api_Key;
            string     temp    = API_URL;

            API_URL = temp.Replace("{region}", user_region);
            temp    = API_URL;
            API_URL = temp.Replace("{summonerId}", user_summonerid);


            // Displays where at
            Console.WriteLine("leaderBoard Object Call");
            try
            {
                // Open stream and generate URI request
                WebRequest.Create(API_URL);
                request_champ_stream             = WebRequest.Create(API_URL);
                request_champ_stream.Credentials = CredentialCache.DefaultCredentials;

                // Setting 'Timeout' property in Milliseconds
                request_champ_stream.Timeout = 30000;

                // This request will throw a WebException if it reaches the timeout limit before it is able to fetch the resource.
                WebResponse response = request_champ_stream.GetResponse();
                Console.WriteLine(((HttpWebResponse)response).StatusDescription);

                // Get the stream contaning content returned by the server.
                Stream       dataStream = response.GetResponseStream();
                StreamReader reader     = new StreamReader(dataStream);

                // Reading content from server and converting it to string type.
                responseFromServer = reader.ReadToEnd();

                // Parse Data from server into object
                summonerLeaderBoard.leaderBoard = JsonConvert.DeserializeObject <List <LeagueDto> >(responseFromServer);

                // Closing Stream
                reader.Close();
                response.Close();

                errorResponse = false;
            }
            // Determines if the call failed.
            catch (WebException e)
            {
                Console.WriteLine("This program can't comminicate with the Web Server." +
                                  "\n\nException Message :" + e.Message);
                if (e.Status == WebExceptionStatus.ProtocolError)
                {
                    errorHTTPStatusCode = "Status Code : {0}" + (((HttpWebResponse)e.Response).StatusCode).ToString();
                    Console.WriteLine("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode);

                    errorReason = "Status Description : {0}" + (((HttpWebResponse)e.Response).StatusDescription).ToString();
                    Console.WriteLine("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }