refactor: changed GameStateEvent to GamestateEvent
This commit is contained in:
parent
e31cc1644d
commit
6e9efa1a59
@ -253,19 +253,19 @@ public class EventBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a generic {@link GameStateEvent} from the values given to the builder.
|
||||
* Builds a generic {@link GamestateEvent} from the values given to the builder.
|
||||
* <ul>
|
||||
* <li>type is the {@link EventType} of the {@link GameStateEvent}</li>
|
||||
* <li>type is the {@link EventType} of the {@link GamestateEvent}</li>
|
||||
* <li>entities is an array of {@link Entity Entities}</li>
|
||||
* <li>turnOrder describes the order in which characters take turns</li>
|
||||
* <li>activeCharacter describes the currently active character</li>
|
||||
* <li>describes whether the win condition is in effect</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return a {@link GameStateEvent} based on the builder
|
||||
* @return a {@link GamestateEvent} based on the builder
|
||||
*/
|
||||
public GameStateEvent buildGameStateEvent() throws IllegalStateException {
|
||||
var gameStateEvent = new GameStateEvent();
|
||||
public GamestateEvent buildGameStateEvent() throws IllegalStateException {
|
||||
var gameStateEvent = new GamestateEvent();
|
||||
gameStateEvent.type = this.type;
|
||||
gameStateEvent.entities = this.entities;
|
||||
gameStateEvent.turnOrder = this.turnOrder;
|
||||
|
@ -5,7 +5,7 @@ public enum EventType {
|
||||
// GameStateEvents
|
||||
Ack,
|
||||
Nack,
|
||||
GameStateEvent,
|
||||
GamestateEvent,
|
||||
|
||||
// CustomEvents
|
||||
CustomEvent,
|
||||
|
@ -7,8 +7,8 @@ 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 {
|
||||
/** Represents the game state event ({@link EventType#GamestateEvent}). */
|
||||
public class GamestateEvent extends Event {
|
||||
public Entity[] entities;
|
||||
public EntityID[] turnOrder;
|
||||
public IntVector2 mapSize;
|
||||
@ -24,7 +24,7 @@ public class GameStateEvent extends Event {
|
||||
|
||||
switch(type) {
|
||||
// GameState needs very specific properties
|
||||
case GameStateEvent:
|
||||
case GamestateEvent:
|
||||
if (this.entities == null ||
|
||||
this.turnOrder == null ||
|
||||
this.mapSize == null ||
|
||||
@ -44,7 +44,7 @@ public class GameStateEvent extends Event {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
GameStateEvent that = (GameStateEvent) o;
|
||||
GamestateEvent that = (GamestateEvent) o;
|
||||
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);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class GameLogic {
|
||||
}
|
||||
}
|
||||
case Req -> {
|
||||
result.add(new EventBuilder(EventType.GameStateEvent)
|
||||
result.add(new EventBuilder(EventType.GamestateEvent)
|
||||
.withEntities(state.entities.export())
|
||||
.withTurnOrder((EntityID[])state.turnOrder.toArray())
|
||||
.withMapSize(state.mapSize)
|
||||
@ -296,7 +296,7 @@ class GameLogic {
|
||||
}
|
||||
}
|
||||
case TimeStone -> {
|
||||
// "👍 i approve" - the server
|
||||
// "👍 i approve" - the server
|
||||
}
|
||||
case SoulStone -> {
|
||||
Character target = getCharacter(state, data.targetField, data.targetEntity);
|
||||
|
@ -205,7 +205,7 @@ class EventBuilderTest {
|
||||
.isTrue()
|
||||
.withFailMessage("GameStateEvent failed check");
|
||||
|
||||
var baseline = new GameStateEvent();
|
||||
var baseline = new GamestateEvent();
|
||||
baseline.type = EventType.ConsumedAPEvent;
|
||||
baseline.entities = entities;
|
||||
baseline.turnOrder = turns;
|
||||
@ -248,15 +248,15 @@ class EventBuilderTest {
|
||||
|
||||
assertThat(new EventBuilder(EventType.Nack).buildGameStateEvent().check()).isTrue();
|
||||
|
||||
assertThat(new EventBuilder(EventType.Req).buildGameStateEvent().check()).isTrue();
|
||||
// assertThat(new EventBuilder(EventType.Req).buildGameStateEvent().check()).isTrue();
|
||||
|
||||
assertThat(new EventBuilder(EventType.GameStateEvent) // if properties missing throw exception
|
||||
assertThat(new EventBuilder(EventType.GamestateEvent) // if properties missing throw exception
|
||||
.withTurnOrder(turns)
|
||||
.withActiveCharacter(turn)
|
||||
.buildGameStateEvent()
|
||||
.check()).isFalse();
|
||||
|
||||
assertThat(new EventBuilder(EventType.GameStateEvent) // no exception if all properties present
|
||||
assertThat(new EventBuilder(EventType.GamestateEvent) // no exception if all properties present
|
||||
.withEntities(entities)
|
||||
.withTurnOrder(turns)
|
||||
.withMapSize(new IntVector2(42, 24))
|
||||
|
Loading…
Reference in New Issue
Block a user