@Override public ArrayList<Move> getMoves(Board board) { ArrayList<Move> movesList = new ArrayList<Move>(); Location newLocation = null; Location currentLocation = board.getLocation(this); char column = currentLocation.getCharacter(); int row = currentLocation.getInteger(); int boardLength = 8; // Down Left for (int i = 1; i < boardLength; i++) { newLocation = new Location((char) (column - i), (row - i)); if (board.isValidSquare(newLocation)) { Piece p = board.getPiece(newLocation); if (p != null && p.getColor() != this.getColor()) { movesList.add(new Move(currentLocation, newLocation)); } else if (p == null) { movesList.add(new Move(currentLocation, newLocation)); } if (pathIsObstructed(board, currentLocation, newLocation)) break; } } // Down Right for (int i = 1; i < boardLength; i++) { newLocation = new Location((char) (column + i), (row - i)); if (board.isValidSquare(newLocation)) { Piece p = board.getPiece(newLocation); if (p != null && p.getColor() != this.getColor()) { movesList.add(new Move(currentLocation, newLocation)); } else if (p == null) { movesList.add(new Move(currentLocation, newLocation)); } if (pathIsObstructed(board, currentLocation, newLocation)) break; } } // Up Left for (int i = 1; i < boardLength; i++) { newLocation = new Location((char) (column - i), (row + i)); if (board.isValidSquare(newLocation)) { Piece p = board.getPiece(newLocation); if (p != null && p.getColor() != this.getColor()) { movesList.add(new Move(currentLocation, newLocation)); } else if (p == null) { movesList.add(new Move(currentLocation, newLocation)); } if (pathIsObstructed(board, currentLocation, newLocation)) break; } } // Up Right for (int i = 1; i < boardLength; i++) { newLocation = new Location((char) (column + i), (row + i)); if (board.isValidSquare(newLocation)) { Piece p = board.getPiece(newLocation); if (p != null && p.getColor() != this.getColor()) { movesList.add(new Move(currentLocation, newLocation)); } else if (p == null) { movesList.add(new Move(currentLocation, newLocation)); } if (pathIsObstructed(board, currentLocation, newLocation)) break; } } return movesList; }