diff options
Diffstat (limited to 'src/ch/epfl')
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 50b0ff2..33a8f5f 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java | |||
@@ -395,7 +395,7 @@ public final class GameState { | |||
395 | Map<PlayerID, List<Bomb>> bombOwnerMap = GameState.mapBombsToPlayers(bombs0); | 395 | Map<PlayerID, List<Bomb>> bombOwnerMap = GameState.mapBombsToPlayers(bombs0); |
396 | List<Bomb> bombs1 = new ArrayList<>(bombs0); | 396 | List<Bomb> bombs1 = new ArrayList<>(bombs0); |
397 | 397 | ||
398 | for (Player p : GameState.alivePlayers(players0)) { | 398 | for (Player p : players0) { |
399 | if (!bombDropEvents.contains(p.id())) continue; | 399 | if (!bombDropEvents.contains(p.id())) continue; |
400 | if (bombedCells.contains(p.position().containingCell())) continue; | 400 | if (bombedCells.contains(p.position().containingCell())) continue; |
401 | 401 | ||
@@ -434,19 +434,9 @@ public final class GameState { | |||
434 | * @return a list of the alive players | 434 | * @return a list of the alive players |
435 | */ | 435 | */ |
436 | public List<Player> alivePlayers() { | 436 | public List<Player> alivePlayers() { |
437 | return GameState.alivePlayers(this.players); | 437 | return Collections.unmodifiableList(this.players.stream() |
438 | } | ||
439 | |||
440 | /** | ||
441 | * Filters the given list of players and returns the lively ones. | ||
442 | * | ||
443 | * @param players a list of players | ||
444 | * @return the list of alive players | ||
445 | */ | ||
446 | private static List<Player> alivePlayers(List<Player> players) { | ||
447 | return players.stream() | ||
448 | .filter(Player::isAlive) | 438 | .filter(Player::isAlive) |
449 | .collect(Collectors.toList()); | 439 | .collect(Collectors.toList())); |
450 | } | 440 | } |
451 | 441 | ||
452 | /** | 442 | /** |
@@ -550,7 +540,7 @@ public final class GameState { | |||
550 | 540 | ||
551 | // 4.1. newly dropped bombs addition | 541 | // 4.1. newly dropped bombs addition |
552 | Set<PlayerID> topPriorityBombDropEvents = discardConflictingBombDropEvents(bombDropEvents); | 542 | Set<PlayerID> topPriorityBombDropEvents = discardConflictingBombDropEvents(bombDropEvents); |
553 | List<Bomb> allBombs = GameState.newlyDroppedBombs(this.players, topPriorityBombDropEvents, this.bombs); | 543 | List<Bomb> allBombs = GameState.newlyDroppedBombs(this.alivePlayers(), topPriorityBombDropEvents, this.bombs); |
554 | 544 | ||
555 | // 4.2. existing bombs evolution | 545 | // 4.2. existing bombs evolution |
556 | List<Bomb> explodingBombs = GameState.explodingBombs(allBombs, blastedCells1); | 546 | List<Bomb> explodingBombs = GameState.explodingBombs(allBombs, blastedCells1); |