Пример #1
0
        /// <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);
        }
Пример #2
0
 /// <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);
     }
 }
Пример #3
0
        /// <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);
        }
Пример #4
0
 /// <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);
     }
 }
Пример #5
0
 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);
 }
Пример #6
0
 public bool exitGameLobby(Guid clientGuidP)
 {
     try
     {
         LobbyClient lc = getLobbyClientByGuid(clientGuidP);
         GameLobby   gl = getGameLobby(lc.getGuidOfGameLobbyAssignedTo());
         return(gl.removeClientFromGame(lc));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #7
0
        /// <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);
            }
        }
Пример #8
0
 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);
     }
 }
Пример #9
0
 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);
         }
     }
 }
Пример #10
0
 /// <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;
 }
Пример #11
0
        /// <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());
        }
Пример #12
0
 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;
     }
 }
Пример #13
0
 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;
 }
Пример #14
0
 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;
         }
     }
 }