2021-05-01 20:30:52 +00:00
|
|
|
package uulm.teamname.marvelous.gamelibrary.events;
|
|
|
|
|
2021-05-05 15:32:18 +00:00
|
|
|
import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
2021-05-01 20:30:52 +00:00
|
|
|
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
|
|
|
|
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
|
|
|
|
|
2021-05-01 22:03:09 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Objects;
|
|
|
|
|
2021-05-01 20:30:52 +00:00
|
|
|
/** Represents the game state event ({@link EventType#GameStateEvent}). */
|
|
|
|
public class GameStateEvent extends Event {
|
2021-05-01 21:19:36 +00:00
|
|
|
public Entity[] entities;
|
2021-05-01 20:30:52 +00:00
|
|
|
public EntityID[] turnOrder;
|
2021-05-05 15:32:18 +00:00
|
|
|
public IntVector2 mapSize; // Stores the map size, for example for a 10x15 map [9,14] (starting from 0)
|
2021-05-01 20:30:52 +00:00
|
|
|
public EntityID activeCharacter;
|
2021-05-05 15:32:18 +00:00
|
|
|
public Integer[] stoneCooldowns; // Int[6]
|
2021-05-02 01:15:20 +00:00
|
|
|
public Boolean winCondition;
|
2021-05-01 22:03:09 +00:00
|
|
|
|
2021-05-03 17:25:36 +00:00
|
|
|
@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 ||
|
2021-05-05 15:32:18 +00:00
|
|
|
this.mapSize == null ||
|
2021-05-03 17:25:36 +00:00
|
|
|
this.activeCharacter == null ||
|
2021-05-05 15:32:18 +00:00
|
|
|
this.stoneCooldowns == null ||
|
2021-05-03 17:25:36 +00:00
|
|
|
this.winCondition == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-05-01 22:03:09 +00:00
|
|
|
@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;
|
2021-05-05 15:32:18 +00:00
|
|
|
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);
|
2021-05-01 22:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
2021-05-05 15:32:18 +00:00
|
|
|
int result = Objects.hash(super.hashCode(), mapSize, activeCharacter, winCondition);
|
2021-05-01 22:03:09 +00:00
|
|
|
result = 31 * result + Arrays.hashCode(entities);
|
|
|
|
result = 31 * result + Arrays.hashCode(turnOrder);
|
2021-05-05 15:32:18 +00:00
|
|
|
result = 31 * result + Arrays.hashCode(stoneCooldowns);
|
2021-05-01 22:03:09 +00:00
|
|
|
return result;
|
|
|
|
}
|
2021-05-01 20:30:52 +00:00
|
|
|
}
|