-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Discontinuous Mercury Rule + Misc. behind the scenes changes (#739)
* Fixed Short Truth Table case rule bug (#707) * Revert "Bugfix 549 (#682)" This reverts commit 5048ee6. * Case rule test fix (#705) Co-authored-by: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com> * Rapid fix for STT case rules Case rules broke at some point from legacy code or merge conflict. Provided is a quick fix in CaseRule and CaseRule_Generic * Revert "Revert "Bugfix 549 (#682)"" (#706) This reverts commit e9fe310. --------- Co-authored-by: Chase-Grajeda <chase.grajeda@gmail.com> Co-authored-by: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com> * Starting work on thermometer class * Added Vial Class Added the vial class which will be helpful for checking rules down the line * Discontinuous Mercury Rule added Added the Discontinuous Mercury contradiciton rule. Added variables to the ThermometerBoard class to keep track of the numbers on the perimiter of the board as well as accessors/setters for these variables. Rewrote a section of the Vials code to make sure cells are added correctly as well as added some accessor functions. --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Chase-Grajeda <chase.grajeda@gmail.com> Co-authored-by: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com> Co-authored-by: Fuzzabee <63023750+Fuzzabee@users.noreply.github.com>
- Loading branch information
1 parent
34ace55
commit d0805d4
Showing
3 changed files
with
179 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...in/java/edu/rpi/legup/puzzle/thermometer/rules/DiscontinuousMercuryContradictionRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package edu.rpi.legup.puzzle.thermometer.rules; | ||
|
||
import edu.rpi.legup.model.gameboard.Board; | ||
import edu.rpi.legup.model.gameboard.PuzzleElement; | ||
import edu.rpi.legup.model.rules.ContradictionRule; | ||
import edu.rpi.legup.puzzle.thermometer.ThermometerBoard; | ||
import edu.rpi.legup.puzzle.thermometer.ThermometerCell; | ||
import edu.rpi.legup.puzzle.thermometer.elements.Vial; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class DiscontinuousMercuryContradictionRule extends ContradictionRule{ | ||
|
||
private final String NO_CONTRADICTION_MESSAGE = "Does not contain a contradiction at this index"; | ||
private final String INVALID_USE_MESSAGE = "Contradiction must be a vial"; | ||
|
||
public DiscontinuousMercuryContradictionRule() { | ||
super("DiscontinuousMercury", | ||
"Discontinuous Mercury", | ||
"A vial has a filled cell after an empty or blocked cell", | ||
null); | ||
} | ||
|
||
|
||
//User can click on any cell in a vial with a discontinuous flow | ||
@Override | ||
public String checkContradictionAt(Board board, PuzzleElement puzzleElement) { | ||
//useful variables | ||
ThermometerBoard thermometerBoard = (ThermometerBoard) board; | ||
|
||
ThermometerCell cell = (ThermometerCell) thermometerBoard.getPuzzleElement(puzzleElement); | ||
|
||
ArrayList<Vial> vials = thermometerBoard.getVials(); | ||
|
||
//finding out which vial contains the specified cell | ||
for (int i = 0; i < vials.size(); i++) { | ||
Vial vial = vials.get(i); | ||
//if a vial contains the clicked on cell | ||
//checking if the vial has a break in the flow | ||
if(vial.containsCell(cell)){ | ||
if(vial.continuousFlow()){ | ||
return super.getNoContradictionMessage() + ": " + this.NO_CONTRADICTION_MESSAGE; | ||
} | ||
else{ | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
//if none of the vials contain the clicked on cell yell at user | ||
return super.getInvalidUseOfRuleMessage() + ": " + this.INVALID_USE_MESSAGE; | ||
} | ||
} |