From fda6f14fec0aaf774aeb4a6dd30da92209fadc7f Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Thu, 5 May 2016 13:25:08 +0200 Subject: Refactor bombs evolution flow --- src/ch/epfl/xblast/server/GameState.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index abd07b3..19b16a9 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -416,7 +416,7 @@ public final class GameState { List ownedBombs = bombOwnerMap.get(p.id()); if (ownedBombs != null && ownedBombs.size() >= p.maxBombs()) continue; - Bomb b = new Bomb(p.id(), p.position().containingCell(), Ticks.BOMB_FUSE_TICKS - 1, p.bombRange()); + Bomb b = p.newBomb(); bombedCells.add(b.position()); bombs1.add(b); } @@ -562,16 +562,16 @@ public final class GameState { // 3. existing explosions evolution List>> explosions1 = GameState.nextExplosions(this.explosions); - // 4.1. existing bombs evolution - List explodingBombs = GameState.explodingBombs(this.bombs, blastedCells1); - List existingBombs = GameState.nextBombs(this.bombs, explodingBombs); + // 4.1. newly dropped bombs addition + Set topPriorityBombDropEvents = discardConflictingBombDropEvents(bombDropEvents); + List allBombs = GameState.newlyDroppedBombs(this.players, topPriorityBombDropEvents, this.bombs); - // 4.2. subsequent explosions addition - explodingBombs.forEach(b -> explosions1.addAll(b.explosion())); + // 4.2. existing bombs evolution + List explodingBombs = GameState.explodingBombs(allBombs, blastedCells1); + List bombs1 = GameState.nextBombs(allBombs, explodingBombs); - // 4.3. newly dropped bombs addition - Set topPriorityBombDropEvents = discardConflictingBombDropEvents(bombDropEvents); - List bombs1 = GameState.newlyDroppedBombs(this.players, topPriorityBombDropEvents, existingBombs); + // 4.3. subsequent explosions addition + explodingBombs.forEach(b -> explosions1.addAll(b.explosion())); // 5. players evolution Map playerBonuses = mapPlayersToBonuses(consumedBonuses); -- cgit v1.2.3