public CMatchInstance( EMatchInstanceID id, CLobbyState lobby_state )
        {
            GameState = new CGameState( lobby_state.GameMode );
            GameState.Initialize_Game( lobby_state.Players );

            MatchState = new CMatchState( id, lobby_state.GameMode, lobby_state.GameCount );
            MatchState.Initialize_Match( lobby_state.Players );
            MatchState.Add_Observers( lobby_state );
        }
 // constructors
 public CClientLobby( CLobbyState lobby_state )
     : base(lobby_state)
 {
 }
		private static void Build_Lobby_Message_Samples( List< CNetworkMessage > message_list )
		{
			CLobbyConfig lobby_config = new CLobbyConfig();
			lobby_config.Initialize( "SampleLobbyConfig", EGameModeType.Four_Players, true, "SamplePassword" );

			message_list.Add( new CCreateLobbyRequest( lobby_config ) );
			message_list.Add( new CCreateLobbyFailure( EMessageRequestID.Start, ECreateLobbyFailureReason.Invalid_Config_Data ) );

			CLobbyState lobby_state = new CLobbyState( (ELobbyID) 666, lobby_config, (EPersistenceID) 5 );
			for ( int i = 0; i < 4; i++ )
			{
				lobby_state.Members.Add( (EPersistenceID) i, new CLobbyMember( (EPersistenceID) i ) );
				lobby_state.PlayersBySlot.Add( (uint) i, (EPersistenceID) i );
			}

			for ( int i = 0; i < 2; i++ )
			{
				lobby_state.Members.Add( (EPersistenceID) (i + 4), new CLobbyMember( (EPersistenceID) (i + 4) ) );
				lobby_state.Observers.Add( (EPersistenceID) (i + 4) );
			}

			message_list.Add( new CCreateLobbySuccess( EMessageRequestID.Start, lobby_state ) );
			message_list.Add( new CJoinLobbyByPlayerRequest( "SomePlayerName", "SomePassword" ) );
			message_list.Add( new CJoinLobbyByIDRequest( (ELobbyID) 5 ) );
			message_list.Add( new CJoinLobbyFailure( EMessageRequestID.Start, EJoinLobbyFailureReason.Creator_Is_Ignoring_You ) );
			message_list.Add( new CJoinLobbySuccess( EMessageRequestID.Start, lobby_state ) );
			message_list.Add( new CLeaveLobbyRequest() );
			message_list.Add( new CLeaveLobbyResponse( EMessageRequestID.Start, ELeaveLobbyFailureReason.Creator_Cannot_Leave ) );

			message_list.Add( new CLobbyOperationMessage( new CLobbyMemberJoinedOperation( (EPersistenceID) 4, "LeavingPlayer", ELobbyMemberType.Player, 1 ) ) );
			message_list.Add( new CLobbyOperationMessage( new CLobbyMemberLeftOperation( (EPersistenceID) 4, ERemovedFromLobbyReason.Lobby_Destroyed_By_Creator ) ) );
			message_list.Add( new CLobbyOperationMessage( new CLobbyMemberMovedOperation( (EPersistenceID) 4, ELobbyMemberType.Player, 1 ) ) );
			message_list.Add( new CLobbyOperationMessage( new CLobbyMembersSwappedOperation( (EPersistenceID) 4, (EPersistenceID) 5 ) ) );
			message_list.Add( new CLobbyOperationMessage( new CLobbyMemberChangeStateOperation( (EPersistenceID) 4, ELobbyMemberState.Ready ) ) );
			message_list.Add( new CLobbyOperationMessage( new CLobbyPlayerBannedOperation( (EPersistenceID) 4 ) ) );
			message_list.Add( new CLobbyOperationMessage( new CLobbyPlayerUnbannedOperation( (EPersistenceID) 4 ) ) );

			message_list.Add( new CDestroyLobbyRequest() );
			message_list.Add( new CDestroyLobbyResponse( EMessageRequestID.Start, EDestroyLobbyFailureReason.Not_In_A_Lobby ) );

			message_list.Add( new CLobbyChangeMemberStateMessage( ELobbyMemberState.Disconnected ) );
			message_list.Add( new CKickPlayerFromLobbyRequest( "PlayerToKick" ) );
			message_list.Add( new CKickPlayerFromLobbyResponse( EMessageRequestID.Start, EKickPlayerFromLobbyError.Cannot_Kick_Self ) );
			message_list.Add( new CBanPlayerFromLobbyRequest( "PlayerToBan" ) );
			message_list.Add( new CBanPlayerFromLobbyResponse( EMessageRequestID.Start, EBanPlayerFromLobbyError.Not_Lobby_Creator ) );
			message_list.Add( new CUnbanPlayerFromLobbyRequest( "PlayerToUnban" ) );
			message_list.Add( new CUnbanPlayerFromLobbyResponse( EMessageRequestID.Start, EUnbanPlayerFromLobbyError.Player_Not_Banned ) );
			message_list.Add( new CUnbannedFromLobbyNotificationMessage( "UnbannedPlayer" ) );
			message_list.Add( new CMovePlayerInLobbyRequest( (EPersistenceID) 10, ELobbyMemberType.Player, 1 ) );
			message_list.Add( new CMovePlayerInLobbyResponse( EMessageRequestID.Start, EMovePlayerInLobbyError.Invalid_Move_Destination ) );
			message_list.Add( new CLobbyStartMatchRequest() );
			message_list.Add( new CLobbyStartMatchResponse( EMessageRequestID.Start, EStartMatchError.Not_Everyone_Ready ) );
		}
 // Construction
 public CJoinLobbySuccess( EMessageRequestID request_id, CLobbyState lobby_state )
     : base(request_id)
 {
     LobbyState = lobby_state;
 }
 // Construction
 public CServerMatchInstance( EMatchInstanceID match_id, CLobbyState lobby_state )
     : base(match_id, lobby_state)
 {
     MatchChannel = EChannelID.Invalid;
     ObserverChannel = EChannelID.Invalid;
 }
        private EMatchInstanceID Create_Game_Instance_From_Lobby( CLobbyState lobby_state )
        {
            EMatchInstanceID id = Allocate_Match_Instance_ID();

            CServerMatchInstance match_instance = new CServerMatchInstance( id, lobby_state );

            m_MatchInstances.Add( id, match_instance );

            return id;
        }
 // Public Interface
 public void Transition_To_Game_Instance_From_Lobby( CLobbyState lobby_state )
 {
     EMatchInstanceID id = Create_Game_Instance_From_Lobby( lobby_state );
     Transition_To_Match( id );
 }
        private void Join_Lobby( CLobbyState lobby_state )
        {
            if ( Lobby != null )
            {
                throw new CApplicationException( "Joined a second lobby while one still exists on the client." );
            }

            Lobby = new CClientLobby( lobby_state );
            Create_Player_Infos_For_Lobby_Members( Lobby );

            CClientLogicalThread.Instance.Add_UI_Notification( new CUIScreenStateNotification( EUIScreenState.Lobby ) );
        }
		public void Add_Observers( CLobbyState lobby_state )
		{
			lobby_state.Observers.Apply( n => m_Observers.Add( n ) );
		}