/// <summary> /// Creates a new LobbyClient and assigns it to the list of lobbyClients /// </summary> /// <returns>LobbyClient instance for client /// </returns> private LobbyClient setUpNewLobbyClient(string name) { LobbyClient client = new LobbyClient(generateGuid(), name); //Add client to the list of clients lobbyClients.Add(client); return(client); }
/// <summary> /// Creates an new LobbyGame with an initial client /// </summary> /// <param name="firstClient"></param> /// <param name="thisGameLobbyGuidP"></param> public GameLobby(LobbyClient firstClient, Guid thisGameLobbyGuidP) { //monopolyDealGame = monopolyDealGameP; this.guid = thisGameLobbyGuidP; id = getNewLobbyID(); setLobbyName(); setStatus(GameLobbyStatus.Empty); if (addClientToGame(firstClient)) { setStatus(GameLobbyStatus.Not_Enough_Players_To_Start); } }
/// <summary> /// Used by a client to set if they are ready to start a game /// </summary> /// <param name="gameLobbyGuidP">game lobby client is connected to guid</param> /// <param name="clientGuidP">clients guid</param> /// <param name="readyP">true if ready, false if not</param> /// <returns>returns if method was successful</returns> public bool setLobbyClientReady(Guid gameLobbyGuidP, Guid clientGuidP, bool readyP) { GameLobby gl = getGameLobby(gameLobbyGuidP); LobbyClient lc = getLobbyClientByGuid(clientGuidP); bool success = gl.setClientReady(lc, readyP); if (success) { checkIfGameStarted(gameLobbyGuidP); } return(success); }
/// <summary> /// Creates an new LobbyGame with an initial client /// </summary> /// <param name="firstClient"></param> /// <param name="thisGameLobbyGuidP"></param> public GameLobby(LobbyClient firstClient, Guid thisGameLobbyGuidP) { //monopolyDealGame = monopolyDealGameP; this.guid = thisGameLobbyGuidP; id = getNewLobbyID(); setLobbyName(); setStatus(GameLobbyStatus.Empty); if (addClientToGame(firstClient)) { setStatus(GameLobbyStatus.Not_Enough_Players_To_Start); } }
internal bool setClientReady(LobbyClient lc, bool readyP) { //Safety Check foreach (LobbyClient client in getListOfClients()) { if (client.getLobbyClientGuid().CompareTo(lc.getLobbyClientGuid()) == 0) { client.setIfReadyToStart(readyP); return(true); } } return(false); }
public bool exitGameLobby(Guid clientGuidP) { try { LobbyClient lc = getLobbyClientByGuid(clientGuidP); GameLobby gl = getGameLobby(lc.getGuidOfGameLobbyAssignedTo()); return(gl.removeClientFromGame(lc)); } catch (Exception) { return(false); } }
/// <summary> /// Attempts to add a Client to an Existing Game Lobby /// /// </summary> /// <param name="gameLobbyGuidP"></param> /// <param name="clientGuidP"></param> /// <returns>returns true if </returns> public bool joinExistingGameLobby(Guid gameLobbyGuidP, Guid clientGuidP) { GameLobby gl = getGameLobby(gameLobbyGuidP); LobbyClient lc = getLobbyClientByGuid(clientGuidP); if (lc != null && gl.addClientToGame(lc)) { //Client successfully added to GameLobby return(true); } else { return(false); } }
public bool addClientToGame(LobbyClient client) { if ((status.CompareTo(GameLobbyStatus.Full) == 0) || (status.CompareTo(GameLobbyStatus.Game_In_Progress) == 0) || (status.CompareTo(GameLobbyStatus.Game_Ended) == 0)) { //Can't add client to this game return(false); } else { clientsConnectedToGame.Add(client); client.assignClientToGameLobby(getGameLobbyGuid()); numberOfClientsInGameLobbyChanged(); //client added return(true); } }
public bool removeClientFromGame(LobbyClient client) { if ((status.CompareTo(GameLobbyStatus.Game_In_Progress) == 0)) { //Can't remove client from this game game in progress return(false); } else { if (clientsConnectedToGame.Remove(client) && client.disassignClientFromGame()) { // client was in game and has been removed numberOfClientsInGameLobbyChanged(); return(true); } else { //client not removed return(false); } } }
/// <summary> /// Creates a new LobbyClient and assigns it to the list of lobbyClients /// </summary> /// <returns>LobbyClient instance for client /// </returns> private LobbyClient setUpNewLobbyClient(string name) { LobbyClient client = new LobbyClient(generateGuid(), name); //Add client to the list of clients lobbyClients.Add(client); return client; }
/// <summary> /// Client calls connect to lobby to be assigned a Guid so it can join games /// </summary> /// <returns>Guid of client to be used in calls to service /// </returns> public Guid connectToLobby(string name) { LobbyClient newClient = setUpNewLobbyClient(name); return(newClient.getLobbyClientGuid()); }
public bool addClientToGame(LobbyClient client) { if ((status.CompareTo(GameLobbyStatus.Full) == 0) || (status.CompareTo(GameLobbyStatus.Game_In_Progress) == 0) || (status.CompareTo(GameLobbyStatus.Game_Ended) == 0)) { //Can't add client to this game return false; } else { clientsConnectedToGame.Add(client); client.assignClientToGameLobby(getGameLobbyGuid()); numberOfClientsInGameLobbyChanged(); //client added return true; } }
internal bool setClientReady(LobbyClient lc, bool readyP) { //Safety Check foreach (LobbyClient client in getListOfClients()) { if (client.getLobbyClientGuid().CompareTo(lc.getLobbyClientGuid()) == 0) { client.setIfReadyToStart(readyP); return true; } } return false; }
public bool removeClientFromGame(LobbyClient client) { if ((status.CompareTo(GameLobbyStatus.Game_In_Progress) == 0)) { //Can't remove client from this game game in progress return false; } else { if (clientsConnectedToGame.Remove(client) && client.disassignClientFromGame()) { // client was in game and has been removed numberOfClientsInGameLobbyChanged(); return true; } else { //client not removed return false; } } }