Updated 'LobbyPlayerJoinedMessage' class.

Updated the 'LobbyPlayerJoinedMessage' class by adding the 'host' attribute and its getter method to.
This commit is contained in:
Daniel Grigencha
2024-12-02 00:12:46 +01:00
parent bfc74ee126
commit ea6431faa4

View File

@@ -19,16 +19,23 @@ public class LobbyPlayerJoinedMessage extends ServerMessage {
*/ */
private final int id; private final int id;
/**
* The flag is the new player is the host
*/
private final boolean host;
/** /**
* Constructs a new LobbyPlayerJoin instance with the specified player name. * Constructs a new LobbyPlayerJoin instance with the specified player name.
* *
* @param player the player joining the lobby * @param player the player joining the lobby
* @param id the id of the player * @param id the id of the player
* @param host as the flag if the player is the host as a Boolean.
*/ */
public LobbyPlayerJoinedMessage(int id, Player player) { public LobbyPlayerJoinedMessage(int id, Player player, boolean host) {
super(); super();
this.player = player; this.player = player;
this.id = id; this.id = id;
this.host = host;
} }
/** /**
@@ -37,6 +44,7 @@ public LobbyPlayerJoinedMessage(int id, Player player) {
private LobbyPlayerJoinedMessage() { private LobbyPlayerJoinedMessage() {
player = null; player = null;
id = 0; id = 0;
host = false;
} }
/** /**
@@ -57,6 +65,10 @@ public int getId(){
return id; return id;
} }
public boolean isHost() {
return this.host;
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *