From 7a311f334af43ad3fae2eb8c106e370187189b02 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Thu, 5 May 2016 22:20:26 +0200 Subject: Merging alive players filter --- src/ch/epfl/xblast/server/GameState.java | 18 ++++-------------- 1 file 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 { Map> bombOwnerMap = GameState.mapBombsToPlayers(bombs0); List bombs1 = new ArrayList<>(bombs0); - for (Player p : GameState.alivePlayers(players0)) { + for (Player p : players0) { if (!bombDropEvents.contains(p.id())) continue; if (bombedCells.contains(p.position().containingCell())) continue; @@ -434,19 +434,9 @@ public final class GameState { * @return a list of the alive players */ public List alivePlayers() { - return GameState.alivePlayers(this.players); - } - - /** - * Filters the given list of players and returns the lively ones. - * - * @param players a list of players - * @return the list of alive players - */ - private static List alivePlayers(List players) { - return players.stream() + return Collections.unmodifiableList(this.players.stream() .filter(Player::isAlive) - .collect(Collectors.toList()); + .collect(Collectors.toList())); } /** @@ -550,7 +540,7 @@ public final class GameState { // 4.1. newly dropped bombs addition Set topPriorityBombDropEvents = discardConflictingBombDropEvents(bombDropEvents); - List allBombs = GameState.newlyDroppedBombs(this.players, topPriorityBombDropEvents, this.bombs); + List allBombs = GameState.newlyDroppedBombs(this.alivePlayers(), topPriorityBombDropEvents, this.bombs); // 4.2. existing bombs evolution List explodingBombs = GameState.explodingBombs(allBombs, blastedCells1); -- cgit v1.2.3