diff options
author | Pacien TRAN-GIRARD | 2016-03-15 20:13:21 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-03-15 20:13:21 +0100 |
commit | 3c47558d60a05f3f46674da610a7a550a559b4be (patch) | |
tree | cf944252419c3b3f27d52a6f3338ff9acfbc543a /src | |
parent | fab4253bba72b035fe36124d66d10799b224b6cf (diff) | |
download | xblast-3c47558d60a05f3f46674da610a7a550a559b4be.tar.gz |
Implement bombedCells() and blastedCells() mapping functions
Diffstat (limited to 'src')
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 2c6f372..cbe29b5 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java | |||
@@ -7,6 +7,7 @@ import ch.epfl.xblast.Direction; | |||
7 | import ch.epfl.xblast.PlayerID; | 7 | import ch.epfl.xblast.PlayerID; |
8 | 8 | ||
9 | import java.util.*; | 9 | import java.util.*; |
10 | import java.util.function.Function; | ||
10 | import java.util.stream.Collectors; | 11 | import java.util.stream.Collectors; |
11 | import java.util.stream.Stream; | 12 | import java.util.stream.Stream; |
12 | 13 | ||
@@ -205,7 +206,9 @@ public final class GameState { | |||
205 | * @return the map of bombs | 206 | * @return the map of bombs |
206 | */ | 207 | */ |
207 | public Map<Cell, Bomb> bombedCells() { | 208 | public Map<Cell, Bomb> bombedCells() { |
208 | return null; // TODO | 209 | return this.bombs |
210 | .stream() | ||
211 | .collect(Collectors.toMap(Bomb::position, Function.identity())); | ||
209 | } | 212 | } |
210 | 213 | ||
211 | /** | 214 | /** |
@@ -214,7 +217,10 @@ public final class GameState { | |||
214 | * @return the set of blasted cells | 217 | * @return the set of blasted cells |
215 | */ | 218 | */ |
216 | public Set<Cell> blastedCells() { | 219 | public Set<Cell> blastedCells() { |
217 | return null; // TODO | 220 | return this.blasts |
221 | .stream() | ||
222 | .map(Sq::head) | ||
223 | .collect(Collectors.toSet()); | ||
218 | } | 224 | } |
219 | 225 | ||
220 | /** | 226 | /** |