diff options
Diffstat (limited to 'src/main/java/fr')
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/context/Game.java | 30 | ||||
-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.java | 4 |
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 @@ | |||
1 | package fr.umlv.java.wallj.context; | 1 | package fr.umlv.java.wallj.context; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.board.Board; | 3 | import fr.umlv.java.wallj.board.Board; |
4 | import fr.umlv.java.wallj.event.ConfirmOrder; | 4 | import fr.umlv.java.wallj.event.*; |
5 | import fr.umlv.java.wallj.event.Event; | ||
6 | import fr.umlv.java.wallj.event.Events; | ||
7 | import fr.umlv.java.wallj.event.GameOverEvent; | ||
8 | 5 | ||
9 | import java.util.*; | 6 | import 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 | */ |
8 | public final class GameOverEvent implements GameEvent { | 8 | public 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; | |||
3 | import fr.umlv.java.wallj.board.TileVec2; | 3 | import fr.umlv.java.wallj.board.TileVec2; |
4 | import fr.umlv.java.wallj.event.BombSetupOrder; | 4 | import fr.umlv.java.wallj.event.BombSetupOrder; |
5 | import fr.umlv.java.wallj.event.ConfirmOrder; | 5 | import fr.umlv.java.wallj.event.ConfirmOrder; |
6 | import fr.umlv.java.wallj.event.GameOverEvent; | 6 | import fr.umlv.java.wallj.event.QuitGameOrder; |
7 | import fr.umlv.java.wallj.event.MoveRobotOrder; | 7 | import fr.umlv.java.wallj.event.MoveRobotOrder; |
8 | import fr.umlv.zen5.ApplicationContext; | 8 | import fr.umlv.zen5.ApplicationContext; |
9 | import fr.umlv.zen5.Event; | 9 | import 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 | } |