Class DisconnectedPlayer

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

public class DisconnectedPlayer extends NetworkEvent
Network event used to notify all clients that a player has disconnected.

Also carries the updated list of available totems, since a disconnection during totem selection may free a totem for other players.

See Also:
  • Field Details

    • availableTotems

      private List<Totems> availableTotems
      Updated list of totems available after the disconnection frees any previously chosen totem.
  • Constructor Details

    • DisconnectedPlayer

      public DisconnectedPlayer(String username)
      Constructs a disconnection event for the specified player.
      Parameters:
      username - the username of the player who disconnected.
  • 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 this disconnection 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 disconnection is handled successfully.
    • apply

      public void apply(MiniModel miniModel)
      Applies this disconnection event to the client-side mini model, updating player data, turn order, game state, and disconnected player list.
      Specified by:
      apply in class NetworkEvent
      Parameters:
      miniModel - the client-side model to update.