|
6 | 6 | import java.lang.reflect.Modifier;
|
7 | 7 | import java.util.ArrayList;
|
8 | 8 | import java.util.List;
|
| 9 | +import java.util.Set; |
9 | 10 |
|
10 | 11 | import static org.junit.jupiter.api.Assertions.*;
|
11 | 12 |
|
@@ -90,10 +91,15 @@ void withStartingTilePlaced() {
|
90 | 91 | void testGame() {
|
91 | 92 |
|
92 | 93 | List<Tile> startingTiles = List.of(Tiles.TILES.get(56));
|
93 |
| - List<Tile> normalTiles = Tiles.TILES.stream().filter(t -> t.kind() == Tile.Kind.NORMAL).toList().subList(0, 3); |
94 |
| - List<Tile> menhirTiles = Tiles.TILES.stream().filter(t -> t.kind() == Tile.Kind.MENHIR).toList().subList(0, 3); |
| 94 | + List<Tile> normalTiles = List.of( |
| 95 | + Tiles.TILES.get(67), |
| 96 | + Tiles.TILES.get(25) |
| 97 | + ); |
| 98 | + List<Tile> menhirTiles = List.of( |
| 99 | + Tiles.TILES.get(88) |
| 100 | + ); |
95 | 101 |
|
96 |
| - TileDecks startingTileDecks =new TileDecks(startingTiles, normalTiles, menhirTiles); |
| 102 | + TileDecks startingTileDecks = new TileDecks(startingTiles, normalTiles, menhirTiles); |
97 | 103 |
|
98 | 104 | GameState game = GameState.initial(
|
99 | 105 | List.of(PlayerColor.RED, PlayerColor.BLUE, PlayerColor.GREEN, PlayerColor.YELLOW),
|
@@ -125,8 +131,46 @@ void testGame() {
|
125 | 131 | Rotation.NONE,
|
126 | 132 | new Pos(0, 1)
|
127 | 133 | );
|
| 134 | + assertEquals(normalTiles.size() - 1, game.tileDecks().normalTiles().size()); |
128 | 135 | game = game.withPlacedTile(pt1);
|
129 | 136 |
|
| 137 | + Occupant occupant67F = new Occupant(Occupant.Kind.HUT, Tiles.TILES.get(67).sideZones().stream().findFirst().get().id()); |
| 138 | + GameState finalGame1 = game; |
| 139 | + assertThrows(IllegalArgumentException.class, () -> finalGame1.withNewOccupant(occupant67F)); |
| 140 | + |
| 141 | + Zone.Forest occupiedZone = (Zone.Forest) Tiles.TILES.get(67).zones().stream().filter(z -> z.id() == 670).findFirst().get(); |
| 142 | + Occupant occupant67T = new Occupant(Occupant.Kind.PAWN, occupiedZone.id()); |
| 143 | + game = game.withNewOccupant(occupant67T); |
| 144 | + |
| 145 | + assertEquals(1, game.board().occupantCount(PlayerColor.RED, Occupant.Kind.PAWN)); |
| 146 | + // check if board |
| 147 | + assertTrue(game.board().occupants().contains(occupant67T)); |
| 148 | + // check if tile |
| 149 | + assert game.board().lastPlacedTile() != null; |
| 150 | + assertEquals(occupant67T, game.board().lastPlacedTile().occupant()); |
| 151 | + // check if area |
| 152 | + Area<Zone.Forest> forestArea = game.board().forestArea(occupiedZone); |
| 153 | + assertEquals(1, forestArea.occupants().size()); |
| 154 | + |
| 155 | + assertEquals(GameState.Action.PLACE_TILE, game.nextAction()); |
| 156 | + assertEquals(PlayerColor.BLUE, game.currentPlayer()); |
| 157 | + assertEquals(normalTiles.size() - 2, game.tileDecks().normalTiles().size()); |
| 158 | + |
| 159 | + game = game.withPlacedTile(new PlacedTile( |
| 160 | + Tiles.TILES.get(25), |
| 161 | + PlayerColor.BLUE, |
| 162 | + Rotation.RIGHT, |
| 163 | + new Pos(1, 0) |
| 164 | + )); |
| 165 | + |
| 166 | + game = game.withNewOccupant(null); |
| 167 | + |
| 168 | + assertEquals(GameState.Action.PLACE_TILE, game.nextAction()); |
| 169 | + assertEquals(PlayerColor.BLUE, game.currentPlayer()); |
| 170 | + assertEquals(Tile.Kind.MENHIR, game.tileToPlace().kind()); |
| 171 | + |
| 172 | + assertEquals(Set.of(PlayerColor.RED), game.messageBoard().messages().getFirst().scorers()); |
| 173 | + |
130 | 174 | // assertEquals(PlayerColor.BLUE, game.currentPlayer());
|
131 | 175 |
|
132 | 176 | // at the end of the game
|
|
0 commit comments