From 9b4d5811821196569a341714b5c0e4f395ab2e26 Mon Sep 17 00:00:00 2001 From: Fuzzabee <63023750+Fuzzabee@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:45:08 -0400 Subject: [PATCH] Thermometer (#807) * Found bug in name of ThermometerTooLarge.png which was throwing errors and not showing up in LEGUP. * Added documentation comments to rules * Updated controller to have correct mouse buttons as well as added debug info with middle mouse. Cleaned up a few methods in TheremomterCell as well. * Fixed ThermomterExporter to allow saving to write correctly to file. * Updated therm_text.xml as row/col was reversed. Also updated some comments on Thermometer and ThermometerExporter --- puzzles files/thermometer/therm_test.xml | 10 +++++----- .../legup/puzzle/thermometer/Thermometer.java | 18 ++++++++++++++++++ .../thermometer/ThermometerExporter.java | 9 ++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/puzzles files/thermometer/therm_test.xml b/puzzles files/thermometer/therm_test.xml index a14539030..66e841dc5 100644 --- a/puzzles files/thermometer/therm_test.xml +++ b/puzzles files/thermometer/therm_test.xml @@ -11,17 +11,17 @@ - - + + + + - - - \ No newline at end of file + diff --git a/src/main/java/edu/rpi/legup/puzzle/thermometer/Thermometer.java b/src/main/java/edu/rpi/legup/puzzle/thermometer/Thermometer.java index c0e5b1a0e..40c8a8461 100644 --- a/src/main/java/edu/rpi/legup/puzzle/thermometer/Thermometer.java +++ b/src/main/java/edu/rpi/legup/puzzle/thermometer/Thermometer.java @@ -13,6 +13,7 @@ public Thermometer() { this.exporter = new ThermometerExporter(this); } + /** Initializes the game board. Called by the invoker of the class */ @Override public void initializeView() { boardView = new ThermometerView((ThermometerBoard) currentBoard); @@ -20,16 +21,33 @@ public void initializeView() { addBoardListener(boardView); } + /** + * Generates a random edu.rpi.legup.puzzle based on the difficulty + * + * @param difficulty level of difficulty (1-10) + * @return board of the random edu.rpi.legup.puzzle + */ @Override public Board generatePuzzle(int difficulty) { return null; } + /** + * Determines if the current board is a valid state + * + * @param board board to check for validity + * @return true if board is valid, false otherwise + */ @Override public boolean isBoardComplete(Board board) { return true; } + /** + * Callback for when the board puzzleElement changes + * + * @param board the board that has changed + */ @Override public void onBoardChange(Board board) { } diff --git a/src/main/java/edu/rpi/legup/puzzle/thermometer/ThermometerExporter.java b/src/main/java/edu/rpi/legup/puzzle/thermometer/ThermometerExporter.java index 1085c7ad7..76da2b8bf 100644 --- a/src/main/java/edu/rpi/legup/puzzle/thermometer/ThermometerExporter.java +++ b/src/main/java/edu/rpi/legup/puzzle/thermometer/ThermometerExporter.java @@ -26,7 +26,8 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { ArrayList vials = board.getVials(); for (ThermometerVial vial : vials) { org.w3c.dom.Element vialElement = newDocument.createElement("vial"); - // Temp for now, waiting on final implementation of vial + // The way the vials are created are with the head (bulb) position and the final position + // This implementation doesn't allow for curved thermometers, but for right now that's fine vialElement.setAttribute("headx", String.valueOf((int) vial.getHead().getLocation().getX())); vialElement.setAttribute("heady", String.valueOf((int) vial.getHead().getLocation().getY())); vialElement.setAttribute("tailx", String.valueOf((int) vial.getTail().getLocation().getX())); @@ -37,8 +38,9 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { // Creating the XML section for the row numbers and appending to the board org.w3c.dom.Element rowNumbersElement = newDocument.createElement("rowNumbers"); - //when time available change to expect arraylist of gridcells ArrayList rowNumbers = board.getRowNumbers(); + // The row numbers are the numbers on the right most column, labeling how many filled sections + // are in the row for (ThermometerCell cell : rowNumbers) { int number = cell.getRotation(); org.w3c.dom.Element rowNumberElement = newDocument.createElement("row"); @@ -49,7 +51,8 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) { // Creating the XML section for the col numbers and appending ot the board org.w3c.dom.Element colNumbersElement = newDocument.createElement("colNumbers"); - //when time available change to expect arraylist of gridcells + // The col numbers are the numbers on the bottom row, labeling how many filled sections + // are in the column ArrayList colNumbers = board.getColNumbers(); for (ThermometerCell cell : colNumbers) { int number = cell.getRotation();