/// <summary> /// Validates target position /// </summary> /// <param name="position">Target position</param> public void ValidatesTargetPosition(Position origin, Position target) { Piece piece = Board.Piece(origin); if (!piece.CanMove(target)) { throw new BoardException("Target position is invalid"); } bool[,] movements = piece.PossibleMovements(); for (int i = 0; i < Board.Rows; i++) { for (int j = 0; j < Board.Columns; j++) { if (movements[i, j] == true && (target.Row == i && target.Column == j)) { return; } } } throw new BoardException("Target position is invalid"); }