Пример #1
0
        /// <summary>
        /// Handles the damage menu
        /// </summary>
        /// <param name="p">Pokemon returned from search</param>
        private static void damageMenu(Pokemon p)
        {
            Console.Clear();
            Console.Write(p);
            Console.WriteLine("--------------------------------------------");
            Console.WriteLine("What kind of damage would you like to do?");
            for (int i = 0; i < (int)Pokemon.Type.None; i++)
            {
                Console.WriteLine((i + 1) + "). " + (Pokemon.Type)i);
            }

            int testType;

            try
            {
                testType = int.Parse(Console.ReadLine());

                if (testType < 0 || testType > 18)
                {
                    throw new IndexOutOfRangeException();
                }

                Console.WriteLine(p.Name + "is affected " + Pokedex.getWeaknessVal(p, (Pokemon.Type)(testType - 1)) + "x by " + ((Pokemon.Type)(testType - 1)).ToString() + " type moves.");
            }
            catch (FormatException)
            {
                Console.Clear();
                Console.WriteLine("That is an invalid input");
            }
            catch (IndexOutOfRangeException)
            {
                Console.Clear();
                Console.WriteLine("Please select a value between 1 and 18");
            }
            finally
            {
                Console.WriteLine("Press Enter to Continue");
                Console.Read();
            }
        }