From 6d05e0e8b91ccdd69a8f45227104a543febf5982 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 2 Feb 2018 11:46:03 +0100 Subject: Implement bomb explosion and deletion event generation Signed-off-by: pacien --- src/main/java/fr/umlv/java/wallj/block/BombBlock.java | 5 +++-- src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java | 2 +- src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java | 2 +- src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main') diff --git a/src/main/java/fr/umlv/java/wallj/block/BombBlock.java b/src/main/java/fr/umlv/java/wallj/block/BombBlock.java index f58f1cc..baf10b3 100644 --- a/src/main/java/fr/umlv/java/wallj/block/BombBlock.java +++ b/src/main/java/fr/umlv/java/wallj/block/BombBlock.java @@ -3,6 +3,7 @@ package fr.umlv.java.wallj.block; import fr.umlv.java.wallj.board.TileVec2; import fr.umlv.java.wallj.context.Context; import fr.umlv.java.wallj.context.GraphicsContext; +import fr.umlv.java.wallj.event.*; import fr.umlv.java.wallj.event.Event; import org.jbox2d.common.Vec2; import org.jbox2d.dynamics.BodyType; @@ -47,14 +48,14 @@ public class BombBlock extends JBoxBlock { } private boolean containsUpdateEvent(List events) { - return false; // TODO: contains PutBombEvent with same current tile location? + return Events.findFirst(events, BombSetupEvent.class).isPresent(); } private List consume(Duration timeDelta) { decrementTimer(timeDelta); if (timer.isNegative()) - return Collections.unmodifiableList(Arrays.asList()); // TODO: BombExplosionEvent and BlockRemoveEvent + return Arrays.asList(new BombExplosionEvent(TileVec2.of(getPos())), new BlockDestroyEvent(this)); else return Collections.emptyList(); } diff --git a/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java b/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java index c0baa83..577371d 100644 --- a/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java +++ b/src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java @@ -9,7 +9,7 @@ import java.util.Objects; * * @author Pacien TRAN-GIRARD */ -public final class BombExplosionEvent { +public final class BombExplosionEvent implements GameEvent { private final TileVec2 source; public BombExplosionEvent(TileVec2 source) { diff --git a/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java b/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java index 2e5cf98..620eea2 100644 --- a/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java +++ b/src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java @@ -5,7 +5,7 @@ import fr.umlv.java.wallj.board.TileVec2; import java.util.Objects; /** - * Bomb setup event. + * Bomb setup event signalling the creation or the update of a bomb at a given position. * * @author Pacien TRAN-GIRARD */ diff --git a/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java b/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java index 25f0048..9e95eb3 100644 --- a/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java +++ b/src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java @@ -1,9 +1,9 @@ package fr.umlv.java.wallj.event; /** - * Event to signal that a bomb will be placed at the next tick + * Asks a robot to drop a bomb. * - * @author Adam NAILI + * @author Pacien TRAN-GIRARD */ public final class BombSetupOrder implements InputEvent { // void -- cgit v1.2.3