Class AddPlayer

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

public class AddPlayer extends NetworkEvent
Network event used to register a new player in the lobby.

The first player to join also proposes the desired number of players for the match. Subsequent joiners ignore proposedNPlayer if the game has already been created.

See Also:
  • Field Details

    • proposedNPlayer

      private final int proposedNPlayer
      Number of players proposed by this player; used only when creating a new game.
  • Constructor Details

    • AddPlayer

      public AddPlayer(String username, int proposedNPlayer)
      Class constructor. Initializes all the attributes.
      Parameters:
      username - the name of the player requesting the event
      proposedNPlayer - the number of proposed players to add to the match
  • Method Details

    • getProposedNPlayer

      public int getProposedNPlayer()
      Returns:
      the number of proposed players to add to the match
    • apply

      public boolean apply(GameController gameController)
      Description copied from class: NetworkEvent
      Applies this event to the specified 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 could be added to the match, false otherwise
    • apply

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