diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index 2514ae7..f7618f7 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -32,14 +32,16 @@ public class GameService { public void drawCard(int amount) { Player player = null; - if (game.getPlayerService().getCurrentTurn()) { - player = game.getPlayerService().getPlayerList().getFirst(); - } else { - player = game.getPlayerService().getPlayerList().getLast(); - } - for (int i = 0; i < amount; i++) { - player.getPlayerDeck().add(game.getDrawCardDeck().getFirst()); - game.getDrawCardDeck().removeFirst(); + if (!game.getDrawCardDeck().isEmpty()) { + if (game.getPlayerService().getCurrentTurn()) { + player = game.getPlayerService().getPlayerList().getFirst(); + } else { + player = game.getPlayerService().getPlayerList().getLast(); + } + for (int i = 0; i < amount; i++) { + player.getPlayerDeck().add(game.getDrawCardDeck().getFirst()); + game.getDrawCardDeck().removeFirst(); + } } if (amount != 1) { nextPlayer();