Skip to content

Commit

Permalink
Update Exporter (#627)
Browse files Browse the repository at this point in the history
* Update Exporter

* Delete Test_Save

---------

Co-authored-by: Charles Tian <[email protected]>
  • Loading branch information
ThisMatt and charlestian23 authored Oct 6, 2023
1 parent 145e316 commit b603f1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormat
if (x >= width || y >= height) {
throw new InvalidFileFormatException("TreeTent Factory: cell location out of bounds");
}
if (value < 0 || value > 3) {
if (value < 0 || value > width) {
throw new InvalidFileFormatException("TreeTent Factory: cell unknown value");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) {
}

org.w3c.dom.Element boardElement = newDocument.createElement("board");
boardElement.setAttribute("width", String.valueOf(board.getWidth()));
boardElement.setAttribute("height", String.valueOf(board.getHeight()));
boardElement.setAttribute("size", String.valueOf(board.getWidth()));

org.w3c.dom.Element cellsElement = newDocument.createElement("cells");
for (PuzzleElement puzzleElement : board.getPuzzleElements()) {
Expand All @@ -37,20 +36,20 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) {

org.w3c.dom.Element axisEast = newDocument.createElement("axis");
axisEast.setAttribute("side", "east");
for (SkyscrapersClue clue : board.getEastClues()) {
for (int i=0; i<board.getWidth(); i++) {
org.w3c.dom.Element clueElement = newDocument.createElement("clue");
clueElement.setAttribute("value", String.valueOf(clue.getData()));
clueElement.setAttribute("index", SkyscrapersClue.colNumToString(clue.getIndex()));
clueElement.setAttribute("value", String.valueOf(board.getEastClues().get(i).getData()));
clueElement.setAttribute("index", String.valueOf(board.getWestClues().get(i).getData()));
axisEast.appendChild(clueElement);
}
boardElement.appendChild(axisEast);

org.w3c.dom.Element axisSouth = newDocument.createElement("axis");
axisSouth.setAttribute("side", "south");
for (SkyscrapersClue clue : board.getSouthClues()) {
for (int i=0; i<board.getWidth(); i++) {
org.w3c.dom.Element clueElement = newDocument.createElement("clue");
clueElement.setAttribute("value", String.valueOf(clue.getData()));
clueElement.setAttribute("index", String.valueOf(clue.getIndex()));
clueElement.setAttribute("value", String.valueOf(board.getSouthClues().get(i).getData()));
clueElement.setAttribute("index", String.valueOf(board.getNorthClues().get(i).getData()));
axisSouth.appendChild(clueElement);
}
boardElement.appendChild(axisSouth);
Expand Down

0 comments on commit b603f1a

Please sign in to comment.