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 );
        }
        // Construction
        public CMatchInstance( EMatchInstanceID id, EPersistenceID player1, EPersistenceID player2, uint game_count )
        {
            GameState = new CGameState( EGameModeType.Two_Players );

            List< EPersistenceID > players = new List< EPersistenceID >();
            players.Add( player1 );
            players.Add( player2 );

            GameState.Initialize_Game( players );

            MatchState = new CMatchState( id, EGameModeType.Two_Players, game_count );
            MatchState.Initialize_Match( players );
        }
        private void On_Match_State_Delta( CMatchState.CMatchStateDelta delta )
        {
            switch ( delta.State )
            {
                case EMatchInstanceState.Halted_End_Of_Match:
                    CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Match_Halt_Because_Match_Over );
                    break;

                case EMatchInstanceState.Halted_End_Of_Game:
                    CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Match_Halt_Because_Game_Over );
                    break;

                case EMatchInstanceState.Halted_Player_Left:
                    CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Match_Halt_Because_Player_Left );
                    break;
            }
        }
        private void On_Match_Continue_State_Delta( CMatchState.CMatchContinueStateDelta delta )
        {
            bool is_self = delta.PlayerID == CClientLogicalThread.Instance.ConnectedID;

            switch ( delta.State )
            {
                case EMatchContinueState.Accepted:
                    if ( is_self )
                    {
                        CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Match_Continue_State_Self_Yes );
                    }
                    else
                    {
                        CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Match_Continue_State_Player_Yes,
                                                                                     CClientPlayerInfoManager.Instance.Get_Player_Name( delta.PlayerID ) );
                    }
                    break;

                case EMatchContinueState.Declined:
                    if ( is_self )
                    {
                        CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Match_Continue_State_Self_No );
                    }
                    else
                    {
                        CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Match_Continue_State_Player_No,
                                                                                     CClientPlayerInfoManager.Instance.Get_Player_Name( delta.PlayerID ) );
                    }
                    break;
            }
        }
 // Construction
 public CClientMatchInstance( CMatchState match_state, CGameState game_state )
     : base(match_state, game_state)
 {
 }
 // Construction
 public CJoinMatchSuccess( CMatchState match_state, CGameState game_state )
     : base()
 {
     MatchState = match_state;
     GameState = game_state;
 }
		private static void Build_Match_Message_Samples( List< CNetworkMessage > message_list )
		{
			List< EPersistenceID > player_list = new List< EPersistenceID >();
			player_list.Add( (EPersistenceID) 2 );
			player_list.Add( (EPersistenceID) 3 );

			CMatchState match_state = new CMatchState( (EMatchInstanceID) 1, EGameModeType.Two_Players, 3 );
			match_state.Initialize_Match(player_list );

			CGameState game_state = new CGameState( EGameModeType.Two_Players );
			game_state.Initialize_Game( player_list );

			message_list.Add( new CJoinMatchSuccess( match_state, game_state ) );

			message_list.Add( new CMatchPlayerLeftMessage( (EPersistenceID) 5, EMatchRemovalReason.Player_Request ) );
			message_list.Add( new CMatchPlayerConnectionStateMessage( (EPersistenceID) 11, true ) );
			message_list.Add( new CLeaveMatchRequest() );
			message_list.Add( new CLeaveMatchResponse( (EMessageRequestID) 2, ELeaveMatchFailureError.Not_In_Match ) );

			message_list.Add( new CMatchTakeTurnRequest( new CPlayCardGameAction( new CCard( ECardColor.Green, ECardValue.Four ) ), new CDrawFromDiscardGameAction( ECardColor.Red ) ) );
			message_list.Add( new CMatchTakeTurnResponse( (EMessageRequestID) 5, EGameActionFailure.Card_Is_Not_In_Your_Hand ) );

			List< IObservedClonableDelta > deltas = new List< IObservedClonableDelta >();
			deltas.Add( new CCardCollection.CCardCollectionDelta( EGameSide.Side2, ECardColor.Blue, ECardValue.Eight ) );
			deltas.Add( new CDeck.CDeckDelta() );
			deltas.Add( new CDiscardPile.CDiscardPileDelta( ECardDelta.Add, ECardColor.White, ECardValue.Multiplier2 ) );
			deltas.Add( new CGameState.CGameStateDelta( 2 ) );
			deltas.Add( new CPlayerHand.CPlayerHandDelta( (EPersistenceID)6, ECardDelta.Remove, ECardColor.Yellow, ECardValue.Two ) );

			message_list.Add( new CMatchDeltaSetMessage( deltas ) );

			List< CAbstractMatchDelta > match_deltas = new List< CAbstractMatchDelta >();
			match_deltas.Add( new CSideMatchStats.CSideMatchStatsDelta( EGameSide.Side2, 132, 2, 3, 2 ) );

			message_list.Add( new CMatchStateDeltaMessage( match_deltas ) );

			message_list.Add( new CContinueMatchRequest( true ) );
			message_list.Add( new CContinueMatchResponse( (EMessageRequestID) 5, EContinueMatchFailure.Cannot_Change_Previous_Commitment ) );

			message_list.Add( new CMatchNewGameMessage( game_state ) );
		}
			// Public interface
			public override void Apply( CMatchState match_state )
			{
				match_state.Set_Continue_State_For_Player( PlayerID, State );
			}
		public abstract void Apply( CMatchState match_state );
		// Public Interface
		public CMatchState Clone_By_Observer( EPersistenceID observer_id )
		{
			CMatchState clone = new CMatchState( ID, Mode, GameCount );
			clone.State = State;
			clone.CurrentGameNumber = CurrentGameNumber;

			// Unconditional cloning
			SideResults.SimpleClone( clone.m_SideResults );
			m_Players.ShallowCopy( clone.m_Players );
			SideBindings.ShallowCopy( clone.m_SideBindings );
			m_ContinueStates.ShallowCopy( clone.m_ContinueStates );

			// admin-only info
			if ( Is_Admin_Observer( observer_id ) )
			{
				m_AdminObservers.ShallowCopy( clone.m_AdminObservers );
				m_Observers.ShallowCopy( clone.m_Observers );
			}

			return clone;
		}
			// Public interface
			public override void Apply( CMatchState match_state )
			{
				match_state.CurrentGameNumber = CurrentGameNumber;
			}
			// Public interface
			public override void Apply( CMatchState match_state )
			{
				match_state.Halt_Match( State );
			}
 public CMatchInstance( CMatchState match_state, CGameState game_state )
 {
     GameState = game_state;
     MatchState = match_state;
 }