feat: data classes for all events and requests

This commit is contained in:
punchready 2021-05-01 22:30:52 +02:00
parent 43cf4c6c1b
commit 3b286b4667
12 changed files with 177 additions and 6 deletions

View File

@ -0,0 +1,51 @@
package uulm.teamname.marvelous.gamelibrary.events;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
/** Represents a character event for: {@link EventType#MeleeAttackEvent}, {@link EventType#RangedAttackEvent}, {@link EventType#MoveEvent}, {@link EventType#ExchangeInfinityStoneEvent}, {@link EventType#UseInfinityStoneEvent}. */
public class CharacterEvent extends Event {
public EntityID originEntity = null;
public EntityID targetEntity = null;
public IntVector2 originField = null;
public IntVector2 targetField = null;
public Integer amount = null;
public StoneType stoneType = null;
@Override
public CharacterEvent type(EventType type) {
this.type = type;
return this;
}
public CharacterEvent setOriginEntity(EntityID originEntity) {
this.originEntity = originEntity;
return this;
}
public CharacterEvent setTargetEntity(EntityID targetEntity) {
this.targetEntity = targetEntity;
return this;
}
public CharacterEvent setOriginField(IntVector2 originField) {
this.originField = originField;
return this;
}
public CharacterEvent setTargetField(IntVector2 targetField) {
this.targetField = targetField;
return this;
}
public CharacterEvent setAmount(Integer amount) {
this.amount = amount;
return this;
}
public CharacterEvent setStone(StoneType stoneType) {
this.stoneType = stoneType;
return this;
}
}

View File

@ -0,0 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.events;
/** Represents a custom event ({@link EventType#CustomEvent}). */
public class CustomEvent extends Event {
public String teamIdentifier;
public Object customContent;
}

View File

@ -0,0 +1,32 @@
package uulm.teamname.marvelous.gamelibrary.events;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
/** Represents an entity event for: {@link EventType#DestroyedEntityEvent}, {@link EventType#TakenDamageEvent}, {@link EventType#ConsumedAPEvent}, {@link EventType#ConsumedMPEvent}, {@link EventType#SpawnEntityEvent}, {@link EventType#HealedEvent}. */
public class EntityEvent extends Event {
public EntityID targetEntity = null;
public IntVector2 targetField = null;
public Integer amount = null;
@Override
public EntityEvent type(EventType type) {
this.type = type;
return this;
}
public EntityEvent setTargetEntity(EntityID targetEntity) {
this.targetEntity = targetEntity;
return this;
}
public EntityEvent setTargetField(IntVector2 targetField) {
this.targetField = targetField;
return this;
}
public EntityEvent setAmount(Integer amount) {
this.amount = amount;
return this;
}
}

View File

@ -2,8 +2,12 @@ package uulm.teamname.marvelous.gamelibrary.events;
import uulm.teamname.marvelous.gamelibrary.json.ingame.MessageStructure;
/** Represents an abstract event sent inside a {@link MessageStructure} between client and server.
*/
/** Represents an abstract event sent inside a {@link MessageStructure} between client and server. */
public abstract class Event {
//TODO: implement Event
public EventType type;
public Event type(EventType type) {
this.type = type;
return this;
}
}

View File

@ -0,0 +1,10 @@
package uulm.teamname.marvelous.gamelibrary.events;
/** Specifies the type of an {@link Event}. */
public enum EventType {
//please make it stop
Ack, Nack, Req, GameStateEvent, CustomEvent,
DestroyedEntityEvent, TakenDamageEvent, ConsumedAPEvent, ConsumedMPEvent, SpawnEntityEvent, HealedEvent,
MeleeAttackEvent, RangedAttackEvent, MoveEvent, UseInfinityStoneEvent, ExchangeInfinityStoneEvent,
RoundSetupEvent, TurnEvent, WinEvent, TurnTimeoutEvent, TimeoutWarningEvent, TimeoutEvent, DisconnectEvent
}

View File

@ -0,0 +1,18 @@
package uulm.teamname.marvelous.gamelibrary.events;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
/** 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#DisconnectEvent}. */
public class GameEvent extends Event {
public int roundCount;
public int turnCount;
public EntityID[] characterOrder;
public EntityID nextCharacter;
public int playerWon;
public String message;
public int timeLeft;
}

View File

@ -0,0 +1,12 @@
package uulm.teamname.marvelous.gamelibrary.events;
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
/** Represents the game state event ({@link EventType#GameStateEvent}). */
public class GameStateEvent extends Event {
public Entity[][] map;
public EntityID[] turnOrder;
public EntityID activeCharacter;
public boolean winCondition;
}

View File

@ -0,0 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.events;
/** Represents a notification event for: {@link EventType#Ack}, {@link EventType#Nack}, {@link EventType#Req}. */
public class NotificationEvent extends Event {
}

View File

@ -0,0 +1,15 @@
package uulm.teamname.marvelous.gamelibrary.requests;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
/** Represents a character event for: {@link RequestType#MeleeAttackRequest}, {@link RequestType#RangedAttackRequest}, {@link RequestType#MoveRequest}, {@link RequestType#ExchangeInfinityStoneRequest}, {@link RequestType#UseInfinityStoneRequest}. */
public class CharacterRequest extends Request {
public EntityID originEntity = null;
public EntityID targetEntity = null;
public IntVector2 originField = null;
public IntVector2 targetField = null;
public Integer value = null; //why is it called amount in events and value in requests?
public StoneType stoneType = null;
}

View File

@ -0,0 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.requests;
/** Represents a game request for: {@link RequestType#DisconnectRequest}. */
public class GameRequest extends Request {
}

View File

@ -2,8 +2,7 @@ package uulm.teamname.marvelous.gamelibrary.requests;
import uulm.teamname.marvelous.gamelibrary.json.ingame.MessageStructure;
/** Represents an abstract request sent inside a {@link MessageStructure} between client and server.
*/
/** Represents an abstract request sent inside a {@link MessageStructure} between client and server. */
public abstract class Request {
//TODO: implement Request
public RequestType type;
}

View File

@ -0,0 +1,11 @@
package uulm.teamname.marvelous.gamelibrary.requests;
/** Specifies the type of a {@link Request}. */
public enum RequestType {
MeleeAttackRequest,
RangedAttackRequest,
MoveRequest,
ExchangeInfinityStoneRequest,
UseInfinityStoneRequest,
DisconnectRequest
}