Skip to content

Commit c525013

Browse files
author
Schinc
committed
Add tests
1 parent 6cf1b96 commit c525013

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

ChickenAttackerInitialGameStateTest.java

+47-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.lang.reflect.Modifier;
77
import java.util.ArrayList;
88
import java.util.List;
9+
import java.util.Set;
910

1011
import static org.junit.jupiter.api.Assertions.*;
1112

@@ -90,10 +91,15 @@ void withStartingTilePlaced() {
9091
void testGame() {
9192

9293
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+
);
95101

96-
TileDecks startingTileDecks =new TileDecks(startingTiles, normalTiles, menhirTiles);
102+
TileDecks startingTileDecks = new TileDecks(startingTiles, normalTiles, menhirTiles);
97103

98104
GameState game = GameState.initial(
99105
List.of(PlayerColor.RED, PlayerColor.BLUE, PlayerColor.GREEN, PlayerColor.YELLOW),
@@ -125,8 +131,46 @@ void testGame() {
125131
Rotation.NONE,
126132
new Pos(0, 1)
127133
);
134+
assertEquals(normalTiles.size() - 1, game.tileDecks().normalTiles().size());
128135
game = game.withPlacedTile(pt1);
129136

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+
130174
// assertEquals(PlayerColor.BLUE, game.currentPlayer());
131175

132176
// at the end of the game

0 commit comments

Comments
 (0)