Skip to content

Commit

Permalink
Merge pull request #201 from Bram-Hub/puzzle-editor-empty-puzzle-impl…
Browse files Browse the repository at this point in the history
…ementations

Nurikabe empty puzzles are now implemented
  • Loading branch information
charlestian23 authored Jul 22, 2022
2 parents fd9a5a9 + 9dd3819 commit 2e08d1f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/java/edu/rpi/legup/puzzle/nurikabe/Nurikabe.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public Board generatePuzzle(int difficulty) {
* @return true if the given dimensions are valid for Nurikabe, false otherwise
*/
public boolean isValidDimensions(int rows, int columns) {
// This is a placeholder, this method needs to be implemented
throw new UnsupportedOperationException();
return rows > 0 && columns > 0;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ public NurikabeImporter(Nurikabe nurikabe) {
*/
@Override
public void initializeBoard(int rows, int columns) {
NurikabeBoard nurikabeBoard = new NurikabeBoard(columns, rows);

for (int y = 0; y < rows; y++) {
for (int x = 0; x < columns; x++) {
NurikabeCell cell = new NurikabeCell(NurikabeType.UNKNOWN.toValue(), new Point(x, y));
cell.setIndex(y * columns + x);
cell.setModifiable(true);
nurikabeBoard.setCell(x, y, cell);
}
}
puzzle.setCurrentBoard(nurikabeBoard);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public void loadPuzzleFromHome(String game, int rows, int columns) throws Illega
throw new IllegalArgumentException(exception.getMessage());
}
catch (RuntimeException e){
e.printStackTrace();
LOGGER.error(e.getMessage());
}
}
Expand Down

0 comments on commit 2e08d1f

Please sign in to comment.