From 59cae272f6a8c6f943ff6b0b6c69117f94c1625c Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sat, 3 Feb 2018 01:30:55 +0100 Subject: Refactoring Game --- src/main/java/fr/umlv/java/wallj/context/Game.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/main') 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 { } + + private void goToNext(){ + if (hasNextBoard()) { //continue + nextStage(); + return; + } + setOver(); + } private void handleEvents(Context context) { if (Events.findFirst(context.getEvents(), QuitGameOrder.class).isPresent()) { context.getGame().setOver(); @@ -81,11 +89,7 @@ public final class Game implements Updateable { } if (Events.findFirst(context.getEvents(), ConfirmOrder.class).isPresent()) { if (currentStage.isCleared()) { - if (context.getGame().hasNextBoard()) { //continue - context.getGame().nextStage(); - } else { //no more board so game over => exiting - setOver(); - } + goToNext(); return; } retryStage(); -- cgit v1.2.3