Client- und Server-Nachrichten verbessert(#9)

main
Johannes Hochwart 3 years ago
parent 25ca90ddf5
commit 77c3db0f2d

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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 {
}

@ -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;
}

@ -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<PlayerData> players;
public JoinedSessionMessage(UUID session, UUID player, List<PlayerData> players) {
this.session = session;
this.player = player;
this.players = List.copyOf(players);
}
}

@ -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;
}

@ -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);
}
}

@ -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;
}

@ -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;
}

@ -0,0 +1,5 @@
package eu.jonahbauer.wizard.common.messages.server;
public interface Response {
//marker interface
}

@ -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"))

@ -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);
}
}

@ -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<SessionData> sessions;
public SessionListMessage(List<SessionData> sessions) {
this.sessions = List.copyOf(sessions);
}
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -1,4 +1,4 @@
package eu.jonahbauer.wizard.common.model.card;
package eu.jonahbauer.wizard.common.model;
public enum Card {
HIDDEN,

@ -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
}

@ -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<T> implements TypeAdapterFactory {
@ -22,7 +23,13 @@ public final class SealedClassTypeAdapterFactory<T> implements TypeAdapterFactor
private SealedClassTypeAdapterFactory(Class<T> clazz, @Nullable String suffix) {
factory = RuntimeTypeAdapterFactory.of(clazz);
register(clazz, suffix);
}
private void register(Class<? extends T> clazz, String suffix) {
for (Class<?> subclass : clazz.getPermittedSubclasses()) {
int modifiers = subclass.getModifiers();
if (Modifier.isFinal(modifiers) || subclass.isSealed() && !Modifier.isAbstract(modifiers)) {
String name = subclass.getSimpleName();
// remove suffix
@ -35,6 +42,17 @@ public final class SealedClassTypeAdapterFactory<T> implements TypeAdapterFactor
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

@ -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(

@ -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<GameState, Game> {
@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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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<String, Configuration> CONFIGURATIONS = new HashMap<>();
private static final Map<Configuration, GameConfiguration> 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;
}

@ -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<Card> cards;
boolean allowExactPredictions;
@With long timeout;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -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) {

@ -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;

@ -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

@ -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) {

@ -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;

@ -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.*;

@ -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;

@ -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<UUID, List<Card>> hands, Card trumpCard, MessageQueue queue) {
private Game performTest(GameConfiguration configuration, int round, Map<UUID, List<Card>> hands, Card trumpCard, MessageQueue queue) {
Game game = spy(new Game(configuration, queue));
doFinish().when(game).transition(any(), any(Predicting.class));
queue.setGame(game);

@ -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<UUID, List<Card>> hands = Map.of(
players[0], Collections.nCopies(round + 1, Card.HIDDEN),
players[1], Collections.nCopies(round + 1, Card.HIDDEN),

@ -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);

@ -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<UUID, List<Card>> hands, Card.Suit trump, MessageQueue queue) {
private Game performTest(GameConfiguration configuration, int round, int trick, Map<UUID, List<Card>> 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));

@ -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;

Loading…
Cancel
Save