fix: stop making duplicate properties which are difficult to access
This commit is contained in:
parent
be7dd1ca94
commit
bc3319eed0
@ -1,13 +1,9 @@
|
|||||||
package uulm.teamname.marvelous.gamelibrary.messages;
|
package uulm.teamname.marvelous.gamelibrary.messages;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
public class ErrorMessage extends BasicMessage{
|
public class ErrorMessage extends BasicMessage{
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.ERROR;
|
|
||||||
|
|
||||||
|
|
||||||
/** Some message telling the client what went wrong */
|
/** Some message telling the client what went wrong */
|
||||||
@NotNull
|
@NotNull
|
||||||
public String message = "No message given";
|
public String message = "No message given";
|
||||||
@ -15,4 +11,8 @@ public class ErrorMessage extends BasicMessage{
|
|||||||
/** The type of the error that happened */
|
/** The type of the error that happened */
|
||||||
@NotNull
|
@NotNull
|
||||||
public int type = 0;
|
public int type = 0;
|
||||||
|
|
||||||
|
public ErrorMessage() {
|
||||||
|
messageType = MessageType.ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class CharacterSelectionMessage extends BasicMessage {
|
public class CharacterSelectionMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.CHARACTER_SELECTION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean array that conveys information about what characters (6)
|
* Boolean array that conveys information about what characters (6)
|
||||||
* of the given characters (12) have been selected
|
* of the given characters (12) have been selected
|
||||||
@ -19,6 +17,10 @@ public class CharacterSelectionMessage extends BasicMessage {
|
|||||||
@Size(min = 12, max = 12, message = "doesn't have twelve elements")
|
@Size(min = 12, max = 12, message = "doesn't have twelve elements")
|
||||||
public Boolean[] characters;
|
public Boolean[] characters;
|
||||||
|
|
||||||
|
public CharacterSelectionMessage() {
|
||||||
|
messageType = MessageType.CHARACTER_SELECTION;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -4,12 +4,8 @@ import jakarta.validation.constraints.NotEmpty;
|
|||||||
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
|
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
|
||||||
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
|
import uulm.teamname.marvelous.gamelibrary.messages.MessageType;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
public class HelloServerMessage extends BasicMessage {
|
public class HelloServerMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.HELLO_SERVER;
|
|
||||||
|
|
||||||
/** User-chosen name, basically a PlayerName */
|
/** User-chosen name, basically a PlayerName */
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
public String name;
|
public String name;
|
||||||
@ -17,4 +13,8 @@ public class HelloServerMessage extends BasicMessage {
|
|||||||
/** Device ID sent by the Client, might be anything, but used together with name to uniquely identify the client */
|
/** Device ID sent by the Client, might be anything, but used together with name to uniquely identify the client */
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
public String deviceID;
|
public String deviceID;
|
||||||
|
|
||||||
|
public HelloServerMessage() {
|
||||||
|
messageType = MessageType.HELLO_SERVER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
|
|
||||||
public class PlayerReadyMessage extends BasicMessage {
|
public class PlayerReadyMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.PLAYER_READY;
|
|
||||||
|
|
||||||
/** Whether the client wants to start the game. If this is false, the client gets disconnected. */
|
/** Whether the client wants to start the game. If this is false, the client gets disconnected. */
|
||||||
@NotNull
|
@NotNull
|
||||||
public Boolean startGame;
|
public Boolean startGame;
|
||||||
@ -17,4 +15,8 @@ public class PlayerReadyMessage extends BasicMessage {
|
|||||||
/** The {@link RoleEnum Role} the client wants to take */
|
/** The {@link RoleEnum Role} the client wants to take */
|
||||||
@NotNull
|
@NotNull
|
||||||
public RoleEnum role;
|
public RoleEnum role;
|
||||||
|
|
||||||
|
public PlayerReadyMessage() {
|
||||||
|
messageType = MessageType.PLAYER_READY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
|
|
||||||
public class ReconnectMessage extends BasicMessage {
|
public class ReconnectMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.RECONNECT;
|
|
||||||
|
|
||||||
/** Whether the client wants to reconnect to the previously running game */
|
/** Whether the client wants to reconnect to the previously running game */
|
||||||
@NotNull
|
@NotNull
|
||||||
public Boolean reconnect;
|
public Boolean reconnect;
|
||||||
|
|
||||||
|
public ReconnectMessage() {
|
||||||
|
messageType = MessageType.RECONNECT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ import java.util.Objects;
|
|||||||
/** Represents a message sent between client and server and contains all possible data. */
|
/** Represents a message sent between client and server and contains all possible data. */
|
||||||
public class RequestMessage extends BasicMessage {
|
public class RequestMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.REQUESTS;
|
|
||||||
|
|
||||||
/** The list of {@link Event Events} sent inside the message. */
|
/** The list of {@link Event Events} sent inside the message. */
|
||||||
@NotNull(message = "No Requests found")
|
@NotNull(message = "No Requests found")
|
||||||
@NotEmpty(message = "No Requests found")
|
@NotEmpty(message = "No Requests found")
|
||||||
@ -28,6 +26,10 @@ public class RequestMessage extends BasicMessage {
|
|||||||
/** The decoded contents of the custom content sent. */
|
/** The decoded contents of the custom content sent. */
|
||||||
public HashMap<String, Object> customContent;
|
public HashMap<String, Object> customContent;
|
||||||
|
|
||||||
|
public RequestMessage() {
|
||||||
|
messageType = MessageType.REQUESTS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override @JsonIgnore
|
@Override @JsonIgnore
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -8,12 +8,14 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class ConfirmSelectionMessage extends BasicMessage {
|
public class ConfirmSelectionMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.CONFIRM_SELECTION;
|
|
||||||
|
|
||||||
/** Whether the other player is also done with the selection already */
|
/** Whether the other player is also done with the selection already */
|
||||||
@NotNull
|
@NotNull
|
||||||
public Boolean selectionComplete;
|
public Boolean selectionComplete;
|
||||||
|
|
||||||
|
public ConfirmSelectionMessage() {
|
||||||
|
messageType = MessageType.CONFIRM_SELECTION;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -15,8 +15,6 @@ import java.util.Objects;
|
|||||||
// @JsonDeserialize(using = EventMessageDeserializer.class)
|
// @JsonDeserialize(using = EventMessageDeserializer.class)
|
||||||
public class EventMessage extends BasicMessage {
|
public class EventMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.EVENTS;
|
|
||||||
|
|
||||||
/** The list of {@link Event Events} sent inside the message. */
|
/** The list of {@link Event Events} sent inside the message. */
|
||||||
@NotNull(message = "No events found")
|
@NotNull(message = "No events found")
|
||||||
@NotEmpty(message = "No events found")
|
@NotEmpty(message = "No events found")
|
||||||
@ -28,6 +26,10 @@ public class EventMessage extends BasicMessage {
|
|||||||
/** The decoded contents of the custom content sent. */
|
/** The decoded contents of the custom content sent. */
|
||||||
public HashMap<String, Object> customContent;
|
public HashMap<String, Object> customContent;
|
||||||
|
|
||||||
|
public EventMessage() {
|
||||||
|
messageType = MessageType.EVENTS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override @JsonIgnore
|
@Override @JsonIgnore
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -13,8 +13,6 @@ import java.util.Objects;
|
|||||||
// @JsonDeserialize(using = GameAssignmentDeserializer.class)
|
// @JsonDeserialize(using = GameAssignmentDeserializer.class)
|
||||||
public class GameAssignmentMessage extends BasicMessage {
|
public class GameAssignmentMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.GAME_ASSIGNMENT;
|
|
||||||
|
|
||||||
/** The ID of the game that the client is connected to. What this is used for is kind of unknown. */
|
/** The ID of the game that the client is connected to. What this is used for is kind of unknown. */
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
public String gameID;
|
public String gameID;
|
||||||
@ -24,6 +22,10 @@ public class GameAssignmentMessage extends BasicMessage {
|
|||||||
@Size(min = 12, max = 12, message = "Character Selection doesn't have 12 booleans")
|
@Size(min = 12, max = 12, message = "Character Selection doesn't have 12 booleans")
|
||||||
public CharacterProperties[] characterSelection;
|
public CharacterProperties[] characterSelection;
|
||||||
|
|
||||||
|
public GameAssignmentMessage() {
|
||||||
|
messageType = MessageType.GAME_ASSIGNMENT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -28,8 +28,6 @@ import java.util.stream.Stream;
|
|||||||
"matchconfig"})
|
"matchconfig"})
|
||||||
public class GameStructureMessage extends BasicMessage {
|
public class GameStructureMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.GAME_STRUCTURE;
|
|
||||||
|
|
||||||
/** The role the client has been assigned to */
|
/** The role the client has been assigned to */
|
||||||
@NotNull
|
@NotNull
|
||||||
public ParticipantType assignment;
|
public ParticipantType assignment;
|
||||||
@ -63,6 +61,10 @@ public class GameStructureMessage extends BasicMessage {
|
|||||||
@Valid
|
@Valid
|
||||||
public ScenarioConfig scenarioconfig;
|
public ScenarioConfig scenarioconfig;
|
||||||
|
|
||||||
|
public GameStructureMessage() {
|
||||||
|
messageType = MessageType.GAME_STRUCTURE;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore public CharacterConfig getCharacterConfig() {
|
@JsonIgnore public CharacterConfig getCharacterConfig() {
|
||||||
CharacterConfig characterConfig = new CharacterConfig();
|
CharacterConfig characterConfig = new CharacterConfig();
|
||||||
characterConfig.characters = Stream
|
characterConfig.characters = Stream
|
||||||
|
@ -9,13 +9,15 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class GeneralAssignmentMessage extends BasicMessage {
|
public class GeneralAssignmentMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.GENERAL_ASSIGNMENT;
|
|
||||||
|
|
||||||
/** The ID of the game that the client is connected to. What this is used for is kind of unknown. */
|
/** The ID of the game that the client is connected to. What this is used for is kind of unknown. */
|
||||||
@NotNull
|
@NotNull
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
public String gameID;
|
public String gameID;
|
||||||
|
|
||||||
|
public GeneralAssignmentMessage() {
|
||||||
|
messageType = MessageType.GENERAL_ASSIGNMENT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -8,9 +8,11 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
|
|
||||||
public class GoodbyeClientMessage extends BasicMessage {
|
public class GoodbyeClientMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.GOODBYE_CLIENT;
|
|
||||||
|
|
||||||
/** A message sent to the client on disconnect */
|
/** A message sent to the client on disconnect */
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
public String message = "You got disconnected.";
|
public String message = "You got disconnected.";
|
||||||
|
|
||||||
|
public GoodbyeClientMessage() {
|
||||||
|
messageType = MessageType.GOODBYE_CLIENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
|
|
||||||
public class HelloClientMessage extends BasicMessage {
|
public class HelloClientMessage extends BasicMessage {
|
||||||
|
|
||||||
public final MessageType messageType = MessageType.HELLO_CLIENT;
|
|
||||||
|
|
||||||
/** Whether there is a running game that the player disconnected from */
|
/** Whether there is a running game that the player disconnected from */
|
||||||
@NotNull
|
@NotNull
|
||||||
public Boolean runningGame;
|
public Boolean runningGame;
|
||||||
|
|
||||||
|
public HelloClientMessage() {
|
||||||
|
messageType = MessageType.HELLO_CLIENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user