From 60366705c2e296f4b2db6664c3a6cb421976d294 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 10 Apr 2016 09:31:03 +0200 Subject: Fix and simplify blasts propagation --- src/ch/epfl/xblast/server/Block.java | 9 +++++++++ src/ch/epfl/xblast/server/GameState.java | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') 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 @@ -86,6 +86,15 @@ public enum Block { return this == INDESTRUCTIBLE_WALL || this == DESTRUCTIBLE_WALL || this == CRUMBLING_WALL; } + /** + * Returns T(this block is destructible). + * + * @return T(this block is destructible) + */ + public boolean isDestructible() { + return this != INDESTRUCTIBLE_WALL; + } + /** * Returns 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 { private static List> nextBlasts(List> blasts0, Board board0, List>> explosions0) { return Stream.concat( blasts0.stream() - .filter(b -> !b.tail().isEmpty()) .filter(b -> board0.blockAt(b.head()).isFree()) .map(Sq::tail), explosions0.stream() .filter(e -> !e.isEmpty()) - .map(Sq::head) - .filter(b -> !b.isEmpty())) + .map(Sq::head)) + .filter(b -> !b.isEmpty()) + .filter(b -> board0.blockAt(b.head()).isDestructible()) .collect(Collectors.toList()); } -- cgit v1.2.3