refactor: divided messages into server and client packages

This commit is contained in:
Yannik Bretschneider 2021-06-03 22:22:23 +02:00
parent 4823803e85
commit cef69473c7
20 changed files with 61 additions and 22 deletions

View File

@ -2,7 +2,7 @@ package uulm.teamname.marvelous.gamelibrary.events;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import uulm.teamname.marvelous.gamelibrary.messages.EventMessage;
import uulm.teamname.marvelous.gamelibrary.messages.server.EventMessage;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EventDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.EventSerializer;

View File

@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.EventMessage;
import uulm.teamname.marvelous.gamelibrary.messages.server.EventMessage;
/**
* Class that contains JSON encoding and decoding. It is initiated with the Character configuration.

View File

@ -1,6 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public enum Assignment {
public enum AssignmentEnum {
PlayerOne,
PlayerTwo,
Spectator

View File

@ -1,10 +1,11 @@
package uulm.teamname.marvelous.gamelibrary.messages;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import uulm.teamname.marvelous.gamelibrary.messages.client.*;
import uulm.teamname.marvelous.gamelibrary.messages.server.*;
import java.util.Objects;

View File

@ -1,4 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.client;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import java.util.Arrays;

View File

@ -1,6 +1,9 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.client;
public class HelloServerMessage extends BasicMessage{
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
public class HelloServerMessage extends BasicMessage {
public final MessageType messageType = MessageType.HELLO_SERVER;

View File

@ -1,4 +1,8 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.client;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import uulm.teamname.marvelous.gamelibrary.messages.RoleEnum;
public class PlayerReadyMessage extends BasicMessage {

View File

@ -1,4 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.client;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
public class ReconnectMessage extends BasicMessage {

View File

@ -1,7 +1,9 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.client;
import com.fasterxml.jackson.annotation.JsonIgnore;
import uulm.teamname.marvelous.gamelibrary.events.Event;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import uulm.teamname.marvelous.gamelibrary.requests.Request;
import java.util.Arrays;

View File

@ -1,4 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.server;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import java.util.Objects;

View File

@ -1,7 +1,9 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.server;
import com.fasterxml.jackson.annotation.JsonIgnore;
import uulm.teamname.marvelous.gamelibrary.events.Event;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import java.util.Arrays;
import java.util.HashMap;

View File

@ -1,6 +1,8 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.server;
import uulm.teamname.marvelous.gamelibrary.config.CharacterProperties;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import java.util.Arrays;
import java.util.Objects;

View File

@ -1,4 +1,4 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.server;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@ -6,6 +6,9 @@ import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
import uulm.teamname.marvelous.gamelibrary.config.CharacterProperties;
import uulm.teamname.marvelous.gamelibrary.config.PartyConfig;
import uulm.teamname.marvelous.gamelibrary.config.ScenarioConfig;
import uulm.teamname.marvelous.gamelibrary.messages.AssignmentEnum;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import java.util.Arrays;
import java.util.Objects;
@ -25,7 +28,7 @@ public class GameStructureMessage extends BasicMessage {
public final MessageType messageType = MessageType.GAME_STRUCTURE;
/** The role the client has been assigned to */
public Assignment assignment;
public AssignmentEnum assignment;
/** The name of the first player */
public String playerOneName;

View File

@ -1,4 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.server;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
import java.util.Objects;

View File

@ -1,4 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.server;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
public class GoodbyeClientMessage extends BasicMessage {

View File

@ -1,4 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
package uulm.teamname.marvelous.gamelibrary.messages.server;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
public class HelloClientMessage extends BasicMessage {

View File

@ -3,7 +3,7 @@ package uulm.teamname.marvelous.gamelibrary.requests;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import uulm.teamname.marvelous.gamelibrary.messages.EventMessage;
import uulm.teamname.marvelous.gamelibrary.messages.server.EventMessage;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.RequestDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.RequestSerializer;

View File

@ -13,7 +13,7 @@ import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.events.Event;
import uulm.teamname.marvelous.gamelibrary.events.EventBuilder;
import uulm.teamname.marvelous.gamelibrary.events.EventType;
import uulm.teamname.marvelous.gamelibrary.messages.EventMessage;
import uulm.teamname.marvelous.gamelibrary.messages.server.EventMessage;
import java.util.*;

View File

@ -12,6 +12,8 @@ import uulm.teamname.marvelous.gamelibrary.events.Event;
import uulm.teamname.marvelous.gamelibrary.events.EventBuilder;
import uulm.teamname.marvelous.gamelibrary.events.EventType;
import uulm.teamname.marvelous.gamelibrary.messages.*;
import uulm.teamname.marvelous.gamelibrary.messages.client.*;
import uulm.teamname.marvelous.gamelibrary.messages.server.*;
import uulm.teamname.marvelous.gamelibrary.requests.Request;
import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder;
import uulm.teamname.marvelous.gamelibrary.requests.RequestType;
@ -331,7 +333,7 @@ public class MessageDeserializationTest {
var message = new GameStructureMessage();
// message.messageType = MessageType.GAME_STRUCTURE;
message.assignment = Assignment.PlayerOne;
message.assignment = AssignmentEnum.PlayerOne;
message.playerOneName = "Gandalf";
message.playerTwoName = "Bilbo";
message.playerOneCharacters = new CharacterProperties[] {racoon, quicksilver, hulk};

View File

@ -15,6 +15,8 @@ import uulm.teamname.marvelous.gamelibrary.events.Event;
import uulm.teamname.marvelous.gamelibrary.events.EventBuilder;
import uulm.teamname.marvelous.gamelibrary.events.EventType;
import uulm.teamname.marvelous.gamelibrary.messages.*;
import uulm.teamname.marvelous.gamelibrary.messages.client.*;
import uulm.teamname.marvelous.gamelibrary.messages.server.*;
import uulm.teamname.marvelous.gamelibrary.requests.Request;
import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder;
import uulm.teamname.marvelous.gamelibrary.requests.RequestType;
@ -343,7 +345,7 @@ public class MessageSerializationTest {
var message = new GameStructureMessage();
// message.messageType = MessageType.GAME_STRUCTURE;
message.assignment = Assignment.PlayerOne;
message.assignment = AssignmentEnum.PlayerOne;
message.playerOneName = "Gandalf";
message.playerTwoName = "Bilbo";
message.playerOneCharacters = new CharacterProperties[] {racoon, quicksilver, hulk};