feat: added (mostly redundant) Json annotations to Events and Requests

This commit is contained in:
Yannik Bretschneider 2021-06-03 22:58:25 +02:00
parent 5d5f649be1
commit 445bde1105
7 changed files with 44 additions and 0 deletions

View File

@ -1,14 +1,20 @@
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.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EventDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.EventSerializer;
import java.util.Objects;
/**
* Represents a character event for: {@link EventType#MeleeAttackEvent}, {@link EventType#RangedAttackEvent}, {@link EventType#MoveEvent}, {@link EventType#ExchangeInfinityStoneEvent}, {@link EventType#UseInfinityStoneEvent}.
*/
@JsonDeserialize(using = EventDeserializer.class)
@JsonSerialize(using = EventSerializer.class)
public class CharacterEvent extends Event {
public EntityID originEntity = null;
public EntityID targetEntity = null;

View File

@ -1,9 +1,16 @@
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.json.ingame.deserialize.EventDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.EventSerializer;
import java.util.HashMap;
import java.util.Objects;
/** Represents a custom event ({@link EventType#CustomEvent}). */
@JsonDeserialize(using = EventDeserializer.class)
@JsonSerialize(using = EventSerializer.class)
public class CustomEvent extends Event {
public String teamIdentifier;
public HashMap<String, Object> customContent;

View File

@ -1,12 +1,18 @@
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.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EventDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.EventSerializer;
import java.util.Objects;
/** Represents an entity event for: {@link EventType#DestroyedEntityEvent}, {@link EventType#TakenDamageEvent}, {@link EventType#ConsumedAPEvent}, {@link EventType#ConsumedMPEvent}, {@link EventType#SpawnEntityEvent}, {@link EventType#HealedEvent}. */
@JsonDeserialize(using = EventDeserializer.class)
@JsonSerialize(using = EventSerializer.class)
public class EntityEvent extends Event {
public EntityID targetEntity = null;
public IntVector2 targetField = null;

View File

@ -1,11 +1,17 @@
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.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EventDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.EventSerializer;
import java.util.Arrays;
import java.util.Objects;
/** Represents a game event for: {@link EventType#RoundSetupEvent}, {@link EventType#TurnEvent}, {@link EventType#WinEvent}, {@link EventType#TurnTimeoutEvent}, {@link EventType#TimeoutWarningEvent}, {@link EventType#TimeoutEvent}, {@link EventType#PauseStartEvent}, {@link EventType#PauseStopEvent}, {@link EventType#DisconnectEvent}. */
@JsonDeserialize(using = EventDeserializer.class)
@JsonSerialize(using = EventSerializer.class)
public class GameEvent extends Event {
public Integer roundCount;
public Integer turnCount;

View File

@ -1,13 +1,19 @@
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.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EventDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.EventSerializer;
import java.util.Arrays;
import java.util.Objects;
/** Represents the game state event ({@link EventType#GamestateEvent}). */
@JsonDeserialize(using = EventDeserializer.class)
@JsonSerialize(using = EventSerializer.class)
public class GamestateEvent extends Event {
public Entity[] entities;
public EntityID[] turnOrder;

View File

@ -1,14 +1,20 @@
package uulm.teamname.marvelous.gamelibrary.requests;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.RequestDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.RequestSerializer;
import java.util.Objects;
/** Represents a character event for: {@link RequestType#MeleeAttackRequest}, {@link RequestType#RangedAttackRequest}, {@link RequestType#MoveRequest}, {@link RequestType#ExchangeInfinityStoneRequest}, {@link RequestType#UseInfinityStoneRequest}. */
@JsonPropertyOrder({"requestType", "originEntity", "targetEntity", "originField", "targetField", "stoneType", "value"})
@JsonDeserialize(using = RequestDeserializer.class)
@JsonSerialize(using = RequestSerializer.class)
public class CharacterRequest extends Request {
public EntityID originEntity = null;
public EntityID targetEntity = null;

View File

@ -1,4 +1,11 @@
package uulm.teamname.marvelous.gamelibrary.requests;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.RequestDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.ingame.serialize.RequestSerializer;
/** Represents a game request for: {@link RequestType#DisconnectRequest}. */
@JsonDeserialize(using = RequestDeserializer.class)
@JsonSerialize(using = RequestSerializer.class)
public class GameRequest extends Request {}