Exemplo n.º 1
0
        /**********************************************************************************************************
        * - Maybe have been deleted by RIOT.
        **********************************************************************************************************/
        /*
         * public void displayFreeToPlay(ChampionListDto displayFreeToPlay)
         * {
         *  int ndx = 0;
         *  int count = 0;
         *  string nameFormat;
         *
         *  // Determines if the list is empty.
         *  bool isEmpty = false;
         *
         *  if (displayFreeToPlay.champions.Count() == 0)
         *  {
         *      isEmpty = true;
         *  }
         *
         *  if (!isEmpty)
         *  {
         *      Console.WriteLine("Displaying Free to Play Roster");
         *
         *      for (ndx = 0; ndx < displayFreeToPlay.champions.Count(); ndx++)
         *      {
         *          if (displayFreeToPlay.champions[ndx].freeToPlay)
         *          {
         *              nameFormat = String.Format("Name : {0,-10}", displayFreeToPlay.champions[ndx].name);
         *
         *              Console.WriteLine(nameFormat);
         *              Console.WriteLine("Health: " + displayFreeToPlay.champions[ndx].defenseRank);
         *              Console.WriteLine("Attack: " + displayFreeToPlay.champions[ndx].attackRank);
         *              Console.WriteLine("Magic: " + displayFreeToPlay.champions[ndx].magicRank);
         *              Console.WriteLine("Difficulty: " + displayFreeToPlay.champions[ndx].difficultyRank);
         *
         *              Console.WriteLine();
         *          }
         *      }
         *  }
         *  else
         *      Console.WriteLine("List is Empty.");
         * } */

        public void displayBotChampions(ChampionListDto displayBotChampions)
        {
            int ndx = 0;
            // Determines if the list is empty.
            bool isEmpty = false;

            if (displayBotChampions.champions == null)
            {
                isEmpty = true;
            }

            if (!isEmpty)
            {
                Console.WriteLine("Displaying Bot Roster enabled for Custom Games");

                for (ndx = 0; ndx < displayBotChampions.champions.Count(); ndx++)
                {
                    if (displayBotChampions.champions[ndx].botEnabled)
                    {
                        Console.WriteLine(displayBotChampions.champions[ndx].id);
                    }
                }
            }
            else
            {
                Console.WriteLine("List is empty");
            }
        }
Exemplo n.º 2
0
        /*****************************************************************
        * Method Name: void displayActiveRoster(ChampionObject)
        * Arguements: displayName
        * Purpose: Displays all current champions that are active in game.
        *****************************************************************/
        public void displayActiveRoster(ChampionListDto championList, ChampionListDTO championListDTO)
        {
            // Determines if the list is empty.
            bool   isEmpty     = false;
            int    code        = 0;
            string whyItFailed = "";

            if (championList == null)
            {
                isEmpty = true;
            }

            championList.getErrorCode(ref code, ref whyItFailed);

            if (championListDTO == null)
            {
                isEmpty = true;
            }

            if ((int)code == 200) // Success!
            {
                if (!isEmpty)
                {
                    foreach (var champion in championListDTO.data)
                    {
                        Console.WriteLine("Name: {0} - ID: {1} ", champion.Key, champion.Value.id);
                    }
                }
                else
                {
                    Console.WriteLine("List is empty.");
                }
            }
            else // Failed!
            {
                Console.WriteLine("-- Failed --");
                Console.WriteLine("Error Code: " + code);
                Console.WriteLine("Reason: " + whyItFailed);
            }

            return;
        }
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: ChampionObject myChamp.
         * Purpose: Calls Riot Servers to grab list of champions currently active in League of Legends.
         * PreConditions: Assumes that API Key and Region have been set to desired location.
         * PostConditions: Fills current object with JSON parsed data.
         *****************************************************************************************/
        public void MakeCall(ref ChampionListDto championList)
        {
            WebRequest request_champ_stream;
            string     responseFromServer;
            string     temp    = requestUrl_champions_v1_2 + api_Key;
            string     API_URL = "";

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

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

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

                // 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
                championList = JsonConvert.DeserializeObject <ChampionListDto>(responseFromServer);

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

                championList.setErrorCode(200, "Success");

                errorResponse = false;
            }

            // Determines if the call failed.
            catch (WebException e)
            {
                championList.setErrorCode((int)e.Status, e.Message);

                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);
            }
        }