Bugfixes
This commit is contained in:
parent
262ae4a2cc
commit
4b13b4ef16
@ -19,8 +19,8 @@ public final class HandMessage extends ObserverMessage {
|
||||
*/
|
||||
private final @NotNull UUID player;
|
||||
/**
|
||||
* A list of all the hand cards. May consist only of {@link Card#HIDDEN} if the cars are not visible to the player
|
||||
* receiving this message
|
||||
* A list of all the hand cards. May consist only of {@link Card#HIDDEN} if the cards are not visible to the player
|
||||
* receiving this message.
|
||||
*/
|
||||
private final @NotNull List<@NotNull Card> hand;
|
||||
|
||||
|
@ -4,9 +4,9 @@ import eu.jonahbauer.wizard.common.messages.data.PlayerData;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class PlayerJoinMessage extends PlayerModifiedMessage {
|
||||
public final class PlayerJoinedMessage extends PlayerModifiedMessage {
|
||||
|
||||
public PlayerJoinMessage(PlayerData playerData) {
|
||||
public PlayerJoinedMessage(PlayerData playerData) {
|
||||
super(playerData);
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class PlayerLeaveMessage extends ServerMessage {
|
||||
public final class PlayerLeftMessage extends ServerMessage {
|
||||
/**
|
||||
* UUID of player who has left
|
||||
*/
|
@ -8,9 +8,9 @@ import lombok.RequiredArgsConstructor;
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public sealed class PlayerModifiedMessage extends ServerMessage permits PlayerJoinMessage {
|
||||
public sealed class PlayerModifiedMessage extends ServerMessage permits PlayerJoinedMessage {
|
||||
/**
|
||||
* Joining player
|
||||
*/
|
||||
private final PlayerData playerData;
|
||||
private final PlayerData player;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import eu.jonahbauer.wizard.common.util.SealedClassTypeAdapterFactory;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode
|
||||
public abstract sealed class ServerMessage permits AckMessage, GameMessage, JoinedSessionMessage, NackMessage, PlayerLeaveMessage, PlayerModifiedMessage, SessionListMessage, SessionModifiedMessage, SessionRemovedMessage, StartingGameMessage {
|
||||
public abstract sealed class ServerMessage permits AckMessage, GameMessage, JoinedSessionMessage, NackMessage, PlayerLeftMessage, PlayerModifiedMessage, SessionListMessage, SessionModifiedMessage, SessionRemovedMessage, StartingGameMessage {
|
||||
public static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeAdapterFactory(SealedClassTypeAdapterFactory.of(ServerMessage.class, "Message"))
|
||||
.registerTypeAdapterFactory(SealedClassTypeAdapterFactory.of(ObserverMessage.class, "Message"))
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user