/// <summary> /// Adds client to game /// </summary> /// <param name="client"></param> /// <returns>Returns true if client added. False if client is not added /// </returns> private void numberOfClientsInGameLobbyChanged() { if (status.CompareTo(GameLobbyStatus.Game_Ended) == 0) { if (clientsConnectedToGame.Count <= 0) { //no players left //Game should be cleaned up. } } if (clientsConnectedToGame.Count > MonopolyDeal.getMaxPlayers()) { setStatus(GameLobbyStatus.overFull); //To many players to start game } else if (clientsConnectedToGame.Count == MonopolyDeal.getMaxPlayers()) { setStatus(GameLobbyStatus.Full); } else if (clientsConnectedToGame.Count == 0) { setStatus(GameLobbyStatus.Empty); } else if (clientsConnectedToGame.Count == 1) { setStatus(GameLobbyStatus.Not_Enough_Players_To_Start); } else if (clientsConnectedToGame.Count >= MonopolyDeal.getMinPlayers()) { setStatus(GameLobbyStatus.Enough_Players_To_Start); } }
public bool checkIfGameStarted(Guid gameLobbyGuidP) { GameLobby gl = getGameLobby(gameLobbyGuidP); if (gl != null) { if (gl.getStatus().CompareTo(GameLobbyStatus.Game_In_Progress) == 0) { //Game started return(true); } else if (gl.areAllClientsReady()) { //Game not started but all clients are ready GameLobbyStatus gls = gl.getStatus(); if (gls.CompareTo(GameLobbyStatus.Enough_Players_To_Start) == 0 || gls.CompareTo(GameLobbyStatus.Full) == 0) { //There is enough clients to start a game and they are all ready if (startGame(gameLobbyGuidP)) { //At this point a new game has been started. return(true); } } } } return(false); }