Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisMatt committed Oct 26, 2023
1 parent 2cd2d4b commit 14fe70b
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ public void setValid(boolean isValid) {
*
* @return number of cases
*/
public int getCasesDepended() {return this.casesDepended;}
public int getCasesDepended() { return this.casesDepended; }

/**
* Sets the number of case rules that depend upon the state of this element
*
* @param cases number of cases
*/
public void setCasesDepended(int cases) {this.casesDepended=cases;}
public void setCasesDepended(int cases) { this.casesDepended=cases; }

/**
* Tests whether two puzzle elements objects have the same puzzle element
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/edu/rpi/legup/model/rules/CaseRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public abstract class CaseRule extends Rule {

private final String INVALID_USE_MESSAGE;

//value of the element selected for this instance of the rule
protected PuzzleElement selectedElement;

/**
Expand Down Expand Up @@ -154,7 +153,14 @@ public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleEl

return elements;
}
public PuzzleElement getSelectedElement(){return selectedElement;}

/**
* Returns the last element given to getCases by this instance
* Set by getCases implementation
*
* @return selected PuzzleElement
*/
public PuzzleElement getSelectedElement(){ return selectedElement; }
}


Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ private List<LightUpCell> getAdjacentCells(LightUpBoard board, LightUpCell cell)
return cells;
}

/**
* Returns the elements necessary for the cases returned by getCases(board,puzzleElement) to be valid
* Overridden by case rules dependent on more than just the modified data
*
* @param board board state at application
* @param puzzleElement selected puzzleElement
* @return List of puzzle elements (typically cells) this application of the case rule depends upon.
* Defaults to any element modified by any case
*/
@Override
public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleElement){
List<PuzzleElement> elements = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@ public ArrayList<Board> getCases(Board board, PuzzleElement puzzleElement) {
public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ private ArrayList<Board> getCasesFromCell(ShortTruthTableBoard board, PuzzleElem

}

/**
* Returns the elements necessary for the cases returned by getCases(board,puzzleElement) to be valid
* Overridden by case rules dependent on more than just the modified data
*
* @param board board state at application
* @param puzzleElement selected puzzleElement
* @return List of puzzle elements (typically cells) this application of the case rule depends upon.
* Defaults to any element modified by any case
*/
@Override
public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleElement){
List<PuzzleElement> elements = super.dependentElements(board,puzzleElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
return checkRuleRaw(transition);
}

/**
* Returns the elements necessary for the cases returned by getCases(board,puzzleElement) to be valid
* Overridden by case rules dependent on more than just the modified data
*
* @param board board state at application
* @param puzzleElement selected puzzleElement
* @return List of puzzle elements (typically cells) this application of the case rule depends upon.
* Defaults to any element modified by any case
*/
@Override
public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleElement){
List<PuzzleElement> elements = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
return checkRuleRaw(transition);
}

/**
* Returns the elements necessary for the cases returned by getCases(board,puzzleElement) to be valid
* Overridden by case rules dependent on more than just the modified data
*
* @param board board state at application
* @param puzzleElement selected puzzleElement
* @return List of puzzle elements (typically cells) this application of the case rule depends upon.
* Defaults to any element modified by any case
*/
@Override
public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleElement){
List<PuzzleElement> elements = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,29 @@ public String checkRuleRaw(TreeTransition transition) {
public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) {
return null;
}

/**
* Returns the elements necessary for the cases returned by getCases(board,puzzleElement) to be valid
* Overridden by case rules dependent on more than just the modified data
*
* @param board board state at application
* @param puzzleElement selected puzzleElement
* @return List of puzzle elements (typically cells) this application of the case rule depends upon.
* Defaults to any element modified by any case
*/
@Override
public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleElement){
List<PuzzleElement> elements = new ArrayList<>();

TreeTentBoard treeTentBoard = (TreeTentBoard) board;
TreeTentClue clue = (TreeTentClue) puzzleElement;

//add all elements of filled row
for (int i = 0; i < treeTentBoard.getWidth(); i++) {
TreeTentCell cell = treeTentBoard.getCell(i, clue.getClueIndex()-1);
elements.add(board.getPuzzleElement((cell)));
}

return elements;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
return checkRuleRaw(transition);
}

/**
* Returns the elements necessary for the cases returned by getCases(board,puzzleElement) to be valid
* Overridden by case rules dependent on more than just the modified data
*
* @param board board state at application
* @param puzzleElement selected puzzleElement
* @return List of puzzle elements (typically cells) this application of the case rule depends upon.
* Defaults to any element modified by any case
*/
@Override
public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleElement){
return List.of(board.getPuzzleElement(puzzleElement));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
return checkRuleRaw(transition);
}

/**
* Returns the elements necessary for the cases returned by getCases(board,puzzleElement) to be valid
* Overridden by case rules dependent on more than just the modified data
*
* @param board board state at application
* @param puzzleElement selected puzzleElement
* @return List of puzzle elements (typically cells) this application of the case rule depends upon.
* Defaults to any element modified by any case
*/
@Override
public List<PuzzleElement> dependentElements(Board board, PuzzleElement puzzleElement){
List<PuzzleElement> elements = new ArrayList<>(List.of(board.getPuzzleElement(puzzleElement)));
Expand Down

0 comments on commit 14fe70b

Please sign in to comment.