Exemple #1
0
        public int GetPawnPromotion()
        {
            int chosen = 0;

            while (chosen < 1 || chosen > 4)
            {
                try
                {
                    //Console.Clear();
                    Console.SetCursorPosition(2, 3);
                    Console.WriteLine("Promote pawn to ( choose number between 1 and 4 ):");
                    Console.SetCursorPosition(2, 4);
                    Console.WriteLine("1 - Queen | 2 - Rook | 3 - Bishop | 4 - Knight");
                    Console.SetCursorPosition(2, 5);
                    Console.Write("Your choice - ");
                    chosen = int.Parse(Console.ReadLine());

                    if (chosen < 1 || chosen > 4)
                    {
                        throw new InvalidOperationException();
                    }
                }
                catch (Exception)
                {
                    IRenderer renderer = new ConsoleRenderer();
                    renderer.PrintErrorMessage(ExceptionMessages.NumberOutOfRangeOneToFourException);
                }

                for (int row = 3; row <= 5; row++)
                {
                    ConsoleHelpers.ClearRow(row);
                }
            }

            return(chosen);
        }