Skip to content

Commit

Permalink
Tested for bug
Browse files Browse the repository at this point in the history
made a variety of tests to try and find source of bug
  • Loading branch information
TreeSnowFence committed Jun 29, 2024
1 parent f49f9a6 commit 798a857
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void mouseReleased(MouseEvent e) {
System.out.printf(
"selected Element is NOT null, attempting to change board at (%d, %d)\n",
scaledPoint.x, scaledPoint.y);

// System.out.println("Before: " + b.getCell(scaledPoint.x,
// scaledPoint.y).getData());
b.setCell(scaledPoint.x, scaledPoint.y, this.selectedElement, e);
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/edu/rpi/legup/history/EditDataCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ public String getErrorString() {
return CommandError.UNMODIFIABLE_BOARD.toString();
} else {
if (!board.getPuzzleElement(selectedPuzzleElement).isModifiable()) {
return CommandError.UNMODIFIABLE_DATA.toString();

selectedPuzzleElement.setModifiable(false);

if(!board.getPuzzleElement(selectedPuzzleElement).isModifiable()) {
return "BYE\n";//CommandError.UNMODIFIABLE_DATA.toString();
}
}
}
} else {
Expand All @@ -123,7 +128,11 @@ public String getErrorString() {
return CommandError.UNMODIFIABLE_BOARD.toString();
} else {
if (!board.getPuzzleElement(selectedPuzzleElement).isModifiable()) {
return CommandError.UNMODIFIABLE_DATA.toString();
selectedPuzzleElement.setModifiable(false);

if(!board.getPuzzleElement(selectedPuzzleElement).isModifiable()) {
return CommandError.UNMODIFIABLE_DATA.toString();
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/edu/rpi/legup/model/gameboard/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public int getElementCount() {
* @return puzzle elements on the board
*/
public List<PuzzleElement> getPuzzleElements() {
return puzzleElements;
List<PuzzleElement> puzzleCopy = new ArrayList<>();
puzzleCopy.addAll(puzzleElements);
return puzzleCopy;
}

/**
Expand All @@ -95,6 +97,7 @@ public boolean isModifiable() {
* @param isModifiable true if the board is modifiable, false otherwise
*/
public void setModifiable(boolean isModifiable) {
//println("HEY, THE MODIFIABLILITY OF AN ELEMENT IS CHANGING");
this.isModifiable = isModifiable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ public boolean isModifiable() {
* @param isModifiable true if this puzzle element is modifiable, false otherwise
*/
public void setModifiable(boolean isModifiable) {
this.isModifiable = isModifiable;
if(this.data.equals(0)){
this.isModifiable = true;
}
else {
this.isModifiable = isModifiable;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ public String getErrorString() {
(TreeTentCell) end.getPuzzleElement());
for (TreeTentLine l : board.getLines()) {
if (line.compare(l) && !l.isModifiable()) {
return CommandError.UNMODIFIABLE_DATA.toString();
l.setModifiable(false);;
if(!l.isModifiable()) {
return CommandError.UNMODIFIABLE_DATA.toString();
}
}
}

Expand Down

0 comments on commit 798a857

Please sign in to comment.