aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-04-10 09:31:03 +0200
committerPacien TRAN-GIRARD2016-04-10 09:31:03 +0200
commit60366705c2e296f4b2db6664c3a6cb421976d294 (patch)
tree62078cf0e74827ba8446eabe9ac4defc7faa76f9 /src
parent5d93798c5c261c4844df2326602a253fe400dd1c (diff)
downloadxblast-60366705c2e296f4b2db6664c3a6cb421976d294.tar.gz
Fix and simplify blasts propagation
Diffstat (limited to 'src')
-rw-r--r--src/ch/epfl/xblast/server/Block.java9
-rw-r--r--src/ch/epfl/xblast/server/GameState.java6
2 files changed, 12 insertions, 3 deletions
diff --git a/src/ch/epfl/xblast/server/Block.java b/src/ch/epfl/xblast/server/Block.java
index 6076297..ca04f31 100644
--- a/src/ch/epfl/xblast/server/Block.java
+++ b/src/ch/epfl/xblast/server/Block.java
@@ -87,6 +87,15 @@ public enum Block {
87 } 87 }
88 88
89 /** 89 /**
90 * Returns T(this block is destructible).
91 *
92 * @return T(this block is destructible)
93 */
94 public boolean isDestructible() {
95 return this != INDESTRUCTIBLE_WALL;
96 }
97
98 /**
90 * Returns T(this block is a bonus). 99 * Returns T(this block is a bonus).
91 * 100 *
92 * @return T(this block is a bonus) 101 * @return T(this block is a bonus)
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java
index ab6f2a6..f3547dc 100644
--- a/src/ch/epfl/xblast/server/GameState.java
+++ b/src/ch/epfl/xblast/server/GameState.java
@@ -113,13 +113,13 @@ public final class GameState {
113 private static List<Sq<Cell>> nextBlasts(List<Sq<Cell>> blasts0, Board board0, List<Sq<Sq<Cell>>> explosions0) { 113 private static List<Sq<Cell>> nextBlasts(List<Sq<Cell>> blasts0, Board board0, List<Sq<Sq<Cell>>> explosions0) {
114 return Stream.concat( 114 return Stream.concat(
115 blasts0.stream() 115 blasts0.stream()
116 .filter(b -> !b.tail().isEmpty())
117 .filter(b -> board0.blockAt(b.head()).isFree()) 116 .filter(b -> board0.blockAt(b.head()).isFree())
118 .map(Sq::tail), 117 .map(Sq::tail),
119 explosions0.stream() 118 explosions0.stream()
120 .filter(e -> !e.isEmpty()) 119 .filter(e -> !e.isEmpty())
121 .map(Sq::head) 120 .map(Sq::head))
122 .filter(b -> !b.isEmpty())) 121 .filter(b -> !b.isEmpty())
122 .filter(b -> board0.blockAt(b.head()).isDestructible())
123 .collect(Collectors.toList()); 123 .collect(Collectors.toList());
124 } 124 }
125 125