feat: expose methods for game state event handling
This commit is contained in:
@ -174,20 +174,29 @@ class GameLogic {
|
||||
}
|
||||
}
|
||||
case Req -> {
|
||||
result.add(new EventBuilder(EventType.GamestateEvent)
|
||||
.withEntities(state.entities.export())
|
||||
.withTurnOrder((EntityID[])state.turnOrder.toArray())
|
||||
.withMapSize(state.mapSize)
|
||||
.withActiveCharacter(state.activeCharacter)
|
||||
.withStoneCooldowns(state.stoneCooldown.export())
|
||||
.withWinCondition(state.won)
|
||||
.buildGameStateEvent());
|
||||
result.add(buildGameStateEvent(state));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link EventType#GamestateEvent} for the given {@link GameState}.
|
||||
* @param state The game state to use
|
||||
* @return The resulting event
|
||||
*/
|
||||
public static Event buildGameStateEvent(GameState state) {
|
||||
return new EventBuilder(EventType.GamestateEvent)
|
||||
.withEntities(state.entities.export())
|
||||
.withTurnOrder((EntityID[])state.turnOrder.toArray())
|
||||
.withMapSize(state.mapSize)
|
||||
.withActiveCharacter(state.activeCharacter)
|
||||
.withStoneCooldowns(state.stoneCooldown.export())
|
||||
.withWinCondition(state.won)
|
||||
.buildGameStateEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a {@link Request} for validity for a {@link GameState}.
|
||||
* @param state The game state to check on
|
||||
|
Reference in New Issue
Block a user