Fix: GameTest
This commit is contained in:
@@ -72,32 +72,28 @@ class GameTest {
|
||||
Player current = game.getCurrentState().getCurrentPlayer();
|
||||
assertNotNull(current);
|
||||
|
||||
if (game.getCurrentState().getNLower() > 0) {
|
||||
if (game.getCurrentState().getNLower() > 0 && hasDrawableLower(game)) {
|
||||
int index = firstNonEventIndexOrMinusOne(game.getLowerListTribeCards());
|
||||
|
||||
if (index != -1) {
|
||||
assertTrue(game.DrawLowerTribeCardByIndex(current, index));
|
||||
} else if (!game.getLowerListBuilding().isEmpty()) {
|
||||
} else {
|
||||
current.addFood(100);
|
||||
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());
|
||||
|
||||
if (index != -1) {
|
||||
assertTrue(game.DrawUpperTribeCardByIndex(current, index));
|
||||
} else if (!game.getUpperListBuilding().isEmpty()) {
|
||||
} else {
|
||||
current.addFood(100);
|
||||
assertTrue(game.DrawUpperBuildingCardByIndex(current, 0));
|
||||
} else {
|
||||
fail("No valid upper card available.");
|
||||
}
|
||||
|
||||
} 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);
|
||||
}
|
||||
|
||||
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
|
||||
void constructorShouldInitializeGameCorrectly() {
|
||||
int nPlayers = 3;
|
||||
@@ -954,8 +960,8 @@ class GameTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void fullGameShouldEndAfterTenRoundsForTwoThreeAndFourPlayersUsingOnlyPublicGameFlow() {
|
||||
for (int nPlayers : new int[]{2, 3, 4}) {
|
||||
void fullGameShouldEndAfterTenRoundsForTwoThreeFourAndFivePlayersUsingOnlyPublicGameFlow() {
|
||||
for (int nPlayers : new int[]{2, 3, 4, 5}) {
|
||||
Game game = new Game(nPlayers);
|
||||
|
||||
for (int i = 1; i <= nPlayers; i++) {
|
||||
|
||||
Reference in New Issue
Block a user