Skip to content

Commit

Permalink
Fixed some bugs with the rules
Browse files Browse the repository at this point in the history
  • Loading branch information
summerhenson committed Apr 9, 2024
1 parent 0becf20 commit 1db4a7a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@
</region>
</board>
</puzzle>
<solved isSolved="false" lastSaved="--"/>
</Legup>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class StarBattleCell extends GridCell<Integer> {
/**
* StarBattleCell Constructor - creates a new StarBattle cell to hold the puzzleElement
*
* @param valueInt value of the star battle cell denoting its state
* @param value value of the star battle cell denoting its state
* @param location location of the cell on the board
* @param groupIndex indicates what group # the cell is in.
* @param size size of the star battle cell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
}

StarBattleBoard modified = (StarBattleBoard) origBoard.copy();
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.STAR);
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.STAR.value);
if (contraRule.checkContradictionAt(modified, puzzleElement) != null) {
return "Black cells must be placed in a row, region, or column with enough stars!";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
}

StarBattleBoard modified = (StarBattleBoard) origBoard.copy();
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.BLACK);
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.BLACK.value);
if (contraRule.checkContradictionAt(modified, puzzleElement) != null) {
return "Star cells must be placed in a row, region, or column without extra spaces!";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public ArrayList<Board> getCases(Board board, PuzzleElement puzzleElement) {
ArrayList<Board> cases = new ArrayList<>();
Board case1 = board.copy();
PuzzleElement data1 = case1.getPuzzleElement(puzzleElement);
data1.setData(StarBattleCellType.STAR);
data1.setData(StarBattleCellType.STAR.value);
case1.addModifiedData(data1);
cases.add(case1);

Board case2 = board.copy();
PuzzleElement data2 = case2.getPuzzleElement(puzzleElement);
data2.setData(StarBattleCellType.BLACK);
data2.setData(StarBattleCellType.BLACK.value);
case2.addModifiedData(data2);
cases.add(case2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElem
}

StarBattleBoard modified = (StarBattleBoard) origBoard.copy();
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.STAR);
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.STAR.value);
if (contraRule.checkContradictionAt(modified, puzzleElement) != null) {
return "Black cells must be placed adjacent to a star!";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
for (int k = 0; k < cellList.size(); k++) {
if (cellList.get(k).getType() == StarBattleCellType.STAR) {
starCount++;
if (starCount >= puzzleNum) {
if (starCount > puzzleNum) {
valid = false;
break;
}
}
}

if (valid == false) {
if (valid) {
return super.getNoContradictionMessage();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Legup>
<puzzle name="Star Battle">
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Legup version="2.0.0">
<puzzle name="StarBattle">
<board size="4" puzzle_num="1">
<region>
<cells>
Expand All @@ -25,12 +26,15 @@
<cell value="0" x="1" y="1">
</cells>
</region>
<region>
<cells>
<cell value="0" x="2" y="0">
<cell value="0" x="3" y="0">
<cell value="0" x="2" y="1">
<cell value="0" x="3" y="1">
</cells>
</region>
</board>
</puzzle>
<solved isSolved="false" lastSaved="--"/>
</Legup>

0 comments on commit 1db4a7a

Please sign in to comment.