diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/GamestateEvent.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/GamestateEvent.java index f1dd44a..2a8db2c 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/GamestateEvent.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/GamestateEvent.java @@ -56,4 +56,17 @@ public class GamestateEvent extends Event { result = 31 * result + Arrays.hashCode(stoneCooldowns); return result; } + + + @Override + public String toString() { + return "GamestateEvent{" + + "entities=" + Arrays.toString(entities) + + ", turnOrder=" + Arrays.toString(turnOrder) + + ", mapSize=" + mapSize + + ", activeCharacter=" + activeCharacter + + ", stoneCooldowns=" + Arrays.toString(stoneCooldowns) + + ", winCondition=" + winCondition + + '}'; + } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java index 96ead75..e63f8f3 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java @@ -1,17 +1,23 @@ package uulm.teamname.marvelous.gamelibrary.json.ingame; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import uulm.teamname.marvelous.gamelibrary.events.Event; +import uulm.teamname.marvelous.gamelibrary.json.MessageType; +import java.util.Arrays; import java.util.HashMap; +import java.util.Objects; /** Represents a message sent between client and server and contains all possible data. */ public class MessageStructure { - //TODO: revise MessageStructure according to actual standard document + + /** This is the message type. It is either REQUESTS or EVENTS, everything else would be invalid here */ + public MessageType messageType; /** The list of {@link Event}s sent inside the message. */ - public Event[] events; + public Event[] messages; - /** The checksum of the current game state at the time the message was sent */ + /** The checksum of the current game state at the time the message was sent. This is legacy (or optional). */ public int checksum; /** The type of the custom content sent with the message. */ @@ -19,4 +25,30 @@ public class MessageStructure { /** The decoded contents of the custom content sent. */ public HashMap customContent; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessageStructure that = (MessageStructure) o; + return checksum == that.checksum && messageType == that.messageType && Arrays.equals(messages, that.messages) && Objects.equals(customContentType, that.customContentType) && Objects.equals(customContent, that.customContent); + } + + @Override + public int hashCode() { + int result = Objects.hash(messageType, checksum, customContentType, customContent); + result = 31 * result + Arrays.hashCode(messages); + return result; + } + + @Override + public String toString() { + return "MessageStructure{" + + "messageType=" + messageType + + ", messages=" + Arrays.toString(messages) + + ", checksum=" + checksum + + ", customContentType='" + customContentType + '\'' + + ", customContent=" + customContent + + '}'; + } }