Fix: GameTest
This commit is contained in:
@@ -72,32 +72,28 @@ class GameTest {
|
|||||||
Player current = game.getCurrentState().getCurrentPlayer();
|
Player current = game.getCurrentState().getCurrentPlayer();
|
||||||
assertNotNull(current);
|
assertNotNull(current);
|
||||||
|
|
||||||
if (game.getCurrentState().getNLower() > 0) {
|
if (game.getCurrentState().getNLower() > 0 && hasDrawableLower(game)) {
|
||||||
int index = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards());
|
int index = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards());
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
assertTrue(game.DrawLowerTribeCardByIndex(current, index));
|
assertTrue(game.DrawLowerTribeCardByIndex(current, index));
|
||||||
} else if (!game.getLowerListBuilding().isEmpty()) {
|
} else {
|
||||||
current.addFood(100);
|
current.addFood(100);
|
||||||
assertTrue(game.DrawLowerBuildingCardByIndex(current, 0));
|
assertTrue(game.DrawLowerBuildingCardByIndex(current, 0));
|
||||||
} else {
|
|
||||||
fail("No valid lower card available.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (game.getCurrentState().getNUpper() > 0) {
|
} else if (game.getCurrentState().getNUpper() > 0 && hasDrawableUpper(game)) {
|
||||||
int index = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
|
int index = firstNonEventIndexOrMinusOne(game.getUpperListTribeCards());
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
assertTrue(game.DrawUpperTribeCardByIndex(current, index));
|
assertTrue(game.DrawUpperTribeCardByIndex(current, index));
|
||||||
} else if (!game.getUpperListBuilding().isEmpty()) {
|
} else {
|
||||||
current.addFood(100);
|
current.addFood(100);
|
||||||
assertTrue(game.DrawUpperBuildingCardByIndex(current, 0));
|
assertTrue(game.DrawUpperBuildingCardByIndex(current, 0));
|
||||||
} else {
|
|
||||||
fail("No valid upper card available.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fail("Current player has no remaining draws.");
|
fail("Current player has no drawable cards, although the game is still resolving actions.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +218,16 @@ class GameTest {
|
|||||||
resolveOptionalPhaseIfPresent(game);
|
resolveOptionalPhaseIfPresent(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasDrawableLower(Game game) {
|
||||||
|
return firstNonEventIndexOrMinusOne(game.getLowerListTribeCards()) != -1
|
||||||
|
|| !game.getLowerListBuilding().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasDrawableUpper(Game game) {
|
||||||
|
return firstNonEventIndexOrMinusOne(game.getUpperListTribeCards()) != -1
|
||||||
|
|| !game.getUpperListBuilding().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorShouldInitializeGameCorrectly() {
|
void constructorShouldInitializeGameCorrectly() {
|
||||||
int nPlayers = 3;
|
int nPlayers = 3;
|
||||||
@@ -954,8 +960,8 @@ class GameTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void fullGameShouldEndAfterTenRoundsForTwoThreeAndFourPlayersUsingOnlyPublicGameFlow() {
|
void fullGameShouldEndAfterTenRoundsForTwoThreeFourAndFivePlayersUsingOnlyPublicGameFlow() {
|
||||||
for (int nPlayers : new int[]{2, 3, 4}) {
|
for (int nPlayers : new int[]{2, 3, 4, 5}) {
|
||||||
Game game = new Game(nPlayers);
|
Game game = new Game(nPlayers);
|
||||||
|
|
||||||
for (int i = 1; i <= nPlayers; i++) {
|
for (int i = 1; i <= nPlayers; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user