Ejemplo n.º 1
0
        public Move(PieceColor color, BoardPosition initialPosition, BoardPosition endingPosition, bool pieceJumped = false, bool pieceCaptured = false)
        {
            if (initialPosition.ContainsPiece())
            {
                throw new ArgumentException("Move initial posiiton must not contain a piece");
            }

            if (endingPosition.ContainsPiece())
            {
                throw new ArgumentException("Move ending posiiton must not contain a piece");
            }

            if (pieceCaptured && !pieceJumped)
            {
                throw new ArgumentException("Capture moves are required to be configured as a jump move");
            }

            if (!ValidateMove(initialPosition, endingPosition, pieceJumped, pieceCaptured))
            {
                throw new ArgumentException("Invalid move requested");
            }

            this.PieceColor = color;
            this.PieceJumped = pieceJumped;
            this.PieceCaptured = pieceCaptured;
            this.InitialPosition = initialPosition;
            this.EndingPosition = endingPosition;
        }