diff --git a/src/main/java/edu/rpi/legup/controller/ElementController.java b/src/main/java/edu/rpi/legup/controller/ElementController.java index 5840650e1..92f45e80a 100644 --- a/src/main/java/edu/rpi/legup/controller/ElementController.java +++ b/src/main/java/edu/rpi/legup/controller/ElementController.java @@ -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); diff --git a/src/main/java/edu/rpi/legup/history/EditDataCommand.java b/src/main/java/edu/rpi/legup/history/EditDataCommand.java index d65f03d66..bddcbdb55 100644 --- a/src/main/java/edu/rpi/legup/history/EditDataCommand.java +++ b/src/main/java/edu/rpi/legup/history/EditDataCommand.java @@ -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 { @@ -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(); + } } } } diff --git a/src/main/java/edu/rpi/legup/model/gameboard/Board.java b/src/main/java/edu/rpi/legup/model/gameboard/Board.java index d8bdf5199..8bcb59458 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/Board.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/Board.java @@ -68,7 +68,9 @@ public int getElementCount() { * @return puzzle elements on the board */ public List getPuzzleElements() { - return puzzleElements; + List puzzleCopy = new ArrayList<>(); + puzzleCopy.addAll(puzzleElements); + return puzzleCopy; } /** @@ -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; } diff --git a/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java b/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java index 4ce030a04..fa7e63034 100644 --- a/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java +++ b/src/main/java/edu/rpi/legup/model/gameboard/PuzzleElement.java @@ -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; + } } /** diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java index feece58a9..7f0accfd9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/EditLineCommand.java @@ -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(); + } } }