Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team Thermometers final merge #816

Merged
merged 72 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
e87240a
Layout of project
ZevCe Jan 30, 2024
0642d1c
Added Mercury or Blocked case rule and updated ThermometerController …
Fuzzabee Feb 6, 2024
c2ab8d9
Starting work on thermometer class
ZevCe Feb 13, 2024
ca7de69
Added Vial Class
ZevCe Feb 14, 2024
f398795
Thermometer (#735)
ZevCe Feb 14, 2024
8c4ebc8
Merge remote-tracking branch 'upstream/master' into thermometer
ZevCe Feb 19, 2024
07b85cd
Discontinuous Mercury Rule added
ZevCe Feb 19, 2024
34ace55
Thermometer (#738)
morenomarcus03 Feb 19, 2024
898add4
Merge remote-tracking branch 'upstream/master' into thermometer
ZevCe Feb 22, 2024
e03c923
Merge branch 'thermometer' of https://github.com/ZevCe/LEGUP into the…
ZevCe Feb 22, 2024
678da44
Merge branch 'thermometer' into thermometer
Fuzzabee Feb 27, 2024
d0805d4
Discontinuous Mercury Rule + Misc. behind the scenes changes (#739)
ZevCe Feb 27, 2024
5c98783
Thermometer too many/few mercury (#747)
morenomarcus03 Feb 27, 2024
b1e738a
Merge branch 'thermometer' of https://github.com/ZevCe/LEGUP into the…
ZevCe Feb 27, 2024
caeeef4
Importer written
ZevCe Mar 1, 2024
43d1305
small bug fixes
ZevCe Mar 1, 2024
7b56d45
Added outlines of Finish...WithEmptyDirectRule and RestIsEmptyDirectR…
Fuzzabee Mar 1, 2024
aef3d32
Uploading test xml file for eventual testing
Fuzzabee Mar 1, 2024
cd124ea
Added Puzzle Factory and Importer
ZevCe Mar 12, 2024
68fa815
Thermometer Importer Functionality + Thermometer Puzzle Factory (#756)
ZevCe Mar 12, 2024
f37a834
Started Exported and added to ThermometerBoard access to row and col …
Fuzzabee Mar 14, 2024
31ee7e6
Merge branch 'thermometer' into thermometer
Fuzzabee Mar 14, 2024
6cb8300
Adding ThermometerExporter.java and therm_test.xml (#759)
Fuzzabee Mar 14, 2024
e952533
Merge remote-tracking branch 'upstream/master' into thermometer
ZevCe Mar 15, 2024
fea9223
Delete ThermometerExporter.java
ZevCe Mar 15, 2024
20a4b4d
Merge remote-tracking branch 'upstream/thermometer' into thermometer
ZevCe Mar 15, 2024
cce8ee5
Added Thermometer to Config file
ZevCe Mar 15, 2024
11179a8
Quick Config File change (#761)
ZevCe Mar 15, 2024
1fdc396
Added necessary code to constructor
ZevCe Mar 15, 2024
f9fc1f5
Merge remote-tracking branch 'upstream/thermometer' into thermometer
ZevCe Mar 15, 2024
744df30
Messing with Rule Recognition
ZevCe Mar 15, 2024
fc95133
Retrofit because I forgot to merge for two weeks (#764)
morenomarcus03 Mar 15, 2024
68b4f20
Merge remote-tracking branch 'upstream/thermometer' into thermometer
ZevCe Mar 15, 2024
a62ec86
Fixing desyncs in repo
ZevCe Mar 19, 2024
d285afa
More syncing and organizing files
ZevCe Mar 19, 2024
6e6a479
Thermometer (#766)
ZevCe Mar 19, 2024
cba0779
Small misc improvements
ZevCe Mar 19, 2024
0771835
Fixed verify vial method
ZevCe Mar 19, 2024
ae7359c
Merge branch 'thermometer' into thermometer
Fuzzabee Mar 20, 2024
8c6b96e
Various thermometer fixes (#767)
ZevCe Mar 20, 2024
c74d877
More work towards visual display
ZevCe Mar 22, 2024
b7f906a
Merge branch 'thermometer' of https://github.com/ZevCe/LEGUP into the…
ZevCe Mar 22, 2024
9e2955f
Update ThermometerElementView.java
ZevCe Mar 26, 2024
3adeea9
Merge branch 'thermometer' into thermometer
ZevCe Mar 26, 2024
1a9785a
Unfinished thermometer updates (#772)
ZevCe Mar 26, 2024
54b4d3c
Thermometer (#773)
morenomarcus03 Mar 26, 2024
af47353
Merge remote-tracking branch 'upstream/thermometer' into thermometer
ZevCe Mar 26, 2024
024778a
Merge branch 'Bram-Hub:thermometer' into thermometer
ZevCe Mar 26, 2024
8a0109b
Merge branch 'thermometer' of https://github.com/ZevCe/LEGUP into the…
ZevCe Mar 26, 2024
f0d07af
Rotating images!!!!!
ZevCe Mar 29, 2024
4c966f4
Thermometer with rotating images!!!! (#782)
ZevCe Mar 29, 2024
2a3aae6
Added in placeable elements
ZevCe Mar 29, 2024
997b7b4
Stabilizing bug fixes
ZevCe Apr 2, 2024
d9f9a4b
Import silliness
ZevCe Apr 2, 2024
2394d17
Bug fixes for the Thermometer Bug Fixes (#794)
ZevCe Apr 2, 2024
63026ac
Final Images + Rule file expansion pack (#795)
morenomarcus03 Apr 5, 2024
90f386d
Thermometer Cleanup and debugging
ZevCe Apr 5, 2024
6dd3791
Merge branch 'pr/797' into thermometer
Chase-Grajeda Apr 5, 2024
3381603
Major Bug Fix (#798)
morenomarcus03 Apr 5, 2024
cfd5a7f
Working row/col numbers (#799)
ZevCe Apr 12, 2024
bf4dcaa
Thermometer (#801)
Fuzzabee Apr 12, 2024
9b4d581
Thermometer (#807)
Fuzzabee Apr 16, 2024
dcb9573
Last minute comments (#810)
ZevCe Apr 16, 2024
2c7f9d4
Final Marcus pull (#814)
morenomarcus03 Apr 16, 2024
0d36dac
Merge branch 'dev' into thermometer
morenomarcus03 Apr 16, 2024
fe7f2f8
Merge branch 'dev' into thermometer
charlestian23 Apr 16, 2024
e258634
Automated Java code formatting changes
Bram28 Apr 16, 2024
8d4287e
Merge branch 'dev' into thermometer
charlestian23 May 5, 2024
c4b740b
Automated Java code formatting changes
Bram28 May 5, 2024
2bf9790
Merge branch 'dev' into thermometer
charlestian23 May 5, 2024
1e3821e
Merge branch 'dev' into thermometer
charlestian23 May 5, 2024
9c18e9c
Update config
charlestian23 May 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions puzzles files/thermometer/therm_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Legup version="5.1.0">
<puzzle name="Thermometer">
<board height="4" width="4">
<vials>
<vial headx="0" heady="0" tailx="2" taily="0"/>
<vial headx="3" heady="0" tailx="3" taily="3"/>
<vial headx="0" heady="1" tailx="1" taily="1"/>
<vial headx="2" heady="1" tailx="2" taily="3"/>
<vial headx="0" heady="3" tailx="0" taily="2"/>
<vial headx="1" heady="2" tailx="1" taily="3"/>
</vials>
<rowNumbers>
<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="2"/>
</colNumbers>
</board>
</puzzle>
</Legup>
56 changes: 56 additions & 0 deletions src/main/java/edu/rpi/legup/puzzle/thermometer/Thermometer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package edu.rpi.legup.puzzle.thermometer;

import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.model.gameboard.Board;

// basically just copy-pasted from dev guide on wiki
public class Thermometer extends Puzzle {
public Thermometer() {
super();

this.name = "Thermometer";

this.importer = new ThermometerImporter(this);
this.exporter = new ThermometerExporter(this);
// we do not have a thermometerCellFactory class as
// thermometerVial has its own thermometerCell factory method
}

/** 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) {}
}
139 changes: 139 additions & 0 deletions src/main/java/edu/rpi/legup/puzzle/thermometer/ThermometerBoard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package edu.rpi.legup.puzzle.thermometer;

import edu.rpi.legup.model.gameboard.GridBoard;
import java.awt.*;
import java.util.ArrayList;

public class ThermometerBoard extends GridBoard {

// an array containing all of our vials on the board
private ArrayList<ThermometerVial> thermometerVials;

// representations of the number requirements along rows and columns of the board
// we use rotation to store the number
private ArrayList<ThermometerCell> colNumbers;
private ArrayList<ThermometerCell> rowNumbers;

private ThermometerCell dummyCell;

// constructors for the boards and variables
public ThermometerBoard(int width, int height) {
super(width, height);

// initializing the row/col number arrays with zeros, so they can be
// easily updated using the setRow/ColNumber functions
colNumbers = new ArrayList<>();
for (int i = 0; i < width - 1; i++) {
ThermometerCell cell =
new ThermometerCell(
new Point(i, height - 1),
ThermometerType.UNKNOWN,
ThermometerFill.UNKNOWN,
0);
cell.setIndex((height - 1) * height + i);
colNumbers.add(cell);
this.setCell(i, height - 1, cell);
}
rowNumbers = new ArrayList<>();
for (int i = 0; i < height - 1; i++) {
ThermometerCell cell =
new ThermometerCell(
new Point(width - 1, i),
ThermometerType.UNKNOWN,
ThermometerFill.UNKNOWN,
0);
cell.setIndex(i * height + (width - 1));
rowNumbers.add(cell);
this.setCell(width - 1, i, cell);
}

// setting a dummy cell so board doesn't have null cells
dummyCell =
new ThermometerCell(
new Point(width - 1, height - 1),
ThermometerType.UNKNOWN,
ThermometerFill.UNKNOWN,
-1);
dummyCell.setIndex((height - 1) * height + width);
this.setCell(width - 1, height - 1, dummyCell);

// creating our empty vial of thermometers to add to
thermometerVials = new ArrayList<>();
}

// setters and accessors for our array of vials
public void addVial(ThermometerVial v) {
thermometerVials.add(v);
}

public ArrayList<ThermometerVial> getVials() {
return thermometerVials;
}

// our setters for row/col numbers with simple input verification
public boolean setRowNumber(int row, int num) {
// first check is to verify we are updating an element in range
// second check is to verify the new number can be achieved by the puzzle
if (row < rowNumbers.size() && num <= colNumbers.size()) {
rowNumbers.get(row).setRotation(num);
return true;
}
return false;
}

public boolean setColNumber(int col, int num) {
// first check is to verify we are updating an element in range
// second check is to verify the new number can be achieved by the puzzle
if (col < colNumbers.size() && num <= rowNumbers.size()) {
colNumbers.get(col).setRotation(num);
return true;
}
return false;
}

// basic accessors for row/col numbers
public int getRowNumber(int row) {
if (row < 0 || row >= rowNumbers.size()) return -1;
return rowNumbers.get(row).getRotation();
}

public int getColNumber(int col) {
if (col < 0 || col >= rowNumbers.size()) return -1;
return colNumbers.get(col).getRotation();
}

// Accessors for saving row/column
public ArrayList<ThermometerCell> getRowNumbers() {
return rowNumbers;
}

public ArrayList<ThermometerCell> getColNumbers() {
return colNumbers;
}

// we all suck at programming so instead of using provided array list
// we use our own array lists to keep track of the vials
// marginally useful because it means we are guaranteed to get a
// thermometer cell when calling get cell, but using some type casting
// this override function could very likely be refactored out
@Override
public ThermometerCell getCell(int x, int y) {
for (ThermometerVial vial : this.thermometerVials) {
for (ThermometerCell cell : vial.getCells()) {
if (cell.getLocation().x == x && cell.getLocation().y == y) return cell;
}
}

for (ThermometerCell cell : rowNumbers) {
if (cell.getLocation().x == x && cell.getLocation().y == y) return cell;
}

for (ThermometerCell cell : colNumbers) {
if (cell.getLocation().x == x && cell.getLocation().y == y) return cell;
}

if (x == this.getWidth() - 1 && y == this.getHeight() - 1) return dummyCell;

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package edu.rpi.legup.puzzle.thermometer;

import edu.rpi.legup.model.gameboard.GridCell;
import java.awt.Point;

public class ThermometerCell extends GridCell<Integer> {

// information about the cell needed to display it
private ThermometerType type;
private ThermometerFill fill;
private int rotation;

public ThermometerCell(Point location, ThermometerType t, ThermometerFill f, int r) {
// since we do not use get/set data value int can be any value
super(1, location);
type = t;
fill = f;
rotation = r;
}

// Note: setdata does not work for our purposes
public void setType(ThermometerType t) {
type = t;
}

public ThermometerType getType() {
return type;
}

public void setFill(ThermometerFill f) {
fill = f;
}

public ThermometerFill getFill() {
return fill;
}

public void setRotation(int r) {
rotation = r;
}

public int getRotation() {
return rotation;
}

@Override
public ThermometerCell copy() {
ThermometerCell copy =
new ThermometerCell((Point) location.clone(), this.type, this.fill, this.rotation);
copy.setIndex(index);
copy.setModifiable(isModifiable);
copy.setGiven(isGiven);
return copy;
}

@Override
public String toString() {
return "("
+ location.getX()
+ ", "
+ location.getY()
+ ") TYPE = "
+ getType()
+ " FILL = "
+ getFill();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package edu.rpi.legup.puzzle.thermometer;

import edu.rpi.legup.controller.ElementController;
import edu.rpi.legup.model.gameboard.PuzzleElement;
import java.awt.event.MouseEvent;

public class ThermometerController extends ElementController {

// method for updating thermometer cells since number cells have unknown for
// their fill type we don't need to worry about end user modifying them with this
@Override
public void changeCell(MouseEvent e, PuzzleElement data) {
ThermometerCell cell = (ThermometerCell) data;

if (e.getButton() == MouseEvent.BUTTON1) {
if (e.isControlDown()) {
this.boardView
.getSelectionPopupMenu()
.show(
boardView,
this.boardView.getCanvas().getX() + e.getX(),
this.boardView.getCanvas().getY() + e.getY());
} else {
if (cell.getFill() == ThermometerFill.EMPTY) {
cell.setFill(ThermometerFill.FILLED);
} else if (cell.getFill() == ThermometerFill.FILLED) {
cell.setFill(ThermometerFill.BLOCKED);
} else {
cell.setFill(ThermometerFill.EMPTY);
}
}
} else if (e.getButton() == MouseEvent.BUTTON3) {
if (cell.getFill() == ThermometerFill.EMPTY) {
cell.setFill(ThermometerFill.BLOCKED);
} else if (cell.getFill() == ThermometerFill.BLOCKED) {
cell.setFill(ThermometerFill.FILLED);
} else {
cell.setFill(ThermometerFill.EMPTY);
}
} else if (e.getButton() == MouseEvent.BUTTON2) {
System.out.println("[DEBUG] " + cell);
}
}
}
Loading
Loading