Class ReconnectPlayer

java.lang.Object
it.polimi.ingsw.gc14.Network.NetworkEvent
it.polimi.ingsw.gc14.Network.NetworkEvents.ReconnectPlayer
All Implemented Interfaces:
Serializable

public class ReconnectPlayer extends NetworkEvent
Network event used to notify that a player has reconnected to the game.
See Also:
  • Constructor Details

    • ReconnectPlayer

      public ReconnectPlayer(String username)
      Constructs a reconnection event for the specified player.
      Parameters:
      username - the username of the player who reconnected.
  • Method Details

    • enrichWithGameState

      public void enrichWithGameState(Game game, ArrayList<String> disconnectedUsernames)
      Description copied from class: NetworkEvent
      Populates this event with the current game state so clients can update their local model after receiving it. Subclasses that carry extra state (available totems, etc.) override this method and call super first.
      Overrides:
      enrichWithGameState in class NetworkEvent
      Parameters:
      game - the current game model.
      disconnectedUsernames - usernames of currently disconnected players.
    • apply

      public boolean apply(GameController gameController)
      Applies the reconnection event to the server-side game controller.
      Specified by:
      apply in class NetworkEvent
      Parameters:
      gameController - the game controller on which to apply the event.
      Returns:
      true if the player reconnection is handled successfully, false otherwise.
    • apply

      public void apply(MiniModel miniModel)
      Applies the reconnection update to the client-side mini model.

      If the event does not represent an error, the player data, turn order, current game state, and slot assignments are updated.

      Specified by:
      apply in class NetworkEvent
      Parameters:
      miniModel - the mini model on which to apply the event.