diff options
author | Pacien TRAN-GIRARD | 2016-04-08 19:20:18 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-04-08 19:20:18 +0200 |
commit | e3f8e4276d87f2dba10395a882dc4673b65b4e89 (patch) | |
tree | a8284a606a1ebdfca24cfca2e27708c5c4559590 | |
parent | 5d8e8c6e0430d004162cb02229a55ab5ae7dee05 (diff) | |
download | xblast-e3f8e4276d87f2dba10395a882dc4673b65b4e89.tar.gz |
Use stream for explosion generation
-rw-r--r-- | src/ch/epfl/xblast/server/Bomb.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index 3b1203b..f32960f 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java | |||
@@ -6,9 +6,10 @@ import ch.epfl.xblast.Cell; | |||
6 | import ch.epfl.xblast.Direction; | 6 | import ch.epfl.xblast.Direction; |
7 | import ch.epfl.xblast.PlayerID; | 7 | import ch.epfl.xblast.PlayerID; |
8 | 8 | ||
9 | import java.util.ArrayList; | ||
10 | import java.util.List; | 9 | import java.util.List; |
11 | import java.util.Objects; | 10 | import java.util.Objects; |
11 | import java.util.stream.Collectors; | ||
12 | import java.util.stream.Stream; | ||
12 | 13 | ||
13 | /** | 14 | /** |
14 | * A Bomb. | 15 | * A Bomb. |
@@ -106,11 +107,9 @@ public final class Bomb { | |||
106 | * @return the explosion | 107 | * @return the explosion |
107 | */ | 108 | */ |
108 | public List<Sq<Sq<Cell>>> explosion() { | 109 | public List<Sq<Sq<Cell>>> explosion() { |
109 | List<Sq<Sq<Cell>>> explosion = new ArrayList<>(); | 110 | return Stream.of(Direction.values()) |
110 | for (Direction dir : Direction.values()) { | 111 | .map(this::explosionArmTowards) |
111 | explosion.add(this.explosionArmTowards(dir)); | 112 | .collect(Collectors.toList()); |
112 | } | ||
113 | return explosion; | ||
114 | } | 113 | } |
115 | 114 | ||
116 | } | 115 | } |