aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/fr
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/fr')
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Game.java30
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/QuitGameOrder.java (renamed from src/main/java/fr/umlv/java/wallj/event/GameOverEvent.java)3
-rw-r--r--src/main/java/fr/umlv/java/wallj/viewer/InputHandler.java4
3 files changed, 21 insertions, 16 deletions
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 422e9b7..56e380f 100644
--- a/src/main/java/fr/umlv/java/wallj/context/Game.java
+++ b/src/main/java/fr/umlv/java/wallj/context/Game.java
@@ -1,10 +1,7 @@
1package fr.umlv.java.wallj.context; 1package fr.umlv.java.wallj.context;
2 2
3import fr.umlv.java.wallj.board.Board; 3import fr.umlv.java.wallj.board.Board;
4import fr.umlv.java.wallj.event.ConfirmOrder; 4import fr.umlv.java.wallj.event.*;
5import fr.umlv.java.wallj.event.Event;
6import fr.umlv.java.wallj.event.Events;
7import fr.umlv.java.wallj.event.GameOverEvent;
8 5
9import java.util.*; 6import java.util.*;
10 7
@@ -76,21 +73,32 @@ public final class Game implements Updateable {
76 currentStage = new Stage(currentStage.getBoard()); 73 currentStage = new Stage(currentStage.getBoard());
77 } 74 }
78 75
76
77 private void handleEvents(Context context){
78 if (Events.findFirst(context.getEvents(), QuitGameOrder.class).isPresent()){
79 context.getGame().setOver();
80 return;
81 }
82 if (Events.findFirst(context.getEvents(), ConfirmOrder.class).isPresent()){
83
84 }
85 }
79 /** 86 /**
80 * @param context the current context 87 * @param context the current context
81 * @return a list of new events 88 * @return a list of new events
82 */ 89 */
83 @Override 90 @Override
84 public List<Event> update(Context context) { 91 public List<Event> update(Context context) {
85 boolean isConfirmOrder = Events.findFirst(context.getEvents(),ConfirmOrder.class).isPresent(); 92 boolean isConfirmOrder = Events.findFirst(context.getEvents(), ConfirmOrder.class).isPresent();
86 boolean isGameOverEvent = Events.findFirst(context.getEvents(),GameOverEvent.class).isPresent(); 93 boolean isQuitGameOrder = Events.findFirst(context.getEvents(), QuitGameOrder.class).isPresent();
94 boolean isStageCleared = Events.findFirst(context.getEvents(), StageClearedEvent.class).isPresent();
95
87 Game currentGame = context.getGame(); 96 Game currentGame = context.getGame();
88 LinkedList<Event> events = new LinkedList<>(); 97 if (isQuitGameOrder) {
89 if (isGameOverEvent) {
90 currentGame.setOver(); 98 currentGame.setOver();
91 } else { 99 } else {
92 if (isConfirmOrder) { 100 if (isConfirmOrder) {
93 if (false /*currentGame.getCurrentStage().isCleared()*/) { // FIXME: use StageClearedEvent 101 if (isStageCleared) {
94 if (currentGame.hasNextBoard()) { //continue 102 if (currentGame.hasNextBoard()) { //continue
95 currentGame.nextStage(); 103 currentGame.nextStage();
96 } else { //no more board so game over => exiting 104 } else { //no more board so game over => exiting
@@ -101,9 +109,7 @@ public final class Game implements Updateable {
101 } 109 }
102 } 110 }
103 } 111 }
104 112 return currentStage.update(context);
105 // FIXME: update underlying stage and merge generated events
106 return events;
107 } 113 }
108 114
109 115
diff --git a/src/main/java/fr/umlv/java/wallj/event/GameOverEvent.java b/src/main/java/fr/umlv/java/wallj/event/QuitGameOrder.java
index 4365dc4..2cabac1 100644
--- a/src/main/java/fr/umlv/java/wallj/event/GameOverEvent.java
+++ b/src/main/java/fr/umlv/java/wallj/event/QuitGameOrder.java
@@ -5,6 +5,5 @@ package fr.umlv.java.wallj.event;
5 * 5 *
6 * @author Pacien TRAN-GIRARD 6 * @author Pacien TRAN-GIRARD
7 */ 7 */
8public final class GameOverEvent implements GameEvent { 8public final class QuitGameOrder implements InputEvent {
9 // void
10} 9}
diff --git a/src/main/java/fr/umlv/java/wallj/viewer/InputHandler.java b/src/main/java/fr/umlv/java/wallj/viewer/InputHandler.java
index a8f53d3..9eea443 100644
--- a/src/main/java/fr/umlv/java/wallj/viewer/InputHandler.java
+++ b/src/main/java/fr/umlv/java/wallj/viewer/InputHandler.java
@@ -3,7 +3,7 @@ package fr.umlv.java.wallj.viewer;
3import fr.umlv.java.wallj.board.TileVec2; 3import fr.umlv.java.wallj.board.TileVec2;
4import fr.umlv.java.wallj.event.BombSetupOrder; 4import fr.umlv.java.wallj.event.BombSetupOrder;
5import fr.umlv.java.wallj.event.ConfirmOrder; 5import fr.umlv.java.wallj.event.ConfirmOrder;
6import fr.umlv.java.wallj.event.GameOverEvent; 6import fr.umlv.java.wallj.event.QuitGameOrder;
7import fr.umlv.java.wallj.event.MoveRobotOrder; 7import fr.umlv.java.wallj.event.MoveRobotOrder;
8import fr.umlv.zen5.ApplicationContext; 8import fr.umlv.zen5.ApplicationContext;
9import fr.umlv.zen5.Event; 9import fr.umlv.zen5.Event;
@@ -58,7 +58,7 @@ public final class InputHandler {
58 events.add(new ConfirmOrder()); 58 events.add(new ConfirmOrder());
59 break; 59 break;
60 case Q: 60 case Q:
61 events.add(new GameOverEvent()); 61 events.add(new QuitGameOrder());
62 break; 62 break;
63 } 63 }
64 } 64 }