diff options
author | Adam NAILI | 2018-02-01 21:27:34 +0100 |
---|---|---|
committer | Adam NAILI | 2018-02-01 21:27:34 +0100 |
commit | f523cd1030de8cc006f41752ea326ae778980820 (patch) | |
tree | 559bf25f0f57c379b1e67c7895a34477960ef0cd /src/main/java/fr/umlv | |
parent | a07c49065165b2f896684a57d647f2b1a13b68ca (diff) | |
download | wallj-f523cd1030de8cc006f41752ea326ae778980820.tar.gz |
Usage of findFirst in GameStateController
Diffstat (limited to 'src/main/java/fr/umlv')
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/controller/GameStateController.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/controller/GameStateController.java b/src/main/java/fr/umlv/java/wallj/controller/GameStateController.java index d7b1638..7f0464c 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/GameStateController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/GameStateController.java | |||
@@ -13,19 +13,18 @@ public class GameStateController implements Controller { | |||
13 | 13 | ||
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 ConfirmOrder); | 16 | boolean isConfirmOrder = Event.findFirst(context.getEvents(),ConfirmOrder.class).isPresent(); |
17 | boolean isGameOverEvent = context.getEvents().stream().anyMatch(event -> event instanceof GameOverEvent); | 17 | boolean isGameOverEvent = Event.findFirst(context.getEvents(),GameOverEvent.class).isPresent(); |
18 | Game currentGame = context.getGame(); | 18 | Game currentGame = context.getGame(); |
19 | LinkedList<Event> events = new LinkedList<>(); | 19 | LinkedList<Event> events = new LinkedList<>(); |
20 | //TODO exiting | ||
21 | if (isGameOverEvent) { | 20 | if (isGameOverEvent) { |
22 | currentGame.setOver(); | 21 | currentGame.setOver(); |
23 | } else { | 22 | } else { |
24 | if (isConfirmEvent) { | 23 | if (isConfirmOrder) { |
25 | if (currentGame.getCurrentStage().isCleared()) { | 24 | if (currentGame.getCurrentStage().isCleared()) { |
26 | if (currentGame.hasNextBoard()) { //continue | 25 | if (currentGame.hasNextBoard()) { //continue |
27 | currentGame.nextStage(); | 26 | currentGame.nextStage(); |
28 | } else { //no more board so game over | 27 | } else { //no more board so game over => exiting |
29 | currentGame.setOver(); | 28 | currentGame.setOver(); |
30 | } | 29 | } |
31 | } else {//retry | 30 | } else {//retry |