Manages session-level state as the single access point for phase transitions, game settings, and player resources. Phases and systems must use this manager rather than reading or writing session state on GameState directly.
Initialises session state from settings and resets phase to IDLE. Called by initializers at the start of a new or loaded game. currentPlayerId is set to the last player so that the first incrementPlayer call in TURN_NEXT_PLAYER wraps to index 0, starting the turn cycle from the beginning of the player array regardless of player type order.
Returns the current game phase.
Transitions the game to a new phase.
Stores the entity selected for a unit command. Called by IdlePhase when transitioning into ENTITY_COMMAND so EntityCommandPhase can read it on follow-up actions.
Returns the currently active entity, or null if none is set.
Returns the current turn number.
Advances to the next player in the players array, wrapping back to the start at the end.
Increments the turn counter by one.
Returns all players for the current session.
Returns the current player, or undefined if not found.
Returns a snapshot of session state. Called by SaveGame to persist the current session. Eventually each manager will contribute its own slice.
Restores session state from a saved snapshot. Called by LoadGame after the snapshot is fetched and validated.