refactor: prepared GamestateEvent and MessageStructure for further steps by generating Equals and ToString
This commit is contained in:
parent
2b5d46f577
commit
062281fdcb
@ -56,4 +56,17 @@ public class GamestateEvent extends Event {
|
|||||||
result = 31 * result + Arrays.hashCode(stoneCooldowns);
|
result = 31 * result + Arrays.hashCode(stoneCooldowns);
|
||||||
return result;
|
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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
package uulm.teamname.marvelous.gamelibrary.json.ingame;
|
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.events.Event;
|
||||||
|
import uulm.teamname.marvelous.gamelibrary.json.MessageType;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
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 MessageStructure {
|
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. */
|
/** 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;
|
public int checksum;
|
||||||
|
|
||||||
/** The type of the custom content sent with the message. */
|
/** 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. */
|
/** The decoded contents of the custom content sent. */
|
||||||
public HashMap<String, Object> customContent;
|
public HashMap<String, Object> 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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user