diff options
author | Adam NAILI | 2018-02-03 01:30:55 +0100 |
---|---|---|
committer | Adam NAILI | 2018-02-03 01:30:55 +0100 |
commit | 59cae272f6a8c6f943ff6b0b6c69117f94c1625c (patch) | |
tree | f36b93b9c421c9672f6779cf60ad171a0a21dc5d | |
parent | 8145b79a20d288b79ea6ad3af57615ce88b7ff82 (diff) | |
download | wallj-59cae272f6a8c6f943ff6b0b6c69117f94c1625c.tar.gz |
Refactoring Game
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/context/Game.java | 14 |
1 files changed, 9 insertions, 5 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 842d484..46de147 100644 --- a/src/main/java/fr/umlv/java/wallj/context/Game.java +++ b/src/main/java/fr/umlv/java/wallj/context/Game.java | |||
@@ -74,6 +74,14 @@ public final class Game implements Updateable { | |||
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | |||
78 | private void goToNext(){ | ||
79 | if (hasNextBoard()) { //continue | ||
80 | nextStage(); | ||
81 | return; | ||
82 | } | ||
83 | setOver(); | ||
84 | } | ||
77 | private void handleEvents(Context context) { | 85 | private void handleEvents(Context context) { |
78 | if (Events.findFirst(context.getEvents(), QuitGameOrder.class).isPresent()) { | 86 | if (Events.findFirst(context.getEvents(), QuitGameOrder.class).isPresent()) { |
79 | context.getGame().setOver(); | 87 | context.getGame().setOver(); |
@@ -81,11 +89,7 @@ public final class Game implements Updateable { | |||
81 | } | 89 | } |
82 | if (Events.findFirst(context.getEvents(), ConfirmOrder.class).isPresent()) { | 90 | if (Events.findFirst(context.getEvents(), ConfirmOrder.class).isPresent()) { |
83 | if (currentStage.isCleared()) { | 91 | if (currentStage.isCleared()) { |
84 | if (context.getGame().hasNextBoard()) { //continue | 92 | goToNext(); |
85 | context.getGame().nextStage(); | ||
86 | } else { //no more board so game over => exiting | ||
87 | setOver(); | ||
88 | } | ||
89 | return; | 93 | return; |
90 | } | 94 | } |
91 | retryStage(); | 95 | retryStage(); |