Coverage Summary for Class: AddPlayer (it.polimi.ingsw.gc14.Network.NetworkEvents)

Class Class, % Method, % Branch, % Line, %
AddPlayer 0% (0/1) 0% (0/4) 0% (0/2) 0% (0/13)


 package it.polimi.ingsw.gc14.Network.NetworkEvents;
 
 import it.polimi.ingsw.gc14.Controller.GameController;
 import it.polimi.ingsw.gc14.ErrorType;
 import it.polimi.ingsw.gc14.Model.MiniModel;
 import it.polimi.ingsw.gc14.Network.EventType;
 import it.polimi.ingsw.gc14.Network.NetworkEvent;
 
 /**
  * Network event used to register a new player in the lobby.
  *
  * <p>The first player to join also proposes the desired number of players
  * for the match. Subsequent joiners ignore {@code proposedNPlayer} if the
  * game has already been created.
  */
 public class AddPlayer extends NetworkEvent {
     /** Number of players proposed by this player; used only when creating a new game. */
     private final int proposedNPlayer;
 
     /**
      * @return the number of proposed players to add to the match
      */
     public int getProposedNPlayer() {
         return proposedNPlayer;
     }
 
     /**
      * Class constructor.
      * Initializes all the attributes.
      * @param username the name of the player requesting the event
      * @param proposedNPlayer the number of proposed players to add to the match
      */
     public AddPlayer(String username, int proposedNPlayer) {
         super(username, EventType.ADD_PLAYER, false, ErrorType.GENERIC_ERROR);
         this.proposedNPlayer = proposedNPlayer;
     }
 
     /**
      * @param gameController the Game Controller on which to apply the event
      * @return true if the player could be added to the match, false otherwise
      */
     @Override
     public boolean apply(GameController gameController)
     {
         return gameController.addPlayer(username);
     }
 
     /**
      * Applies this event to the client-side mini model, updating players,
      * turn order, game state, and slot map.
      *
      * @param miniModel the client-side model to update.
      */
     @Override
     public void apply(MiniModel miniModel){
         synchronized (miniModel) {
             if (isError)
                 return;
             miniModel.setPlayers(playerList);
             miniModel.setOrderLogicCard(orderLogicCard);
             miniModel.setCurrentState(currentState);
             miniModel.setSlotPlayerMap(slotPlayerMap);
             miniModel.setLastEvent(this);
         }
     }
 }