Browse Source

unable to draw from empty DrawCardDeck

main
fdai7920 11 months ago
parent
commit
ddfb8e271b
  1. 18
      src/main/java/de/hsfulda/onses/services/GameService.java

18
src/main/java/de/hsfulda/onses/services/GameService.java

@ -32,14 +32,16 @@ public class GameService {
public void drawCard(int amount) { public void drawCard(int amount) {
Player player = null; 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) { if (amount != 1) {
nextPlayer(); nextPlayer();

Loading…
Cancel
Save