Пример #1
0
        public Player game()
        {
            while (!ischeckMated() && !isStaleMated())
            {
                if (isWhiteMove)
                {
                    Console.WriteLine("White Plays the move \n");
                }
                else
                {
                    Console.WriteLine("Black Plays the move \n");
                }
                int Sx, Sy, Dx, Dy;
                Sx = Convert.ToInt32(Console.ReadLine());
                Sy = Convert.ToInt32(Console.ReadLine());
                Dx = Convert.ToInt32(Console.ReadLine());
                Dy = Convert.ToInt32(Console.ReadLine());

                bool isValid = false;
                if (isWhiteMove)
                {
                    isValid = WPlayer.move(Dx, Dy, chessboard.getPiece(Sx, Sy), chessboard.getPiece(Dx, Dy), chessboard);
                }
                else
                {
                    isValid = WPlayer.move(Dx, Dy, chessboard.getPiece(Sx, Sy), chessboard.getPiece(Dx, Dy), chessboard);
                }
                if (isValid)
                {
                    isWhiteMove = !isWhiteMove;
                }
            }
            return(isWhiteMove ? BPlayer : WPlayer);
        }