Coverage Summary for Class: LobbyInfo (it.polimi.ingsw.Server.Messages.ServerResponses.SupportStructures)

Class Class, % Method, % Line, %
LobbyInfo 0% (0/1) 0% (0/6) 0% (0/11)


1 package it.polimi.ingsw.Server.Messages.ServerResponses.SupportStructures; 2  3 import it.polimi.ingsw.Server.Lobby; 4  5 import java.io.Serial; 6 import java.io.Serializable; 7 import java.util.List; 8 import java.util.UUID; 9  10 /** 11  * Information about a {@link Lobby} to be shared with clients 12  */ 13 public class LobbyInfo implements Serializable { 14  @Serial 15  private static final long serialVersionUID = 314L; 16  private final String admin; 17  private final UUID ID; 18  private final boolean isPublic; 19  private final int maxPlayers; 20  private final List<String> players; 21  22  /** 23  * Generate the lobby info 24  * 25  * @param lobby the lobby to get the info of 26  */ 27  public LobbyInfo(Lobby lobby) { 28  this.admin = lobby.getAdmin(); 29  this.ID = lobby.getId(); 30  this.isPublic = lobby.isPublic(); 31  this.maxPlayers = lobby.getMaxPlayers(); 32  this.players = lobby.getPlayers(); 33  } 34  35  /** 36  * Get the admin nickname 37  * 38  * @return the admin nickname 39  */ 40  public String getAdmin() { 41  return admin; 42  } 43  44  /** 45  * Get the UUID of the Lobby 46  * 47  * @return the UUID of the Lobby 48  */ 49  public UUID getID() { 50  return ID; 51  } 52  53  /** 54  * Check if the Lobby is public 55  * 56  * @return true if the lobby is public 57  */ 58  public boolean isPublic() { 59  return isPublic; 60  } 61  62  /** 63  * Get the maximum amount of players allowed in the lobby 64  * 65  * @return the max size of the lobby 66  */ 67  public int getMaxPlayers() { 68  return maxPlayers; 69  } 70  71  /** 72  * Get connected player nicknames 73  * 74  * @return an Unmodifiable {@link List} containing the connected players 75  */ 76  public List<String> getPlayers() { 77  return List.copyOf(players); 78  } 79 }