feat: reworked GamestateEvent according to new standard

This commit is contained in:
Yannik Bretschneider 2021-05-05 17:32:18 +02:00
parent 9405b89fb3
commit 3038368ad8

View File

@ -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;
}
}