Browse Source

refactoring: change checkWin

main
fdai7793 11 months ago
parent
commit
2ebe20e612
  1. 2
      src/main/java/de/hsfulda/onses/models/Game.java
  2. 6
      src/main/java/de/hsfulda/onses/services/GameService.java

2
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<Card> drawCardDeck = new ArrayList<>();

6
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);
}
}

Loading…
Cancel
Save