Browse Source

ResetActionCard

main
fdai7793 11 months ago
parent
commit
46732eae37
  1. 15
      src/main/java/de/hsfulda/onses/services/GameService.java

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

@ -8,6 +8,7 @@ import java.util.Collections;
public class GameService {
private final Game game;
public GameService(Game game) {
this.game = game;
this.game.setGameService(this);
@ -22,6 +23,7 @@ public class GameService {
}
}
}
public GameService() {
this(new Game());
}
@ -33,6 +35,7 @@ public class GameService {
public void nextPlayer() {
game.getPlayerService().nextTurn();
}
public void drawCard(int amount) {
Player player = null;
if (game.getPlayerService().getCurrentTurn()) {
@ -48,9 +51,14 @@ public class GameService {
nextPlayer();
}
}
public void playCard(Card card)
{
public void playCard(Card card) {
// add lastPlayedCard back to drawCardDeck
Card lastCard = game.getLastPlayedCard();
if (lastCard.getValue() == Card.Value.CHOOSE || lastCard.getValue() == Card.Value.CHOOSEDRAW) {
lastCard.setColor(Card.Color.BLACK);
}
game.addCardToDrawCardDeck(lastCard);
game.setLastPlayedCard(card);
// check for special rules (draw, colorchoose, skip,...)
// Skip
@ -85,8 +93,7 @@ public class GameService {
}
}
public boolean legalMove(Card card)
{
public boolean legalMove(Card card) {
boolean legalMoveFound = false;
Card lastCard = game.getLastPlayedCard();
// rules:

Loading…
Cancel
Save