Browse Source

refactoring: add set player ad cardDraw

main^2
fdai7736 11 months ago
parent
commit
019515e7a0
  1. 6
      src/main/java/de/hsfulda/onses/services/GameService.java

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

@ -54,7 +54,8 @@ public class GameService {
player = game.getPlayerService().getPlayerList().getLast(); player = game.getPlayerService().getPlayerList().getLast();
} }
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
player.getPlayerDeck().add(game.getDrawCardDeck().getFirst().setFacedown(isFaceDown));
Card newCard = game.getDrawCardDeck().getFirst().setFacedown(isFaceDown).setPlayer(player);
player.getPlayerDeck().add(newCard);
game.getDrawCardDeck().removeFirst(); game.getDrawCardDeck().removeFirst();
} }
if (amount == 1 && !player.getPlayerDeck().isEmpty()) { if (amount == 1 && !player.getPlayerDeck().isEmpty()) {
@ -133,6 +134,9 @@ public class GameService {
} }
public void playCard(Card card) { public void playCard(Card card) {
if(card.getPlayer() != null) {
card.getPlayer().removeCardFromPlayerDeck(card);
}
// add lastPlayedCard back to drawCardDeck // add lastPlayedCard back to drawCardDeck
this.addLastPlayedCardToDrawCardDeck(); this.addLastPlayedCardToDrawCardDeck();
game.setLastPlayedCard(card); game.setLastPlayedCard(card);

Loading…
Cancel
Save