Skip to content

Commit

Permalink
Merge branch 'star-battle' of https://github.com/Bram-Hub/LEGUP into …
Browse files Browse the repository at this point in the history
…star-battle
  • Loading branch information
sarah-min committed Feb 27, 2024
2 parents 2d9dc03 + 024aa4f commit 3dd86fb
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
68 changes: 68 additions & 0 deletions puzzles files/starbattle/6x6 Star Battle 1star Normal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Legup version="2.0.0">
<puzzle name="StarBattle">
<board height="6" width="6">
<region>
<cells>
<cell value="0" x="0" y="0"/>
<cell value="0" x="1" y="0"/>
<cell value="0" x="2" y="0"/>
<cell value="0" x="3" y="0"/>
<cell value="0" x="4" y="0"/>
<cell value="0" x="5" y="0"/>
<cell value="0" x="0" y="1"/>
<cell value="0" x="2" y="1"/>
<cell value="0" x="3" y="1"/>
<cell value="0" x="4" y="1"/>
</cells>
</region>
<region>
<cells>
<cell value="0" x="1" y="1"/>
<cell value="0" x="1" y="2"/>
</cells>
</region>
<region>
<cells>
<cell value="0" x="5" y="1"/>
<cell value="0" x="3" y="2"/>
<cell value="0" x="4" y="2"/>
<cell value="0" x="5" y="2"/>
<cell value="0" x="4" y="3"/>
</cells>
</region>
<region>
<cells>
<cell value="0" x="0" y="2"/>
<cell value="0" x="0" y="3"/>
<cell value="0" x="0" y="4"/>
<cell value="0" x="2" y="4"/>
<cell value="0" x="0" y="5"/>
<cell value="0" x="1" y="5"/>
<cell value="0" x="2" y="5"/>
<cell value="0" x="3" y="5"/>
</cells>
</region>
<region>
<cells>
<cell value="0" x="2" y="2"/>
<cell value="0" x="1" y="3"/>
<cell value="0" x="2" y="3"/>
<cell value="0" x="3" y="3"/>
<cell value="0" x="1" y="4"/>
<cell value="0" x="3" y="4"/>
<cell value="0" x="4" y="4"/>
<cell value="0" x="4" y="5"/>
<cell value="0" x="5" y="5"/>
</cells>
</region>
<region>
<cells>
<cell value="0" x="5" y="3"/>
<cell value="0" x="5" y="4"/>
</cells>
</region>
</board>
</puzzle>
<solved isSolved="false" lastSaved="--"/>
</Legup>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

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.model.rules.DirectRule;
import edu.rpi.legup.model.tree.TreeNode;
import edu.rpi.legup.model.tree.TreeTransition;
import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard;
import edu.rpi.legup.puzzle.nurikabe.NurikabeType;
import edu.rpi.legup.puzzle.nurikabe.rules.NoNumberContradictionRule;
import edu.rpi.legup.puzzle.starbattle.StarBattleBoard;
import edu.rpi.legup.puzzle.starbattle.StarBattleCell;
import edu.rpi.legup.puzzle.starbattle.StarBattleCellType;
Expand All @@ -29,7 +33,22 @@ public SurroundStarDirectRule() {
*/
@Override
public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) {
StarBattleBoard board = (StarBattleBoard) transition.getBoard();
StarBattleBoard origBoard = (StarBattleBoard) transition.getParents().get(0).getBoard();
ContradictionRule contraRule = new ClashingOrbitContradictionRule();

StarBattleCell cell = (StarBattleCell) board.getPuzzleElement(puzzleElement);

if (cell.getType() != StarBattleCellType.BLACK) {
return "Only black cells are allowed for this rule!";
}

StarBattleBoard modified = (StarBattleBoard) origBoard.copy();
//TODO: please for the love of god make a copy method for star battle board because this isn't actually going to work otherwise
modified.getPuzzleElement(puzzleElement).setData(StarBattleCellType.STAR);
if (contraRule.checkContradictionAt(modified, puzzleElement) != null) {
return "Black cells must be placed adjacent to a star!";
}
return null;
}

Expand Down

0 comments on commit 3dd86fb

Please sign in to comment.