Skip to content
Snippets Groups Projects

added notification feature to commants

Merged Petter Selfors Rølvåg requested to merge dev2 into dev
10 files
+ 94
53
Compare changes
  • Side-by-side
  • Inline
Files
10
@@ -12,12 +12,22 @@ public class cLobbyLeave extends Command{
@@ -12,12 +12,22 @@ public class cLobbyLeave extends Command{
@Override
@Override
public void execute(PlayerController playerController, Connection connection){
public void execute(PlayerController playerController, Connection connection){
if(data instanceof Integer){
if(data instanceof Lobby){
int result = (int) data;
Lobby lobby = (Lobby) data;
if (result == -1) System.out.println("Failed to leave lobby");
if(lobby.getID() != -1){
else {
if (lobby.getPlayersID().contains((Integer) connection.getID())) {
playerController.setLobby(new Lobby(-1));
//Somebody else left
System.out.println("Request to leave lobby successful");
System.out.println("Somebody left the lobby");
 
playerController.setLobby(lobby);
 
}
 
else{
 
//The current player left
 
playerController.setLobby(new Lobby(-1));
 
System.out.println("Request to leave lobby successful");
 
}
 
}
 
else{
 
System.out.println("Received leaveLobby command with an error");
}
}
}
}
}
}
Loading