-
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.
Merge branch 'star-battle' of https://github.com/Bram-Hub/LEGUP into …
…star-battle
- Loading branch information
Showing
10 changed files
with
183 additions
and
6 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
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
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
69 changes: 69 additions & 0 deletions
69
src/test/java/puzzles/starbattle/rules/BlackoutDirectRuleTest.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,69 @@ | ||
package puzzles.starbattle.rules; | ||
|
||
import edu.rpi.legup.puzzle.nurikabe.Nurikabe; | ||
import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard; | ||
import edu.rpi.legup.puzzle.nurikabe.NurikabeCell; | ||
import edu.rpi.legup.puzzle.nurikabe.NurikabeType; | ||
import legup.MockGameBoardFacade; | ||
import legup.TestUtilities; | ||
import edu.rpi.legup.model.tree.TreeNode; | ||
import edu.rpi.legup.model.tree.TreeTransition; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import edu.rpi.legup.puzzle.starbattle.StarBattle; | ||
import edu.rpi.legup.puzzle.starbattle.StarBattleBoard; | ||
import edu.rpi.legup.puzzle.starbattle.StarBattleCell; | ||
import edu.rpi.legup.puzzle.starbattle.StarBattleCellType; | ||
import edu.rpi.legup.puzzle.starbattle.rules.BlackoutDirectRule; | ||
import edu.rpi.legup.save.InvalidFileFormatException; | ||
|
||
import java.awt.*; | ||
|
||
public class BlackoutDirectRuleTest { | ||
|
||
private static final BlackoutDirectRule RULE = new BlackoutDirectRule(); | ||
private static StarBattle starbattle; | ||
|
||
@BeforeClass | ||
public static void setUp() { | ||
MockGameBoardFacade.getInstance(); | ||
starbattle = new StarBattle(); | ||
} | ||
|
||
@Test | ||
public void BlackoutDirectRuleTest_ColumnBlackout() throws InvalidFileFormatException { | ||
TestUtilities.importTestBoard("puzzles/starbattle/rules/BlackoutDirectRule/ColumnBlackout", starbattle); | ||
TreeNode rootNode = starbattle.getTree().getRootNode(); | ||
TreeTransition transition = rootNode.getChildren().get(0); | ||
transition.setRule(RULE); | ||
|
||
StarBattleBoard board = (StarBattleBoard) transition.getBoard(); | ||
|
||
StarBattleCell cell1 = board.getCell(1, 1); | ||
cell1.setData(StarBattleCellType.BLACK.value); | ||
StarBattleCell cell2 = board.getCell(1, 2); | ||
cell2.setData(StarBattleCellType.BLACK.value); | ||
StarBattleCell cell3 = board.getCell(1, 3); | ||
cell3.setData(StarBattleCellType.BLACK.value); | ||
|
||
board.addModifiedData(cell1); | ||
board.addModifiedData(cell2); | ||
board.addModifiedData(cell3); | ||
|
||
Assert.assertNull(RULE.checkRule(transition)); | ||
|
||
for (int i = 0; i < board.getHeight(); i++) { | ||
for (int k = 0; k < board.getWidth(); k++) { | ||
Point point = new Point(k, i); | ||
if (point.equals(cell1.getLocation()) || point.equals(cell2.getLocation()) || point.equals(cell3.getLocation())) { | ||
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i))); | ||
} | ||
else { | ||
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i))); | ||
} | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/ColumnBlackout
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,36 @@ | ||
<Legup> | ||
<puzzle name="Star Battle"> | ||
<board size="4" puzzle_num="1"> | ||
<region> | ||
<cells> | ||
<cell value="0" x="0" y="2"> | ||
<cell value="0" x="1" y="2"> | ||
<cell value="0" x="0" y="3"> | ||
<cell value="0" x="1" y="3"> | ||
</cells> | ||
</region> | ||
<region> | ||
<cells> | ||
<cell value="0" x="2" y="2"> | ||
<cell value="0" x="3" y="2"> | ||
<cell value="0" x="2" y="3"> | ||
<cell value="0" x="3" y="3"> | ||
</cells> | ||
</region> | ||
<region> | ||
<cells> | ||
<cell value="0" x="0" y="0"> | ||
<cell value="-2" x="1" y="0"> | ||
<cell value="0" x="0" y="1"> | ||
<cell value="0" x="1" y="1"> | ||
</cells> | ||
</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> | ||
</board> | ||
</puzzle> | ||
</Legup> |
36 changes: 36 additions & 0 deletions
36
src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RegionBlackout
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,36 @@ | ||
<Legup> | ||
<puzzle name="Star Battle"> | ||
<board size="4" puzzle_num="1"> | ||
<region> | ||
<cells> | ||
<cell value="0" x="0" y="2"> | ||
<cell value="0" x="1" y="2"> | ||
<cell value="0" x="0" y="3"> | ||
<cell value="0" x="1" y="3"> | ||
</cells> | ||
</region> | ||
<region> | ||
<cells> | ||
<cell value="0" x="2" y="2"> | ||
<cell value="0" x="3" y="2"> | ||
<cell value="0" x="2" y="3"> | ||
<cell value="0" x="3" y="3"> | ||
</cells> | ||
</region> | ||
<region> | ||
<cells> | ||
<cell value="0" x="0" y="0"> | ||
<cell value="-2" x="1" y="0"> | ||
<cell value="0" x="0" y="1"> | ||
<cell value="0" x="1" y="1"> | ||
</cells> | ||
</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> | ||
</board> | ||
</puzzle> | ||
</Legup> |
36 changes: 36 additions & 0 deletions
36
src/test/resources/puzzles/starbattle.rules/BlackoutDirectRule/RowBlackout
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,36 @@ | ||
<Legup> | ||
<puzzle name="Star Battle"> | ||
<board size="4" puzzle_num="1"> | ||
<region> | ||
<cells> | ||
<cell value="0" x="0" y="2"> | ||
<cell value="0" x="1" y="2"> | ||
<cell value="0" x="0" y="3"> | ||
<cell value="0" x="1" y="3"> | ||
</cells> | ||
</region> | ||
<region> | ||
<cells> | ||
<cell value="0" x="2" y="2"> | ||
<cell value="0" x="3" y="2"> | ||
<cell value="0" x="2" y="3"> | ||
<cell value="0" x="3" y="3"> | ||
</cells> | ||
</region> | ||
<region> | ||
<cells> | ||
<cell value="0" x="0" y="0"> | ||
<cell value="-2" x="1" y="0"> | ||
<cell value="0" x="0" y="1"> | ||
<cell value="0" x="1" y="1"> | ||
</cells> | ||
</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> | ||
</board> | ||
</puzzle> | ||
</Legup> |