From 77c3db0f2d91e78451aed6e9742ec53e848d859f Mon Sep 17 00:00:00 2001 From: Johannes Hochwart Date: Fri, 5 Nov 2021 12:43:58 +0100 Subject: [PATCH] Client- und Server-Nachrichten verbessert(#9) --- .../messages/client/CreateSessionMessage.java | 19 +++++------ .../messages/client/InteractionMessage.java | 2 +- .../messages/client/JoinSessionMessage.java | 4 +-- .../common/messages/client/ReadyMessage.java | 2 +- .../common/messages/data/PlayerData.java | 10 +++--- .../common/messages/data/SessionData.java | 13 ++++--- .../common/messages/observer/CardMessage.java | 2 +- .../common/messages/observer/HandMessage.java | 2 +- .../messages/observer/JugglingMessage.java | 0 .../messages/observer/TrickMessage.java | 2 +- .../messages/observer/TrumpMessage.java | 2 +- .../messages/observer/UserInputMessage.java | 2 +- .../common/messages/player/JuggleMessage.java | 2 +- .../messages/player/PickTrumpMessage.java | 2 +- .../messages/player/PlayCardMessage.java | 2 +- .../common/messages/server/AckMessage.java | 2 +- .../common/messages/server/GameMessage.java | 2 +- .../messages/server/JoinedSessionMessage.java | 21 ++++++++---- .../common/messages/server/NackMessage.java | 2 +- .../messages/server/PlayerJoinMessage.java | 14 +++----- .../messages/server/PlayerLeaveMessage.java | 2 +- .../server/PlayerModifiedMessage.java | 16 +++++++++ .../common/messages/server/Response.java | 5 +++ .../common/messages/server/ServerMessage.java | 2 +- .../server/SessionCreatedMessage.java | 14 +++----- .../messages/server/SessionListMessage.java | 14 +++++--- .../server/SessionModifiedMessage.java | 16 +++++++++ .../server/SessionRemovedMessage.java | 4 +-- .../messages/server/StartingGameMessage.java | 3 +- .../wizard/common/model/{card => }/Card.java | 2 +- .../wizard/common/model/Configuration.java | 7 ++++ .../util/SealedClassTypeAdapterFactory.java | 34 ++++++++++++++----- .../java/eu/jonahbauer/wizard/core/CLI.java | 6 ++-- .../jonahbauer/wizard/core/machine/Game.java | 8 ++--- .../wizard/core/machine/states/GameData.java | 2 +- .../core/machine/states/round/Dealing.java | 2 +- .../states/round/DeterminingTrump.java | 2 +- .../machine/states/trick/FinishingTrick.java | 2 +- .../core/machine/states/trick/Juggling.java | 2 +- .../machine/states/trick/PlayingCard.java | 2 +- .../wizard/core/model/Configurations.java | 23 +++++++------ ...figuration.java => GameConfiguration.java} | 4 +-- .../wizard/core/model/card/CardUtils.java | 2 +- .../core/model/card/ChangelingJesterCard.java | 2 +- .../core/model/card/ChangelingWizardCard.java | 2 +- .../wizard/core/model/card/ColoredCard.java | 2 +- .../core/model/card/ColoredSubcard.java | 2 +- .../wizard/core/model/card/GameCard.java | 2 +- .../wizard/core/model/card/GameCards.java | 2 +- .../wizard/core/model/card/JesterCard.java | 2 +- .../core/model/card/NonPlayableCard.java | 2 +- .../wizard/core/model/card/SimpleCard.java | 2 +- .../wizard/core/model/card/WizardCard.java | 2 +- .../wizard/core/model/deck/Deck.java | 2 +- .../wizard/core/model/deck/Decks.java | 2 +- .../wizard/core/machine/MessageQueue.java | 2 +- .../states/round/DeterminingTrumpTest.java | 6 ++-- .../machine/states/round/PredictingTest.java | 6 ++-- .../core/machine/states/round/RoundTest.java | 6 ++-- .../core/machine/states/trick/TrickTest.java | 6 ++-- .../wizard/core/model/card/CardUtilsTest.java | 2 +- 61 files changed, 201 insertions(+), 132 deletions(-) delete mode 100644 wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/JugglingMessage.java create mode 100644 wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerModifiedMessage.java create mode 100644 wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/Response.java create mode 100644 wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionModifiedMessage.java rename wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/{card => }/Card.java (95%) create mode 100644 wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/Configuration.java rename wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/{Configuration.java => GameConfiguration.java} (82%) diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/CreateSessionMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/CreateSessionMessage.java index 697afc8..cb7e16e 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/CreateSessionMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/CreateSessionMessage.java @@ -1,5 +1,6 @@ package eu.jonahbauer.wizard.common.messages.client; +import eu.jonahbauer.wizard.common.model.Configuration; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -10,23 +11,19 @@ import org.jetbrains.annotations.Range; @EqualsAndHashCode(callSuper = true) public final class CreateSessionMessage extends ClientMessage { /** - * Name of session + * Name of the session */ - private final String name; + private final String sessionName; /** - * Name of creating and joining player + * Name of the creating and joining player */ private final String playerName; /** - * Choose of Deck + * timout in milliseconds for user interactions */ - private final String deck; + private final long timeout; /** - * Choose if exact predictions are allowed + * Game configuration */ - private final boolean exactPrediction; - /** - * timout in milliseconds - */ - private final @Range(from = 30*1000, to = 10* 60*1000) long timeout; + private final Configuration configuration; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/InteractionMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/InteractionMessage.java index 9dd8869..97d04a7 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/InteractionMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/InteractionMessage.java @@ -10,7 +10,7 @@ import lombok.RequiredArgsConstructor; @EqualsAndHashCode(callSuper = true) public final class InteractionMessage extends ClientMessage { /** - * Reference to wrapped {@link PlayerMessage} + * Wrapped {@link PlayerMessage} */ private final PlayerMessage playerMessage; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/JoinSessionMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/JoinSessionMessage.java index 9d59286..5bc1e33 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/JoinSessionMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/JoinSessionMessage.java @@ -11,11 +11,11 @@ import java.util.UUID; @EqualsAndHashCode(callSuper = true) public final class JoinSessionMessage extends ClientMessage { /** - * uuid of joining session + * UUID of the session */ private final UUID session; /** - * Name of joining player + * Name of the joining player */ private final String playerName; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/ReadyMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/ReadyMessage.java index 4a0de94..661d089 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/ReadyMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/client/ReadyMessage.java @@ -9,7 +9,7 @@ import lombok.RequiredArgsConstructor; @EqualsAndHashCode(callSuper = true) public final class ReadyMessage extends ClientMessage { /** - * State of ready + * State of readiness */ private final boolean ready; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/PlayerData.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/PlayerData.java index a178760..00e186f 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/PlayerData.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/PlayerData.java @@ -8,18 +8,18 @@ import java.util.UUID; @Getter @RequiredArgsConstructor -@EqualsAndHashCode +@EqualsAndHashCode(of = "uuid") public class PlayerData { /** - * UUID of corresponding player + * UUID of the player */ - private final UUID id; + private final UUID uuid; /** - * name of corresponding player + * Name of the player */ private final String name; /** - * readyState of corresponding player + * Readiness state of the player */ private final boolean ready; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/SessionData.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/SessionData.java index 1cea59b..0e8be35 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/SessionData.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/data/SessionData.java @@ -1,5 +1,6 @@ package eu.jonahbauer.wizard.common.messages.data; +import eu.jonahbauer.wizard.common.model.Configuration; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -8,18 +9,22 @@ import java.util.UUID; @Getter @RequiredArgsConstructor -@EqualsAndHashCode +@EqualsAndHashCode(of = "uuid") public class SessionData { /** - * uuid of corresponding session + * UUID of the session */ private final UUID uuid; /** - * name of corresponding session + * Name of the session */ private final String name; /** - * number of players in the corresponding session + * Number of players currently in the session */ private final int playerCount; + /** + * Configuration of the session + */ + private final Configuration configuration; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/CardMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/CardMessage.java index 3dd271d..984fe36 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/CardMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/CardMessage.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.common.messages.observer; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/HandMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/HandMessage.java index 396626c..33b768c 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/HandMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/HandMessage.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.common.messages.observer; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; import org.jetbrains.annotations.NotNull; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/JugglingMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/JugglingMessage.java deleted file mode 100644 index e69de29..0000000 diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrickMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrickMessage.java index f91d570..b7b82cb 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrickMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrickMessage.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.common.messages.observer; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrumpMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrumpMessage.java index 888647c..2ec534e 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrumpMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/TrumpMessage.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.common.messages.observer; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; import org.jetbrains.annotations.Nullable; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/UserInputMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/UserInputMessage.java index e0ba829..36118b4 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/UserInputMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/observer/UserInputMessage.java @@ -4,7 +4,7 @@ import eu.jonahbauer.wizard.common.messages.player.JuggleMessage; import eu.jonahbauer.wizard.common.messages.player.PickTrumpMessage; import eu.jonahbauer.wizard.common.messages.player.PlayCardMessage; import eu.jonahbauer.wizard.common.messages.player.PredictMessage; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/JuggleMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/JuggleMessage.java index c0b650a..2d639fc 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/JuggleMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/JuggleMessage.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.common.messages.player; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PickTrumpMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PickTrumpMessage.java index a10c544..be47021 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PickTrumpMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PickTrumpMessage.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.common.messages.player; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PlayCardMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PlayCardMessage.java index c0f3afb..6e33a03 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PlayCardMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/player/PlayCardMessage.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.common.messages.player; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/AckMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/AckMessage.java index 7fee56e..7e89460 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/AckMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/AckMessage.java @@ -1,5 +1,5 @@ package eu.jonahbauer.wizard.common.messages.server; -public final class AckMessage extends ServerMessage { +public final class AckMessage extends ServerMessage implements Response { } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/GameMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/GameMessage.java index 9429525..37b3ed2 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/GameMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/GameMessage.java @@ -10,7 +10,7 @@ import lombok.RequiredArgsConstructor; @EqualsAndHashCode(callSuper = true) public final class GameMessage extends ServerMessage { /** - * Reference to wrapped {@link ObserverMessage} + * Wrapped {@link ObserverMessage} */ private final ObserverMessage observerMessage; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/JoinedSessionMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/JoinedSessionMessage.java index 50cb1df..5a4af70 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/JoinedSessionMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/JoinedSessionMessage.java @@ -3,20 +3,29 @@ package eu.jonahbauer.wizard.common.messages.server; import eu.jonahbauer.wizard.common.messages.data.PlayerData; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.RequiredArgsConstructor; +import java.util.List; import java.util.UUID; @Getter -@RequiredArgsConstructor @EqualsAndHashCode(callSuper = true) -public final class JoinedSessionMessage extends ServerMessage { +public final class JoinedSessionMessage extends ServerMessage implements Response { /** - * uuid of joined session + * UUID of joined session */ private final UUID session; /** - * Reference to data of joined player + * UUID assigned to the player */ - private final PlayerData playerData; + private final UUID player; + /** + * List of players already in the session + */ + private final List players; + + public JoinedSessionMessage(UUID session, UUID player, List players) { + this.session = session; + this.player = player; + this.players = List.copyOf(players); + } } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/NackMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/NackMessage.java index 1d2e94b..9eebf94 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/NackMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/NackMessage.java @@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor; @Getter @RequiredArgsConstructor @EqualsAndHashCode(callSuper = true) -public final class NackMessage extends ServerMessage { +public final class NackMessage extends ServerMessage implements Response { private final int code; private final String message; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerJoinMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerJoinMessage.java index 964fdb5..00aa869 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerJoinMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerJoinMessage.java @@ -2,15 +2,11 @@ package eu.jonahbauer.wizard.common.messages.server; import eu.jonahbauer.wizard.common.messages.data.PlayerData; import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -@Getter -@RequiredArgsConstructor @EqualsAndHashCode(callSuper = true) -public final class PlayerJoinMessage extends ServerMessage { - /** - * Reference to data of left player - */ - private final PlayerData playerData; +public final class PlayerJoinMessage extends PlayerModifiedMessage { + + public PlayerJoinMessage(PlayerData playerData) { + super(playerData); + } } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerLeaveMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerLeaveMessage.java index 19758ca..ff18a82 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerLeaveMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerLeaveMessage.java @@ -11,7 +11,7 @@ import java.util.UUID; @EqualsAndHashCode(callSuper = true) public final class PlayerLeaveMessage extends ServerMessage { /** - * {@link java.util.UUID} of leaving player + * UUID of player who has left */ private final UUID player; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerModifiedMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerModifiedMessage.java new file mode 100644 index 0000000..a8e547c --- /dev/null +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/PlayerModifiedMessage.java @@ -0,0 +1,16 @@ +package eu.jonahbauer.wizard.common.messages.server; + +import eu.jonahbauer.wizard.common.messages.data.PlayerData; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +@EqualsAndHashCode(callSuper = true) +public sealed class PlayerModifiedMessage extends ServerMessage permits PlayerJoinMessage { + /** + * Joining player + */ + private final PlayerData playerData; +} diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/Response.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/Response.java new file mode 100644 index 0000000..68940ac --- /dev/null +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/Response.java @@ -0,0 +1,5 @@ +package eu.jonahbauer.wizard.common.messages.server; + +public interface Response { + //marker interface +} diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/ServerMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/ServerMessage.java index f2570fd..392e099 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/ServerMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/ServerMessage.java @@ -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, PlayerJoinMessage, PlayerLeaveMessage, SessionCreatedMessage, SessionListMessage, SessionRemovedMessage, StartingGameMessage { +public abstract sealed class ServerMessage permits AckMessage, GameMessage, JoinedSessionMessage, NackMessage, PlayerLeaveMessage, PlayerModifiedMessage, SessionListMessage, SessionModifiedMessage, SessionRemovedMessage, StartingGameMessage { public static final Gson GSON = new GsonBuilder() .registerTypeAdapterFactory(SealedClassTypeAdapterFactory.of(ServerMessage.class, "Message")) .registerTypeAdapterFactory(SealedClassTypeAdapterFactory.of(ObserverMessage.class, "Message")) diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionCreatedMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionCreatedMessage.java index 2a1140a..4e5c05f 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionCreatedMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionCreatedMessage.java @@ -2,15 +2,11 @@ package eu.jonahbauer.wizard.common.messages.server; import eu.jonahbauer.wizard.common.messages.data.SessionData; import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -@Getter -@RequiredArgsConstructor @EqualsAndHashCode(callSuper = true) -public final class SessionCreatedMessage extends ServerMessage { - /** - * Reference to data of created Session - */ - private final SessionData sessionData; +public final class SessionCreatedMessage extends SessionModifiedMessage { + + public SessionCreatedMessage(SessionData session) { + super(session); + } } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionListMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionListMessage.java index 80aa9d1..5e76c81 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionListMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionListMessage.java @@ -3,14 +3,18 @@ package eu.jonahbauer.wizard.common.messages.server; import eu.jonahbauer.wizard.common.messages.data.SessionData; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.RequiredArgsConstructor; + +import java.util.List; @Getter -@RequiredArgsConstructor @EqualsAndHashCode(callSuper = true) -public final class SessionListMessage extends ServerMessage { +public final class SessionListMessage extends ServerMessage implements Response { /** - * Reference to data of existing Sessions + * List of available sessions */ - private final SessionData[] sessionData; + private final List sessions; + + public SessionListMessage(List sessions) { + this.sessions = List.copyOf(sessions); + } } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionModifiedMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionModifiedMessage.java new file mode 100644 index 0000000..f03ec45 --- /dev/null +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionModifiedMessage.java @@ -0,0 +1,16 @@ +package eu.jonahbauer.wizard.common.messages.server; + +import eu.jonahbauer.wizard.common.messages.data.SessionData; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +@EqualsAndHashCode(callSuper = true) +public sealed class SessionModifiedMessage extends ServerMessage permits SessionCreatedMessage { + /** + * The created session + */ + private final SessionData session; +} diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionRemovedMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionRemovedMessage.java index cfc589f..5c939e5 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionRemovedMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/SessionRemovedMessage.java @@ -11,7 +11,7 @@ import java.util.UUID; @EqualsAndHashCode(callSuper = true) public final class SessionRemovedMessage extends ServerMessage { /** - * {@link UUID} of leaving player + * UUID of the removed session */ - private final UUID player; + private final UUID session; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/StartingGameMessage.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/StartingGameMessage.java index 0dab3bf..fbf8e30 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/StartingGameMessage.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/messages/server/StartingGameMessage.java @@ -9,8 +9,7 @@ import lombok.RequiredArgsConstructor; @EqualsAndHashCode(callSuper = true) public final class StartingGameMessage extends ServerMessage { /** - * Time of game start in - * {@link System#currentTimeMillis() UNIX time} + * Time of game start in {@link System#currentTimeMillis() UNIX time} */ private final long time; } diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/card/Card.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/Card.java similarity index 95% rename from wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/card/Card.java rename to wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/Card.java index f785866..fd2a082 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/card/Card.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/Card.java @@ -1,4 +1,4 @@ -package eu.jonahbauer.wizard.common.model.card; +package eu.jonahbauer.wizard.common.model; public enum Card { HIDDEN, diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/Configuration.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/Configuration.java new file mode 100644 index 0000000..8e04d4b --- /dev/null +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/model/Configuration.java @@ -0,0 +1,7 @@ +package eu.jonahbauer.wizard.common.model; + +public enum Configuration { + DEFAULT, DEFAULT_PM1, + ANNIVERSARY_2016, ANNIVERSARY_2016_PM1, + ANNIVERSARY_2021, ANNIVERSARY_2021_PM1 +} diff --git a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/util/SealedClassTypeAdapterFactory.java b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/util/SealedClassTypeAdapterFactory.java index f483de7..2e07ea5 100644 --- a/wizard-common/src/main/java/eu/jonahbauer/wizard/common/util/SealedClassTypeAdapterFactory.java +++ b/wizard-common/src/main/java/eu/jonahbauer/wizard/common/util/SealedClassTypeAdapterFactory.java @@ -7,6 +7,7 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.typeadapters.RuntimeTypeAdapterFactory; import org.jetbrains.annotations.Nullable; +import java.lang.reflect.Modifier; import java.util.Locale; public final class SealedClassTypeAdapterFactory implements TypeAdapterFactory { @@ -22,19 +23,36 @@ public final class SealedClassTypeAdapterFactory implements TypeAdapterFactor private SealedClassTypeAdapterFactory(Class clazz, @Nullable String suffix) { factory = RuntimeTypeAdapterFactory.of(clazz); + register(clazz, suffix); + } + + private void register(Class clazz, String suffix) { for (Class subclass : clazz.getPermittedSubclasses()) { - String name = subclass.getSimpleName(); + int modifiers = subclass.getModifiers(); + if (Modifier.isFinal(modifiers) || subclass.isSealed() && !Modifier.isAbstract(modifiers)) { + String name = subclass.getSimpleName(); - // remove suffix - if (suffix != null) { - if (name.endsWith(suffix)) name = name.substring(0, name.length() - suffix.length()); - } + // remove suffix + if (suffix != null) { + if (name.endsWith(suffix)) name = name.substring(0, name.length() - suffix.length()); + } - // transform camelCast to snake_case - name = name.replaceAll("([a-z])([A-Z]+)", "$1_$2").toLowerCase(Locale.ROOT); + // transform camelCast to snake_case + name = name.replaceAll("([a-z])([A-Z]+)", "$1_$2").toLowerCase(Locale.ROOT); - factory.registerSubtype(subclass.asSubclass(clazz), name); + factory.registerSubtype(subclass.asSubclass(clazz), name); + } + if (subclass.isSealed()) { + register(subclass.asSubclass(clazz), suffix); + } else if (!Modifier.isFinal(modifiers)) { + //subclass is non-sealed + throw new IllegalArgumentException( + "SealedClassTypeAdapterFactory does not support a type hierarchy that contains non-sealed classes. " + + "Found non-sealed class " + subclass.getName() + ); + } } + } @Override diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/CLI.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/CLI.java index f1d3c4d..f53da5b 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/CLI.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/CLI.java @@ -3,10 +3,10 @@ package eu.jonahbauer.wizard.core; import eu.jonahbauer.wizard.common.messages.player.PickTrumpMessage; import eu.jonahbauer.wizard.common.messages.player.PlayCardMessage; import eu.jonahbauer.wizard.common.messages.player.PredictMessage; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.messages.Observer; -import eu.jonahbauer.wizard.core.model.Configuration; +import eu.jonahbauer.wizard.core.model.GameConfiguration; import eu.jonahbauer.wizard.core.model.Configurations; import java.util.List; @@ -17,7 +17,7 @@ import java.util.regex.Pattern; public class CLI { public static void main(String[] args) { - Configuration config = Configurations.DEFAULT.withTimeout(0); + GameConfiguration config = Configurations.DEFAULT.withTimeout(0); Observer observer = (player, msg) -> System.out.println(msg); Game game = new Game(config, observer); var players = List.of( diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/Game.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/Game.java index df635e1..f056586 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/Game.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/Game.java @@ -7,7 +7,7 @@ import eu.jonahbauer.wizard.core.messages.Observer; import eu.jonahbauer.wizard.common.messages.observer.ObserverMessage; import eu.jonahbauer.wizard.common.messages.observer.StateMessage; import eu.jonahbauer.wizard.common.messages.player.PlayerMessage; -import eu.jonahbauer.wizard.core.model.Configuration; +import eu.jonahbauer.wizard.core.model.GameConfiguration; import eu.jonahbauer.wizard.core.util.Util; import lombok.Getter; @@ -22,16 +22,16 @@ public final class Game extends Context { @Getter private final Random random; @Getter - private final Configuration config; + private final GameConfiguration config; private final Observer observer; - public Game(Configuration config, Observer observer) { + public Game(GameConfiguration config, Observer observer) { this.random = new Random(); this.config = config; this.observer = observer; } - public Game(long seed, Configuration config, Observer observer) { + public Game(long seed, GameConfiguration config, Observer observer) { this.random = new Random(seed); this.config = config; this.observer = observer; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/GameData.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/GameData.java index a895614..44b9e18 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/GameData.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/GameData.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.machine.states; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/Dealing.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/Dealing.java index 1fbc592..27cff7f 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/Dealing.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/Dealing.java @@ -1,7 +1,7 @@ package eu.jonahbauer.wizard.core.machine.states.round; import eu.jonahbauer.wizard.common.messages.observer.HandMessage; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.states.GameData; import eu.jonahbauer.wizard.core.model.deck.Deck; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrump.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrump.java index 05596df..0db0196 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrump.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrump.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.machine.states.round; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.states.GameData; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.common.messages.observer.HandMessage; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/FinishingTrick.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/FinishingTrick.java index 37b6061..188b978 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/FinishingTrick.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/FinishingTrick.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.machine.states.trick; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.states.GameData; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.states.InvalidDataException; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/Juggling.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/Juggling.java index f0f58f6..171c368 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/Juggling.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/Juggling.java @@ -4,7 +4,7 @@ import eu.jonahbauer.wizard.common.messages.observer.HandMessage; import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage; import eu.jonahbauer.wizard.common.messages.player.JuggleMessage; import eu.jonahbauer.wizard.common.messages.player.PlayerMessage; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.states.GameData; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/PlayingCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/PlayingCard.java index adea1bf..04a956c 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/PlayingCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/machine/states/trick/PlayingCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.machine.states.trick; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.states.GameData; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.states.InvalidDataException; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/Configurations.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/Configurations.java index dd382ed..f21ca29 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/Configurations.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/Configurations.java @@ -1,5 +1,6 @@ package eu.jonahbauer.wizard.core.model; +import eu.jonahbauer.wizard.common.model.Configuration; import eu.jonahbauer.wizard.core.model.deck.Decks; import lombok.experimental.UtilityClass; import org.jetbrains.annotations.Contract; @@ -12,55 +13,55 @@ import java.util.NoSuchElementException; @UtilityClass public class Configurations { - private static final Map CONFIGURATIONS = new HashMap<>(); + private static final Map CONFIGURATIONS = new HashMap<>(); - public static final Configuration DEFAULT = register("DEFAULT", new Configuration( + public static final GameConfiguration DEFAULT = register(Configuration.DEFAULT, new GameConfiguration( Decks.DEFAULT, true, 10 * 60 * 1000 )); - public static final Configuration DEFAULT_PM1 = register("DEFAULT_PM1", new Configuration( + public static final GameConfiguration DEFAULT_PM1 = register(Configuration.DEFAULT_PM1, new GameConfiguration( Decks.DEFAULT, false, 10 * 60 * 1000 )); - public static final Configuration ANNIVERSARY_2016 = register("ANNIVERSARY_2016", new Configuration( + public static final GameConfiguration ANNIVERSARY_2016 = register(Configuration.ANNIVERSARY_2016, new GameConfiguration( Decks.ANNIVERSARY_2016, true, 10 * 60 * 1000 )); - public static final Configuration ANNIVERSARY_2016_PM1 = register("ANNIVERSARY_2016_PM1", new Configuration( + public static final GameConfiguration ANNIVERSARY_2016_PM1 = register(Configuration.ANNIVERSARY_2016_PM1, new GameConfiguration( Decks.ANNIVERSARY_2016, false, 10 * 60 * 1000 )); - public static final Configuration ANNIVERSARY_2021 = register("ANNIVERSARY_2021", new Configuration( + public static final GameConfiguration ANNIVERSARY_2021 = register(Configuration.ANNIVERSARY_2021, new GameConfiguration( Decks.ANNIVERSARY_2021, true, 10 * 60 * 1000 )); - public static final Configuration ANNIVERSARY_2021_PM1 = register("ANNIVERSARY_2021_PM1", new Configuration( + public static final GameConfiguration ANNIVERSARY_2021_PM1 = register(Configuration.ANNIVERSARY_2021_PM1, new GameConfiguration( Decks.ANNIVERSARY_2021, false, 10 * 60 * 1000 )); @Contract("_,_ -> param2") - private static Configuration register(@NotNull String name, @NotNull Configuration configuration) { - if (CONFIGURATIONS.putIfAbsent(name.toUpperCase(Locale.ROOT), configuration) != null) { + private static GameConfiguration register(@NotNull Configuration name, @NotNull GameConfiguration configuration) { + if (CONFIGURATIONS.putIfAbsent(name, configuration) != null) { throw new IllegalArgumentException("Name already taken."); } return configuration; } @NotNull - public static Configuration get(@NotNull String name) { - var out = CONFIGURATIONS.get(name.toUpperCase(Locale.ROOT)); + public static GameConfiguration get(@NotNull Configuration name) { + var out = CONFIGURATIONS.get(name); if (out == null) throw new NoSuchElementException("Configuration with name '" + name + "' does not exist."); return out; } diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/Configuration.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/GameConfiguration.java similarity index 82% rename from wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/Configuration.java rename to wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/GameConfiguration.java index 561d340..6d65c22 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/Configuration.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/GameConfiguration.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Value; @@ -12,7 +12,7 @@ import java.util.Set; @Value @Accessors(fluent = true) @AllArgsConstructor(access = AccessLevel.PACKAGE) -public class Configuration { +public class GameConfiguration { Set cards; boolean allowExactPredictions; @With long timeout; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/CardUtils.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/CardUtils.java index 4c15d88..674e4fd 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/CardUtils.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/CardUtils.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import lombok.experimental.UtilityClass; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingJesterCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingJesterCard.java index 1eb3579..90f4559 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingJesterCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingJesterCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import java.util.List; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingWizardCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingWizardCard.java index 7061ab7..35f30fb 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingWizardCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ChangelingWizardCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import java.util.List; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredCard.java index 2355787..d2c22e7 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import lombok.Getter; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredSubcard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredSubcard.java index d7d3962..a09ecf0 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredSubcard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/ColoredSubcard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import lombok.Getter; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCard.java index 6a754c6..76ec70d 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCards.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCards.java index b33b53e..a03625a 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCards.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/GameCards.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.experimental.UtilityClass; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/JesterCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/JesterCard.java index f18ff2f..7cff444 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/JesterCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/JesterCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; public class JesterCard extends SimpleCard { public JesterCard(Card card) { diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/NonPlayableCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/NonPlayableCard.java index 395bc82..715c6e6 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/NonPlayableCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/NonPlayableCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import lombok.Getter; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/SimpleCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/SimpleCard.java index 9104d54..f2d5b98 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/SimpleCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/SimpleCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.Getter; @Getter diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/WizardCard.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/WizardCard.java index 8463caa..3f3056d 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/WizardCard.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/card/WizardCard.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; public class WizardCard extends SimpleCard { public WizardCard(Card card) { diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Deck.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Deck.java index e1b053d..2b83991 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Deck.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Deck.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.deck; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; diff --git a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Decks.java b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Decks.java index ca72060..5e31206 100644 --- a/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Decks.java +++ b/wizard-core/src/main/java/eu/jonahbauer/wizard/core/model/deck/Decks.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.deck; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import lombok.experimental.UtilityClass; import java.util.*; diff --git a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/MessageQueue.java b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/MessageQueue.java index bc20cb8..1dda2df 100644 --- a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/MessageQueue.java +++ b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/MessageQueue.java @@ -3,7 +3,7 @@ package eu.jonahbauer.wizard.core.machine; import eu.jonahbauer.wizard.common.messages.observer.ObserverMessage; import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage; import eu.jonahbauer.wizard.common.messages.player.*; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.messages.Observer; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrumpTest.java b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrumpTest.java index 90f6e8b..e8fb89e 100644 --- a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrumpTest.java +++ b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/DeterminingTrumpTest.java @@ -4,11 +4,11 @@ import eu.jonahbauer.wizard.common.messages.observer.HandMessage; import eu.jonahbauer.wizard.common.messages.observer.StateMessage; import eu.jonahbauer.wizard.common.messages.observer.TrumpMessage; import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.MessageQueue; import eu.jonahbauer.wizard.core.machine.states.GameData; -import eu.jonahbauer.wizard.core.model.Configuration; +import eu.jonahbauer.wizard.core.model.GameConfiguration; import eu.jonahbauer.wizard.core.model.Configurations; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; @@ -35,7 +35,7 @@ public class DeterminingTrumpTest { @SneakyThrows @SuppressWarnings("SameParameterValue") - private Game performTest(Configuration configuration, int round, Map> hands, Card trumpCard, MessageQueue queue) { + private Game performTest(GameConfiguration configuration, int round, Map> hands, Card trumpCard, MessageQueue queue) { Game game = spy(new Game(configuration, queue)); doFinish().when(game).transition(any(), any(Predicting.class)); queue.setGame(game); diff --git a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/PredictingTest.java b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/PredictingTest.java index c876286..29b7401 100644 --- a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/PredictingTest.java +++ b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/PredictingTest.java @@ -3,13 +3,13 @@ package eu.jonahbauer.wizard.core.machine.states.round; import eu.jonahbauer.wizard.common.messages.observer.PredictionMessage; import eu.jonahbauer.wizard.common.messages.observer.StateMessage; import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.GameTestUtils; import eu.jonahbauer.wizard.core.machine.MessageQueue; import eu.jonahbauer.wizard.core.machine.states.GameData; import eu.jonahbauer.wizard.core.machine.states.trick.StartingTrick; -import eu.jonahbauer.wizard.core.model.Configuration; +import eu.jonahbauer.wizard.core.model.GameConfiguration; import eu.jonahbauer.wizard.core.model.Configurations; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; @@ -37,7 +37,7 @@ public class PredictingTest { @SneakyThrows @SuppressWarnings("SameParameterValue") - private Game performTest(Configuration configuration, int round, MessageQueue queue) { + private Game performTest(GameConfiguration configuration, int round, MessageQueue queue) { Map> hands = Map.of( players[0], Collections.nCopies(round + 1, Card.HIDDEN), players[1], Collections.nCopies(round + 1, Card.HIDDEN), diff --git a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/RoundTest.java b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/RoundTest.java index de24d38..f4ad3b6 100644 --- a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/RoundTest.java +++ b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/round/RoundTest.java @@ -1,11 +1,11 @@ package eu.jonahbauer.wizard.core.machine.states.round; import eu.jonahbauer.wizard.common.messages.observer.*; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.MessageQueue; import eu.jonahbauer.wizard.core.machine.states.GameData; -import eu.jonahbauer.wizard.core.model.Configuration; +import eu.jonahbauer.wizard.core.model.GameConfiguration; import eu.jonahbauer.wizard.core.model.Configurations; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; @@ -32,7 +32,7 @@ public class RoundTest { }; @SneakyThrows - private Game performTest(long seed, Configuration configuration, int round, MessageQueue queue) { + private Game performTest(long seed, GameConfiguration configuration, int round, MessageQueue queue) { Game game = spy(new Game(seed, configuration, queue)); doFinish().when(game).transition(any(), any(StartingRound.class)); queue.setGame(game); diff --git a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/trick/TrickTest.java b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/trick/TrickTest.java index b737c2c..18c9f37 100644 --- a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/trick/TrickTest.java +++ b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/machine/states/trick/TrickTest.java @@ -1,13 +1,13 @@ package eu.jonahbauer.wizard.core.machine.states.trick; import eu.jonahbauer.wizard.common.messages.observer.*; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.machine.Game; import eu.jonahbauer.wizard.core.machine.GameTestUtils; import eu.jonahbauer.wizard.core.machine.MessageQueue; import eu.jonahbauer.wizard.core.machine.states.GameData; import eu.jonahbauer.wizard.core.machine.states.round.FinishingRound; -import eu.jonahbauer.wizard.core.model.Configuration; +import eu.jonahbauer.wizard.core.model.GameConfiguration; import eu.jonahbauer.wizard.core.model.Configurations; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; @@ -34,7 +34,7 @@ public class TrickTest { @SneakyThrows @SuppressWarnings("SameParameterValue") - private Game performTest(Configuration configuration, int round, int trick, Map> hands, Card.Suit trump, MessageQueue queue) { + private Game performTest(GameConfiguration configuration, int round, int trick, Map> hands, Card.Suit trump, MessageQueue queue) { Game game = spy(new Game(configuration, queue)); doFinish().when(game).transition(any(), any(StartingTrick.class)); doFinish().when(game).transition(any(), any(FinishingRound.class)); diff --git a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/model/card/CardUtilsTest.java b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/model/card/CardUtilsTest.java index 8aa6005..7d7b345 100644 --- a/wizard-core/src/test/java/eu/jonahbauer/wizard/core/model/card/CardUtilsTest.java +++ b/wizard-core/src/test/java/eu/jonahbauer/wizard/core/model/card/CardUtilsTest.java @@ -1,6 +1,6 @@ package eu.jonahbauer.wizard.core.model.card; -import eu.jonahbauer.wizard.common.model.card.Card; +import eu.jonahbauer.wizard.common.model.Card; import eu.jonahbauer.wizard.core.util.Pair; import org.junit.jupiter.api.Test;