From 81e53edb2a6057fd14ee726844f1a45c5329ae61 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Thu, 24 Jun 2021 15:25:02 +0200 Subject: [PATCH] feat: added TeleportedEvent --- .../gamelibrary/events/EventType.java | 3 + .../gamelibrary/events/TeleportedEvent.java | 56 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/main/java/uulm/teamname/marvelous/gamelibrary/events/TeleportedEvent.java diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventType.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventType.java index 44c8ff8..7d64255 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventType.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventType.java @@ -25,6 +25,9 @@ public enum EventType { UseInfinityStoneEvent, ExchangeInfinityStoneEvent, + // TeleportedEvent + TeleportedEvent, + // GameEvents RoundSetupEvent, TurnEvent, diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/TeleportedEvent.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/TeleportedEvent.java new file mode 100644 index 0000000..d7cd929 --- /dev/null +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/TeleportedEvent.java @@ -0,0 +1,56 @@ +package uulm.teamname.marvelous.gamelibrary.events; + +import uulm.teamname.marvelous.gamelibrary.IntVector2; +import uulm.teamname.marvelous.gamelibrary.entities.EntityID; + +import java.util.Objects; + +public class TeleportedEvent extends Event { + + public EntityID teleportedEntity; + + public IntVector2 originField, targetField; + + public EntityID originPortal, targetPortal; + + @Override + public boolean check() { + return teleportedEntity != null && + originField != null && + targetField != null && + originPortal != null && + targetPortal != null && + super.check(); + } + + @Override + public Event type(EventType type) { + return super.type(type); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + TeleportedEvent that = (TeleportedEvent) o; + return Objects.equals(teleportedEntity, that.teleportedEntity) && Objects.equals(originField, that.originField) && Objects.equals(targetField, that.targetField) && Objects.equals(originPortal, that.originPortal) && Objects.equals(targetPortal, that.targetPortal); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), teleportedEntity, originField, targetField, originPortal, targetPortal); + } + + @Override + public String toString() { + return "TeleportedEvent{" + + "teleportedEntity=" + teleportedEntity + + ", originField=" + originField + + ", targetField=" + targetField + + ", originPortal=" + originPortal + + ", targetPortal=" + targetPortal + + '}'; + } +}