Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 6 bugfix for pit trap #13

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/ch/epfl/chacun/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
updatedBoard = updatedBoard.withoutGatherersOrFishersIn(closedForests, closedRivers);
// The player can play again if he closed a forest containing a menhir with a normal tile
boolean hasSecondTurn = closedForestWithMenhir != null
&& board.lastPlacedTile().kind() == Tile.Kind.NORMAL;

Check warning on line 305 in src/ch/epfl/chacun/GameState.java

View workflow job for this annotation

GitHub Actions / qodana

Nullability and data flow problems

Method invocation `kind` may produce `NullPointerException`

// SECOND TURN CHECK
TileDecks updatedMenhirDeck = hasSecondTurn ?
Expand Down Expand Up @@ -350,15 +350,15 @@
for (Area<Zone.Meadow> meadow : board.meadowAreas()) {
// Check that the meadow does not contain a wildfire
if (!meadow.tileIds().contains(WILD_FIRE_TILE_ID)) {
// Determine the cancelled animals of the meadow
updatedBoard = updatedBoard
.withMoreCancelledAnimals(computeCancelledAnimals(meadow, 0));
// Check if the meadow contains a pit trap
if (meadow.tileIds().contains(PIT_TRAP_TILE_ID)) {
// Change the cancelled animals to optimize the points scored by the pit trap
updatedBoard = updatedBoard
.withMoreCancelledAnimals(computeCancelledAnimalsWithPitTrap(meadow, updatedBoard));
}
// Determine the cancelled animals of the meadow
updatedBoard = updatedBoard
.withMoreCancelledAnimals(computeCancelledAnimals(meadow, 0));
}
if (meadow.tileIds().contains(PIT_TRAP_TILE_ID)) {
Area<Zone.Meadow> adjacentMeadow = updatedBoard
Expand Down Expand Up @@ -447,9 +447,9 @@
// The cancelled animals which are out of the pit trap reach
Set<Animal> cancelledAnimals = computeCancelledAnimals(outOfReachMeadowArea, tigerNb);
// Subtract the number of deer which are out of the pit trap reach from the tiger number
tigerNb -= getAnimalsOfKind(Area.animals(outOfReachMeadowArea, Set.of()), Animal.Kind.DEER).size();

Check warning on line 450 in src/ch/epfl/chacun/GameState.java

View workflow job for this annotation

GitHub Actions / qodana

Unused assignment

The value `getAnimalsOfKind(Area.animals(outOfReachMeadowArea, Set.of()), Animal.Kind.DEER).size()` assigned to `tigerNb` is never used

Check warning on line 450 in src/ch/epfl/chacun/GameState.java

View workflow job for this annotation

GitHub Actions / qodana

Unused assignment

The value `getAnimalsOfKind(Area.animals(outOfReachMeadowArea, Set.of()), Animal.Kind.DEER).size()` assigned to `tigerNb` is never used
// Add the remaining cancelled animals from the adjacent meadows
cancelledAnimals.addAll(computeCancelledAnimals(adjacentMeadowArea, tigerNb));
//cancelledAnimals.addAll(computeCancelledAnimals(adjacentMeadowArea, tigerNb));
return cancelledAnimals;
}

Expand Down
Loading