Example #1
0
        public LoadAndChooseWindow()
        {
            InitializeComponent();
            pokemonCollection  = new PokemonCollection();
            pokemonCollection2 = new PokemonCollection();

            string[] types = Enum.GetNames(typeof(PokemonType));
            cbTypes1.ItemsSource = types;
            cbTypes2.ItemsSource = types;
        }
Example #2
0
 public ActionResult Index()
 {
     using (var webClient = new WebClient())
     {
         //get a string representation of our JSON
         String rawJSON = webClient.DownloadString("https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json");
         //convert the JSON string to a series of objects
         PokemonCollection pokemonCollection = JsonConvert.DeserializeObject <PokemonCollection>(rawJSON);
         return(View(pokemonCollection));
     }
 }
Example #3
0
        public static void GetAllPokemon(HttpClient client)
        {
            var allPokemonResp         = client.GetAsync("pokemon").Result;
            PokemonCollection pokemons = allPokemonResp.Content.ReadAsAsync <PokemonCollection>().Result;

            foreach (var pokemon in pokemons.Results)
            {
                Console.WriteLine($"->> {pokemon.name}");
            }

            Console.ReadLine();
        }
        /*******************************
        * CatchEmAll()
        *******************************/
        public static void CatchEmAll(HttpClient client)
        {
            HttpResponseMessage allPokemonResp = client.GetAsync("pokemon").Result;
            PokemonCollection   catchEmAll     = allPokemonResp.Content.ReadAsAsync <PokemonCollection>().Result;
            bool keepCatching = true;

            while (keepCatching)
            {
                Console.Clear();

                foreach (var pokemon in catchEmAll.Results)
                {
                    Console.WriteLine(pokemon.name.ToUpper());
                }

                var pageMovement = Extras.WriteRead(
                    "\n (N)ext page |"
                    + "(P)revious page |"
                    + "(G)et Details |"
                    + "(E)xit: ").ToUpper();

                switch (pageMovement)
                {
                case "N":
                    catchEmAll = catchEmAll.GetNext(client);
                    break;

                case "P":
                    catchEmAll = catchEmAll.GetPrevious(client);
                    break;

                case "G":
                    GetSinglePokemon(client);
                    keepCatching = false;
                    break;

                default:
                    Extras.Menu();
                    keepCatching = false;
                    break;
                }
            }
        }
Example #5
0
        public ActionResult PokemonDetail(FormCollection id)
        {
            using (var webClient = new WebClient())
            {
                //get a string representation of our JSON
                String rawJSON = webClient.DownloadString("https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json");
                //convert the JSON string to a series of objects
                PokemonCollection pokemonCollection = JsonConvert.DeserializeObject <PokemonCollection>(rawJSON);
                ViewBag.Id = id["idPokemon"];
                ViewBag.Id = Convert.ToInt32(ViewBag.Id);
                ViewBag.Id = ViewBag.Id - 1;
                var currentPokemon = pokemonCollection.Pokemon[ViewBag.Id];

                //Logic for finding Evolution tree
                try
                {
                    //Pokemon has a previous evolution
                    var hasPrevious = currentPokemon.prev_evolution[0];
                    try
                    {
                        //It has a previous evolution and a next evolution, in total : 3 evolutions and the selected is the middle evolution
                        var hasNext = currentPokemon.next_evolution[0];

                        ViewBag.First  = hasPrevious;
                        ViewBag.Second = currentPokemon;
                        ViewBag.Third  = hasNext;

                        //Status for rendering view
                        ViewBag.OnlyStatus      = false;
                        ViewBag.TwoEvolutions   = false;
                        ViewBag.ThreeEvolutions = true;
                    }
                    catch
                    {
                        //It doesn't have a next evolution, therefor it is the last of two evolutions
                        ViewBag.First  = hasPrevious;
                        ViewBag.Second = currentPokemon;


                        ViewBag.OnlyStatus      = false;
                        ViewBag.TwoEvolutions   = true;
                        ViewBag.ThreeEvolutions = false;
                    }
                }
                catch
                {
                    //First pokemon in the evolution tree
                    try
                    {
                        //And it has more evolutions
                        int count = 0;
                        for (var i = 0; i < currentPokemon.next_evolution.Length; i++)
                        {
                            count++;
                        }

                        if (count == 2)
                        {
                            //2 more evolutions to be spesific
                            ViewBag.First           = currentPokemon;
                            ViewBag.Second          = currentPokemon.next_evolution[0];
                            ViewBag.Third           = currentPokemon.next_evolution[1];
                            ViewBag.OnlyStatus      = false;
                            ViewBag.TwoEvolutions   = false;
                            ViewBag.ThreeEvolutions = true;
                        }
                        else
                        {
                            //One more evolution to be specific
                            ViewBag.First  = currentPokemon;
                            ViewBag.Second = currentPokemon.next_evolution[0];

                            ViewBag.OnlyStatus      = false;
                            ViewBag.TwoEvolutions   = true;
                            ViewBag.ThreeEvolutions = false;
                        }
                    }
                    catch
                    {
                        //Only one pokemon, no evolution
                        ViewBag.OnlyStatus      = true;
                        ViewBag.TwoEvolutions   = false;
                        ViewBag.ThreeEvolutions = false;
                    }
                }

                return(View(pokemonCollection));
            }
        }
Example #6
0
        public static void PokeApp()
        {
            bool runAgain = true;

            while (runAgain)
            {
                Console.WriteLine("Press 1 to see a list of all Pokemon");
                Console.WriteLine("Press 2 to see details of a Pokemon");
                Console.WriteLine("Press 3 to see a list of all Games");
                Console.WriteLine("Press 4 to see details of a Game");
                Console.WriteLine("Press 5 to see a list of all Items");
                Console.WriteLine("Press 6 to see details of an Item");
                Console.WriteLine("Press 9 to exit");
                var input = Console.ReadLine();

                switch (input)
                {
                case "1":
                    Console.Clear();
                    var allPokemonResponse       = client.GetAsync("pokemon").Result;
                    PokemonCollection allPokemon = allPokemonResponse.Content.ReadAsAsync <PokemonCollection>().Result;

                    bool question = true;
                    while (question == true)
                    {
                        foreach (var pokemon in allPokemon.Results)
                        {
                            Console.WriteLine(pokemon.name);
                        }

                        var answer = Read("Press 9 for the next page, 1 for the previous page or 0 to return to the menu");
                        switch (answer)
                        {
                        case "1":
                            allPokemon = allPokemon.GetPrevious(client);
                            break;

                        case "9":
                            allPokemon = allPokemon.GetNext(client);
                            break;

                        default:
                            question = false;
                            break;
                        }
                    }
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                    break;

                case "2":
                    Console.Clear();
                    var thisPoke = GetPokemon(Read("Enter name or Id of Pokemon"));
                    Console.WriteLine();
                    Console.WriteLine(thisPoke.name);
                    Console.WriteLine(thisPoke.height);
                    Console.WriteLine(thisPoke.weight);
                    foreach (var move in thisPoke.moves)
                    {
                        Console.WriteLine($"{move.move.name}");
                    }
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                    break;

                case "3":
                    Console.Clear();
                    var allGameResponse       = client.GetAsync("generation").Result;
                    PokemonCollection allGame = allGameResponse.Content.ReadAsAsync <PokemonCollection>().Result;
                    foreach (var game in allGame.Results)
                    {
                        Console.WriteLine(game.name);
                    }

                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                    break;

                case "4":
                    Console.Clear();
                    var thisGame = GetGame(Read("Enter name or Id of Game"));
                    Console.WriteLine(thisGame.name);
                    foreach (var name in thisGame.names)
                    {
                        Console.WriteLine($"{name.language.name}");
                    }
                    Console.WriteLine(thisGame.version_groups);
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                    break;

                case "5":
                    Console.Clear();
                    var allItemResponse       = client.GetAsync("item").Result;
                    PokemonCollection allItem = allItemResponse.Content.ReadAsAsync <PokemonCollection>().Result;
                    foreach (var item in allItem.Results)
                    {
                        Console.WriteLine(item.name);
                    }
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                    break;

                case "6":
                    Console.Clear();
                    var thisItem = GetItem(Read("Enter name or Id of Item"));
                    Console.WriteLine(thisItem.Name);
                    Console.WriteLine(thisItem.AttributeName);
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                    break;

                default:
                    runAgain = false;
                    break;
                }
            }
        }
Example #7
0
 public static void PokemonList()
 {
     var allPokemonResponse       = client.GetAsync("pokemon").Result;
     PokemonCollection allPokemon = allPokemonResponse.Content.ReadAsAsync <PokemonCollection>().Result;
 }