예제 #1
0
        /// <summary>
        /// get the pokemon object by name
        ///
        /// </summary>
        /// <param name="pokeName"></param>
        /// <param name="baseUrl"></param>
        public static async void GetPokemonByName(string pokeName, string baseUrl)
        {
            #region Getting all the api data
            try
            {
                using (var client = new HttpClient())
                {
                    using (HttpResponseMessage respo = client.GetAsync(baseUrl).Result)
                    {
                        using (HttpContent content = respo.Content)
                        {
                            var data = await content.ReadAsStringAsync();

                            if (data != null)
                            {
                                var dataObj = JObject.Parse(data)["abilities"];


                                poke poke      = JsonConvert.DeserializeObject <poke>(data);
                                var  abilities = poke.abilities.Where(a => a != null).ToList();
                                Console.WriteLine("{0} - Abilities are: ", pokeName);
                                foreach (var item in abilities)
                                {
                                    Console.WriteLine(" * {0,3}", item.ability.name);
                                    GetPokemonAbility(pokeName, item.ability.url);
                                }
                            }
                            else
                            {
                                Console.WriteLine("NO Data----------?");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("OMG we got an Exception ------------------");
                Console.WriteLine(ex);
            }
            #endregion
        }
예제 #2
0
        static void Main()
        {
            poke p1Poke1 = new poke(); //i need pointers
            poke p1Poke2 = new poke();
            poke p1Poke3 = new poke();
            poke p1Poke4 = new poke();
            poke p1Poke5 = new poke();
            poke p1Poke6 = new poke();

            poke p2Poke1 = new poke();
            poke p2Poke2 = new poke();
            poke p2Poke3 = new poke();
            poke p2Poke4 = new poke();
            poke p2Poke5 = new poke();
            poke p2Poke6 = new poke();

            Console.Write("Welcome to the Pokemon Battle Simulator! Please being entering your pokemon." + Environment.NewLine);

            for (int i = 0; i < 6; i++) // a loop to add all the pokemon of a team to the data and switch the read i/o to the appropriate number
            {
                Console.Write("Pokemon " + i + ": ");
                switch (i)
                {
                case 0:
                    p1Poke1 = new poke(Console.ReadLine());
                    break;

                case 1:
                    p1Poke2 = new poke(Console.ReadLine());
                    break;

                case 2:
                    p1Poke3 = new poke(Console.ReadLine());
                    break;

                case 3:
                    p1Poke4 = new poke(Console.ReadLine());
                    break;

                case 4:
                    p1Poke5 = new poke(Console.ReadLine());
                    break;

                case 5:
                    p1Poke6 = new poke(Console.ReadLine());
                    break;
                }
            }

            Console.Write("Now enter the pokemon on your opponent's team: " + Environment.NewLine);

            for (int k = 0; k < 6; k++)
            {
                Console.Write("Pokemon " + k + ": ");
                switch (k)
                {
                case 0:
                    p2Poke1 = new poke(Console.ReadLine());
                    break;

                //dispMon(p1Poke1)
                case 1:
                    p2Poke2 = new poke(Console.ReadLine());
                    break;

                //dispMon(p1Poke1)
                case 2:
                    p2Poke3 = new poke(Console.ReadLine());
                    break;

                //dispMon(p1Poke1)
                case 3:
                    p2Poke4 = new poke(Console.ReadLine());
                    break;

                //dispMon(p1Poke1)
                case 4:
                    p2Poke5 = new poke(Console.ReadLine());
                    break;

                //dispMon(p1Poke1)
                case 5:
                    p2Poke6 = new poke(Console.ReadLine());
                    break;
                    //dispMon(p1Poke1)
                }
            }
            Console.Write("Your Team:" + Environment.NewLine);
            p1Poke1.dispMon();
            p1Poke2.dispMon();
            p1Poke3.dispMon();
            p1Poke4.dispMon();
            p1Poke5.dispMon();
            p1Poke6.dispMon();
            Console.Write(Environment.NewLine);
            Console.Write("Opponent's Team: " + Environment.NewLine);
        }