Skip to content

Commit

Permalink
Thermometer (#807)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Fuzzabee authored Apr 16, 2024
1 parent bf4dcaa commit 9b4d581
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
10 changes: 5 additions & 5 deletions puzzles files/thermometer/therm_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
<vial headx="1" heady="2" tailx="1" taily="3"/>
</vials>
<rowNumbers>
<row value="3"/>
<row value="2"/>
<row value="2"/>
<row value="4"/>
<row value="2"/>
<row value="1"/>
</rowNumbers>
<colNumbers>
<col value="3"/>
<col value="2"/>
<col value="2"/>
<col value="4"/>
<col value="2"/>
<col value="1"/>
</colNumbers>
</board>
</puzzle>
</Legup>
</Legup>
18 changes: 18 additions & 0 deletions src/main/java/edu/rpi/legup/puzzle/thermometer/Thermometer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,41 @@ 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);
boardView.setBoard(currentBoard);
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) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ protected org.w3c.dom.Element createBoardElement(Document newDocument) {
ArrayList<ThermometerVial> 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()));
Expand All @@ -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<ThermometerCell> 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");
Expand All @@ -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<ThermometerCell> colNumbers = board.getColNumbers();
for (ThermometerCell cell : colNumbers) {
int number = cell.getRotation();
Expand Down

0 comments on commit 9b4d581

Please sign in to comment.