From 3038368ad8791dfb4e82b7be03bed0325feaadcf Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Wed, 5 May 2021 17:32:18 +0200 Subject: [PATCH] feat: reworked GamestateEvent according to new standard --- .../marvelous/gamelibrary/events/GameStateEvent.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 8fdce54..0eb8301 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/GameStateEvent.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/GameStateEvent.java @@ -1,5 +1,6 @@ package uulm.teamname.marvelous.gamelibrary.events; +import uulm.teamname.marvelous.gamelibrary.IntVector2; import uulm.teamname.marvelous.gamelibrary.entities.Entity; import uulm.teamname.marvelous.gamelibrary.entities.EntityID; @@ -10,7 +11,9 @@ import java.util.Objects; public class GameStateEvent extends Event { public Entity[] entities; public EntityID[] turnOrder; + public IntVector2 mapSize; // Stores the map size, for example for a 10x15 map [9,14] (starting from 0) public EntityID activeCharacter; + public Integer[] stoneCooldowns; // Int[6] public Boolean winCondition; @Override @@ -24,7 +27,9 @@ public class GameStateEvent extends Event { case GameStateEvent: if (this.entities == null || this.turnOrder == null || + this.mapSize == null || this.activeCharacter == null || + this.stoneCooldowns == null || this.winCondition == null) { return false; } @@ -40,14 +45,15 @@ public class GameStateEvent extends Event { if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; GameStateEvent that = (GameStateEvent) o; - return winCondition == that.winCondition && Arrays.equals(entities, that.entities) && Arrays.equals(turnOrder, that.turnOrder) && Objects.equals(activeCharacter, that.activeCharacter); + return Arrays.equals(entities, that.entities) && Arrays.equals(turnOrder, that.turnOrder) && Objects.equals(mapSize, that.mapSize) && Objects.equals(activeCharacter, that.activeCharacter) && Arrays.equals(stoneCooldowns, that.stoneCooldowns) && Objects.equals(winCondition, that.winCondition); } @Override public int hashCode() { - int result = Objects.hash(super.hashCode(), activeCharacter, winCondition); + int result = Objects.hash(super.hashCode(), mapSize, activeCharacter, winCondition); result = 31 * result + Arrays.hashCode(entities); result = 31 * result + Arrays.hashCode(turnOrder); + result = 31 * result + Arrays.hashCode(stoneCooldowns); return result; } }