Пример #1
0
        /* Checks if the position FROM is valide\
         * throws GameBoardException
         * @param Position pos
         */
        public void ValidateFromPosition(Position pos)
        {
            Piece p = this.Board.GetPiece(pos);

            if (p == null)
            {
                throw new GameBoardException("There is no piece in the chosen position!");
            }

            if (p.Color != this.CurrentPlayer)
            {
                throw new GameBoardException("The piece chosen is not yours!");
            }

            if (!p.HasPossibleMoves())
            {
                throw new GameBoardException("You cannot move the chosen piece!");
            }
        }