diff options
author | pacien | 2018-02-03 22:44:09 +0100 |
---|---|---|
committer | pacien | 2018-02-03 22:44:09 +0100 |
commit | 30f734d6b8602410e7d57d2f9f9bd4814df9fefe (patch) | |
tree | ef4960f58ebde41d6b1b634683015adb15db6b0e /src/main/java | |
parent | e8675bbf9b2841bb209ca8ae11eaaf379b78470c (diff) | |
download | wallj-30f734d6b8602410e7d57d2f9f9bd4814df9fefe.tar.gz |
Add simulation starting condition check
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/block/RobotBlock.java | 3 | ||||
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/context/Stage.java | 13 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/block/RobotBlock.java b/src/main/java/fr/umlv/java/wallj/block/RobotBlock.java index e4e0aad..4d7745b 100644 --- a/src/main/java/fr/umlv/java/wallj/block/RobotBlock.java +++ b/src/main/java/fr/umlv/java/wallj/block/RobotBlock.java | |||
@@ -23,7 +23,6 @@ import java.util.List; | |||
23 | */ | 23 | */ |
24 | public class RobotBlock extends Block { | 24 | public class RobotBlock extends Block { |
25 | private static final float SPEED = 10f; // px/ms | 25 | private static final float SPEED = 10f; // px/ms |
26 | private static final int MAX_BOMB_PLACEMENTS = 3; | ||
27 | 26 | ||
28 | private Vec2 pos; | 27 | private Vec2 pos; |
29 | private PathFinder pathFinder; | 28 | private PathFinder pathFinder; |
@@ -69,7 +68,7 @@ public class RobotBlock extends Block { | |||
69 | } | 68 | } |
70 | 69 | ||
71 | private List<Event> dropBomb(BombSetupOrder order) { | 70 | private List<Event> dropBomb(BombSetupOrder order) { |
72 | if (droppedBombCount >= MAX_BOMB_PLACEMENTS) return Collections.emptyList(); | 71 | if (droppedBombCount >= Stage.BOMB_PLACEMENTS) return Collections.emptyList(); |
73 | 72 | ||
74 | droppedBombCount++; | 73 | droppedBombCount++; |
75 | return Collections.singletonList(new BlockCreateEvent(BlockType.BOMB, getTile())); | 74 | return Collections.singletonList(new BlockCreateEvent(BlockType.BOMB, getTile())); |
diff --git a/src/main/java/fr/umlv/java/wallj/context/Stage.java b/src/main/java/fr/umlv/java/wallj/context/Stage.java index 49aa196..9737583 100644 --- a/src/main/java/fr/umlv/java/wallj/context/Stage.java +++ b/src/main/java/fr/umlv/java/wallj/context/Stage.java | |||
@@ -17,6 +17,7 @@ import java.util.*; | |||
17 | * @author Pacien TRAN-GIRARD | 17 | * @author Pacien TRAN-GIRARD |
18 | */ | 18 | */ |
19 | public class Stage implements Updateable { | 19 | public class Stage implements Updateable { |
20 | public static final int BOMB_PLACEMENTS = 3; | ||
20 | private static final int VELOCITY_TICK_PER_MS = 6; | 21 | private static final int VELOCITY_TICK_PER_MS = 6; |
21 | private static final int POSITION_TICK_PER_MS = 2; | 22 | private static final int POSITION_TICK_PER_MS = 2; |
22 | 23 | ||
@@ -60,7 +61,17 @@ public class Stage implements Updateable { | |||
60 | * @implNote TODO: profile this and consider a garbage block counter | 61 | * @implNote TODO: profile this and consider a garbage block counter |
61 | */ | 62 | */ |
62 | public boolean isCleared() { | 63 | public boolean isCleared() { |
63 | return blocks.stream().noneMatch(block -> block.getType() == BlockType.GARBAGE); | 64 | return blocks.stream() |
65 | .noneMatch(block -> block.getType() == BlockType.GARBAGE); | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * @return T(the physics simulation can start, i.e. the player has placed all their bombs) | ||
70 | */ | ||
71 | public boolean isReady() { | ||
72 | return blocks.stream() | ||
73 | .filter(block -> block.getType() == BlockType.BOMB) | ||
74 | .count() == BOMB_PLACEMENTS; | ||
64 | } | 75 | } |
65 | 76 | ||
66 | /** | 77 | /** |