Browse Source

ResetActionCard

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

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

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

Loading…
Cancel
Save