This commit is contained in:
Johannes Hochwart
2021-11-10 20:27:19 +01:00
parent 77c3db0f2d
commit 0e23ddc343
8 changed files with 21 additions and 11 deletions

View File

@@ -57,7 +57,12 @@ public final class DeterminingTrump extends RoundState {
@Override
public void onTimeout(Game game) {
Card.Suit[] suits = new Card.Suit[]{Card.Suit.BLUE, Card.Suit.GREEN, Card.Suit.RED, Card.Suit.YELLOW};
Card.Suit[] suits;
if (werewolf) {
suits = new Card.Suit[]{Card.Suit.BLUE, Card.Suit.GREEN, Card.Suit.RED, Card.Suit.YELLOW, Card.Suit.NONE};
} else {
suits = new Card.Suit[]{Card.Suit.BLUE, Card.Suit.GREEN, Card.Suit.RED, Card.Suit.YELLOW};
}
transition(game, suits[game.getRandom().nextInt(suits.length)]);
}
@@ -72,8 +77,10 @@ public final class DeterminingTrump extends RoundState {
}
private void checkTrumpSuit(Card.Suit suit) {
if (suit == Card.Suit.NONE) {
if (!werewolf && suit == Card.Suit.NONE) {
throw new IllegalArgumentException("Trump suit must not be " + Card.Suit.NONE + ".");
} else if (suit == null) {
throw new IllegalArgumentException("Trump suit must not be null.");
}
}

View File

@@ -33,6 +33,9 @@ public final class PlayingCard extends TrickState {
@Override
public void onMessage(Game game, UUID player, PlayerMessage message) {
if (get(CURRENT_PLAYER).equals(player) && message instanceof PlayCardMessage cardMessage) {
if (cardMessage.getCard() == null) {
throw new IllegalArgumentException("Card must not be null.");
}
transition(game, cardMessage.getCard());
} else {
super.onMessage(game, player, message);

View File

@@ -57,7 +57,7 @@ public class CardUtils {
} else if (card instanceof ColoredCard coloredCard) {
if (coloredCard.getSuit() == trumpSuit) {
return 200 + coloredCard.getValue();
} else if (coloredCard.getSuit() == suit) {
} else if (coloredCard.getSuit() == suit) {
return 100 + coloredCard.getValue();
} else {
return coloredCard.getValue();