aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/fr
diff options
context:
space:
mode:
authorpacien2018-02-02 11:46:03 +0100
committerpacien2018-02-02 11:46:03 +0100
commit6d05e0e8b91ccdd69a8f45227104a543febf5982 (patch)
tree0d6a113121f21dfcde240deeb16968c9d4540d71 /src/main/java/fr
parenta70916c1aba32f9ea52221e30e3882786911aaf2 (diff)
downloadwallj-6d05e0e8b91ccdd69a8f45227104a543febf5982.tar.gz
Implement bomb explosion and deletion event generation
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src/main/java/fr')
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/BombBlock.java5
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/BombExplosionEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java4
4 files changed, 7 insertions, 6 deletions
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;
3import fr.umlv.java.wallj.board.TileVec2; 3import fr.umlv.java.wallj.board.TileVec2;
4import fr.umlv.java.wallj.context.Context; 4import fr.umlv.java.wallj.context.Context;
5import fr.umlv.java.wallj.context.GraphicsContext; 5import fr.umlv.java.wallj.context.GraphicsContext;
6import fr.umlv.java.wallj.event.*;
6import fr.umlv.java.wallj.event.Event; 7import fr.umlv.java.wallj.event.Event;
7import org.jbox2d.common.Vec2; 8import org.jbox2d.common.Vec2;
8import org.jbox2d.dynamics.BodyType; 9import org.jbox2d.dynamics.BodyType;
@@ -47,14 +48,14 @@ public class BombBlock extends JBoxBlock {
47 } 48 }
48 49
49 private boolean containsUpdateEvent(List<Event> events) { 50 private boolean containsUpdateEvent(List<Event> events) {
50 return false; // TODO: contains PutBombEvent with same current tile location? 51 return Events.findFirst(events, BombSetupEvent.class).isPresent();
51 } 52 }
52 53
53 private List<Event> consume(Duration timeDelta) { 54 private List<Event> consume(Duration timeDelta) {
54 decrementTimer(timeDelta); 55 decrementTimer(timeDelta);
55 56
56 if (timer.isNegative()) 57 if (timer.isNegative())
57 return Collections.unmodifiableList(Arrays.asList()); // TODO: BombExplosionEvent and BlockRemoveEvent 58 return Arrays.asList(new BombExplosionEvent(TileVec2.of(getPos())), new BlockDestroyEvent(this));
58 else 59 else
59 return Collections.emptyList(); 60 return Collections.emptyList();
60 } 61 }
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;
9 * 9 *
10 * @author Pacien TRAN-GIRARD 10 * @author Pacien TRAN-GIRARD
11 */ 11 */
12public final class BombExplosionEvent { 12public final class BombExplosionEvent implements GameEvent {
13 private final TileVec2 source; 13 private final TileVec2 source;
14 14
15 public BombExplosionEvent(TileVec2 source) { 15 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;
5import java.util.Objects; 5import java.util.Objects;
6 6
7/** 7/**
8 * Bomb setup event. 8 * Bomb setup event signalling the creation or the update of a bomb at a given position.
9 * 9 *
10 * @author Pacien TRAN-GIRARD 10 * @author Pacien TRAN-GIRARD
11 */ 11 */
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 @@
1package fr.umlv.java.wallj.event; 1package fr.umlv.java.wallj.event;
2 2
3/** 3/**
4 * Event to signal that a bomb will be placed at the next tick 4 * Asks a robot to drop a bomb.
5 * 5 *
6 * @author Adam NAILI 6 * @author Pacien TRAN-GIRARD
7 */ 7 */
8public final class BombSetupOrder implements InputEvent { 8public final class BombSetupOrder implements InputEvent {
9 // void 9 // void