From 2ebe20e6129ddcd1d492c3e0107bb34068784d3a Mon Sep 17 00:00:00 2001 From: fdai7793 Date: Tue, 6 Feb 2024 21:25:24 +0100 Subject: [PATCH] refactoring: change checkWin --- src/main/java/de/hsfulda/onses/models/Game.java | 2 +- src/main/java/de/hsfulda/onses/services/GameService.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/models/Game.java b/src/main/java/de/hsfulda/onses/models/Game.java index 5072b7c..893fbb2 100644 --- a/src/main/java/de/hsfulda/onses/models/Game.java +++ b/src/main/java/de/hsfulda/onses/models/Game.java @@ -10,7 +10,7 @@ public class Game { private GameService gameService; private PlayerService playerService; - private boolean gameOver; + private boolean gameOver = false; private final ArrayList drawCardDeck = new ArrayList<>(); diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index ea8824f..129790f 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -108,10 +108,8 @@ public class GameService { } public void checkForWin() { - if (this.game.getPlayerService().getPlayerList().getFirst().getPlayerDeck().isEmpty()) { - System.out.println("Player wins"); - } else if (this.game.getPlayerService().getPlayerList().getLast().getPlayerDeck().isEmpty()) { - System.out.println("Bot wins"); + if (this.game.getPlayerService().getPlayerList().getFirst().getPlayerDeck().isEmpty() || this.game.getPlayerService().getPlayerList().getLast().getPlayerDeck().isEmpty()) { + this.game.setGameOver(true); } }