package uulm.teamname.marvelous.gamelibrary.events; import uulm.teamname.marvelous.gamelibrary.entities.Entity; import uulm.teamname.marvelous.gamelibrary.entities.EntityID; import java.util.Arrays; import java.util.Objects; /** Represents the game state event ({@link EventType#GameStateEvent}). */ public class GameStateEvent extends Event { public Entity[] entities; public EntityID[] turnOrder; public EntityID activeCharacter; public Boolean winCondition; @Override public boolean check() { if(!super.check()) { return false; } switch(type) { // GameState needs very specific properties case GameStateEvent: if (this.entities == null || this.turnOrder == null || this.activeCharacter == null || this.winCondition == null) { return false; } break; } return true; } @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; GameStateEvent that = (GameStateEvent) o; return winCondition == that.winCondition && Arrays.equals(entities, that.entities) && Arrays.equals(turnOrder, that.turnOrder) && Objects.equals(activeCharacter, that.activeCharacter); } @Override public int hashCode() { int result = Objects.hash(super.hashCode(), activeCharacter, winCondition); result = 31 * result + Arrays.hashCode(entities); result = 31 * result + Arrays.hashCode(turnOrder); return result; } }