aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/fr/umlv/java/wallj/Main.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/Stage.java3
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Game.java3
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/InputHandler.java8
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/GameController.java17
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/GarbagePhysicsController.java3
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/StageController.java3
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/TrashPhysicsController.java3
-rw-r--r--src/main/java/fr/umlv/java/wallj/viewer/Viewer.java10
9 files changed, 38 insertions, 14 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/Main.java b/src/main/java/fr/umlv/java/wallj/Main.java
index 0ac4136..37a99b0 100644
--- a/src/main/java/fr/umlv/java/wallj/Main.java
+++ b/src/main/java/fr/umlv/java/wallj/Main.java
@@ -27,7 +27,7 @@ public class Main {
27 paths.add(Paths.get(string)); 27 paths.add(Paths.get(string));
28 } 28 }
29 } else { 29 } else {
30 paths.add(getResourcePath("/maps/smallvalid.txt")); 30 paths.add(getResourcePath("/maps/level0.txt"));
31 } 31 }
32 return paths; 32 return paths;
33 } 33 }
diff --git a/src/main/java/fr/umlv/java/wallj/block/Stage.java b/src/main/java/fr/umlv/java/wallj/block/Stage.java
index d34af97..5d2d07c 100644
--- a/src/main/java/fr/umlv/java/wallj/block/Stage.java
+++ b/src/main/java/fr/umlv/java/wallj/block/Stage.java
@@ -4,6 +4,7 @@ import fr.umlv.java.wallj.board.Board;
4import fr.umlv.java.wallj.context.Context; 4import fr.umlv.java.wallj.context.Context;
5import fr.umlv.java.wallj.event.Event; 5import fr.umlv.java.wallj.event.Event;
6 6
7import java.util.Collections;
7import java.util.List; 8import java.util.List;
8import java.util.Objects; 9import java.util.Objects;
9 10
@@ -31,7 +32,7 @@ public class Stage {
31 */ 32 */
32 public List<Event> update(Context context) { 33 public List<Event> update(Context context) {
33 //TODO 34 //TODO
34 return null; 35 return Collections.emptyList();
35 } 36 }
36 37
37 public boolean isCleared() { 38 public boolean isCleared() {
diff --git a/src/main/java/fr/umlv/java/wallj/context/Game.java b/src/main/java/fr/umlv/java/wallj/context/Game.java
index d5f9873..62454b0 100644
--- a/src/main/java/fr/umlv/java/wallj/context/Game.java
+++ b/src/main/java/fr/umlv/java/wallj/context/Game.java
@@ -64,7 +64,8 @@ public final class Game {
64 public boolean isOver() { 64 public boolean isOver() {
65 return over; 65 return over;
66 } 66 }
67 public void setOver(){ 67
68 public void setOver() {
68 over = true; 69 over = true;
69 } 70 }
70 71
diff --git a/src/main/java/fr/umlv/java/wallj/context/InputHandler.java b/src/main/java/fr/umlv/java/wallj/context/InputHandler.java
index 1a64667..faa80a7 100644
--- a/src/main/java/fr/umlv/java/wallj/context/InputHandler.java
+++ b/src/main/java/fr/umlv/java/wallj/context/InputHandler.java
@@ -1,7 +1,9 @@
1package fr.umlv.java.wallj.context; 1package fr.umlv.java.wallj.context;
2 2
3import fr.umlv.java.wallj.board.TileVec2; 3import fr.umlv.java.wallj.board.TileVec2;
4import fr.umlv.java.wallj.event.ConfirmEvent;
4import fr.umlv.java.wallj.event.DropBombEvent; 5import fr.umlv.java.wallj.event.DropBombEvent;
6import fr.umlv.java.wallj.event.GameOverEvent;
5import fr.umlv.java.wallj.event.MoveRobotEvent; 7import fr.umlv.java.wallj.event.MoveRobotEvent;
6import fr.umlv.zen5.ApplicationContext; 8import fr.umlv.zen5.ApplicationContext;
7import fr.umlv.zen5.Event; 9import fr.umlv.zen5.Event;
@@ -53,6 +55,12 @@ public final class InputHandler {
53 case SPACE: 55 case SPACE:
54 events.add(new DropBombEvent()); 56 events.add(new DropBombEvent());
55 break; 57 break;
58 case R:
59 events.add(new ConfirmEvent());
60 break;
61 case Q:
62 events.add(new GameOverEvent());
63 break;
56 } 64 }
57 } 65 }
58 } 66 }
diff --git a/src/main/java/fr/umlv/java/wallj/controller/GameController.java b/src/main/java/fr/umlv/java/wallj/controller/GameController.java
index 456793a..df4eade 100644
--- a/src/main/java/fr/umlv/java/wallj/controller/GameController.java
+++ b/src/main/java/fr/umlv/java/wallj/controller/GameController.java
@@ -14,23 +14,24 @@ public class GameController implements Controller {
14 @Override 14 @Override
15 public List<Event> update(Context context) { 15 public List<Event> update(Context context) {
16 boolean isConfirmEvent = context.getEvents().stream().anyMatch(event -> event instanceof ConfirmEvent); 16 boolean isConfirmEvent = context.getEvents().stream().anyMatch(event -> event instanceof ConfirmEvent);
17 boolean isGameOver = context.getEvents().stream().allMatch(event -> event instanceof GameOverEvent); 17 boolean isGameOverEvent = context.getEvents().stream().anyMatch(event -> event instanceof GameOverEvent);
18
18 Game currentGame = context.getGame(); 19 Game currentGame = context.getGame();
19 LinkedList<Event> events = new LinkedList<>(); 20 LinkedList<Event> events = new LinkedList<>();
20 if (isConfirmEvent) { 21 //TODO exiting
21 //TODO exiting 22 if (isGameOverEvent) {
22 if (!isGameOver) { 23 currentGame.setOver();
24 } else {
25 if (isConfirmEvent) {
23 if (currentGame.getCurrentStage().isCleared()) { 26 if (currentGame.getCurrentStage().isCleared()) {
24 if (currentGame.hasNextBoard()) { //continue 27 if (currentGame.hasNextBoard()) { //continue
25 currentGame.nextStage(); 28 currentGame.nextStage();
26 } else { 29 } else { //no more board so game over
27 events.add(new GameOverEvent()); 30 currentGame.setOver();
28 } 31 }
29 } else {//retry 32 } else {//retry
30 currentGame.retryStage(); 33 currentGame.retryStage();
31 } 34 }
32 } else {
33 currentGame.setOver();
34 } 35 }
35 } 36 }
36 return events; 37 return events;
diff --git a/src/main/java/fr/umlv/java/wallj/controller/GarbagePhysicsController.java b/src/main/java/fr/umlv/java/wallj/controller/GarbagePhysicsController.java
index f8a7c36..16adeba 100644
--- a/src/main/java/fr/umlv/java/wallj/controller/GarbagePhysicsController.java
+++ b/src/main/java/fr/umlv/java/wallj/controller/GarbagePhysicsController.java
@@ -4,6 +4,7 @@ import fr.umlv.java.wallj.context.Context;
4import fr.umlv.java.wallj.event.Event; 4import fr.umlv.java.wallj.event.Event;
5import fr.umlv.java.wallj.block.GarbageBlock; 5import fr.umlv.java.wallj.block.GarbageBlock;
6 6
7import java.util.Collections;
7import java.util.List; 8import java.util.List;
8import java.util.Objects; 9import java.util.Objects;
9 10
@@ -19,7 +20,7 @@ public class GarbagePhysicsController extends PhysicsController {
19 @Override 20 @Override
20 public List<Event> update(Context context) { 21 public List<Event> update(Context context) {
21 //TODO 22 //TODO
22 return null; 23 return Collections.emptyList();
23 } 24 }
24 25
25} 26}
diff --git a/src/main/java/fr/umlv/java/wallj/controller/StageController.java b/src/main/java/fr/umlv/java/wallj/controller/StageController.java
index d62e246..57a87fd 100644
--- a/src/main/java/fr/umlv/java/wallj/controller/StageController.java
+++ b/src/main/java/fr/umlv/java/wallj/controller/StageController.java
@@ -3,6 +3,7 @@ package fr.umlv.java.wallj.controller;
3import fr.umlv.java.wallj.context.Context; 3import fr.umlv.java.wallj.context.Context;
4import fr.umlv.java.wallj.event.Event; 4import fr.umlv.java.wallj.event.Event;
5 5
6import java.util.Collections;
6import java.util.List; 7import java.util.List;
7 8
8public class StageController implements Controller { 9public class StageController implements Controller {
@@ -10,7 +11,7 @@ public class StageController implements Controller {
10 11
11 @Override 12 @Override
12 public List<Event> update(Context context) { 13 public List<Event> update(Context context) {
13 return null; 14 return Collections.emptyList();
14 } 15 }
15 16
16} 17}
diff --git a/src/main/java/fr/umlv/java/wallj/controller/TrashPhysicsController.java b/src/main/java/fr/umlv/java/wallj/controller/TrashPhysicsController.java
index 323f044..310a00f 100644
--- a/src/main/java/fr/umlv/java/wallj/controller/TrashPhysicsController.java
+++ b/src/main/java/fr/umlv/java/wallj/controller/TrashPhysicsController.java
@@ -4,6 +4,7 @@ import fr.umlv.java.wallj.context.Context;
4import fr.umlv.java.wallj.event.Event; 4import fr.umlv.java.wallj.event.Event;
5import fr.umlv.java.wallj.block.TrashBlock; 5import fr.umlv.java.wallj.block.TrashBlock;
6 6
7import java.util.Collections;
7import java.util.List; 8import java.util.List;
8import java.util.Objects; 9import java.util.Objects;
9 10
@@ -19,7 +20,7 @@ public class TrashPhysicsController extends PhysicsController {
19 @Override 20 @Override
20 public List<Event> update(Context context) { 21 public List<Event> update(Context context) {
21 //TODO 22 //TODO
22 return null; 23 return Collections.emptyList();
23 } 24 }
24 25
25} 26}
diff --git a/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java b/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
index a87f418..857453c 100644
--- a/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
+++ b/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
@@ -27,6 +27,7 @@ import java.util.Objects;
27public final class Viewer { 27public final class Viewer {
28 28
29 private final Game currentGame; 29 private final Game currentGame;
30