// Construction public CChatPlayer( EPersistenceID persistence_id, ESessionID session_id, string name, List< EPersistenceID > ignore_list ) { PersistenceID = persistence_id; SessionID = session_id; Name = name; ignore_list.ShallowCopy( m_IgnoreList ); }
// Public interface public CGameState Clone_By_Observer( EPersistenceID observer, bool is_admin ) { CGameState game_state = new CGameState(); // Unconditional cloning game_state.CurrentTurnIndex = CurrentTurnIndex; game_state.Mode = Mode; DiscardPiles.FullClone( game_state.m_DiscardPiles ); m_TurnSequence.ShallowCopy( game_state.m_TurnSequence ); foreach ( var side_pair in m_CardCollections ) { Dictionary< ECardColor, CCardCollection > collection_dictionary = new Dictionary< ECardColor, CCardCollection >(); game_state.m_CardCollections.Add( side_pair.Key, collection_dictionary ); side_pair.Value.FullClone( collection_dictionary ); } // Conditional cloning m_PlayerHands.VarClone( game_state.m_PlayerHands, n => ( is_admin || observer == n.Key ) ? EGameStateClonePermission.Full : EGameStateClonePermission.Hidden ); game_state.m_Deck = m_Deck.Clone( is_admin ? EGameStateClonePermission.Full : EGameStateClonePermission.Hidden ) as CDeck; return game_state; }
public EJoinLobbyFailureReason Check_Join( EPersistenceID player_id ) { CPersistentPlayerData creator_player_data = CDatabaseProxy.Instance.Get_Player_Data( Creator ); if ( creator_player_data.IgnoreList.Contains( player_id ) ) { return EJoinLobbyFailureReason.Creator_Is_Ignoring_You; } if ( !Can_Be_Joined() ) { return EJoinLobbyFailureReason.Lobby_Full; } if ( Is_Banned( player_id ) ) { return EJoinLobbyFailureReason.Banned; } if ( Password != null && Password.Length > 0 ) { return EJoinLobbyFailureReason.Password_Mismatch; } return EJoinLobbyFailureReason.None; }
private void Add_Player_To_Ignore_List( EPersistenceID player_id, EPersistenceID ignored_id ) { CChatPlayer player_data = Get_Player_By_Persistence_ID( player_id ); if ( player_data != null ) { player_data.Add_Ignored_Player( ignored_id ); } }
public void Remove_Member( EPersistenceID player_id ) { MatchState.Remove_Observer( player_id ); if ( MatchState.Remove_Player( player_id ) ) { CClientPlayerInfoManager.Instance.End_Player_Listen( player_id, EPlayerListenReason.In_Match ); } }
private void Add_Channel_To_Player( EPersistenceID player_id, EChannelID channel_id ) { CChatPlayer player = Get_Player_By_Persistence_ID( player_id ); if ( player != null ) { player.Add_Channel( channel_id ); } }
// Player ops public static void Join_General_Channel( EPersistenceID player_id, EMessageRequestID client_request_id ) { ESessionID session_id = CConnectedPlayerManager.Instance.Get_Active_Player_Session_ID( player_id ); Change_System_Channel( player_id, CConnectedPlayerManager.Instance.GeneralChatChannel, EChannelGameProperties.OrdinarySingletonMask, delegate( CResponseMessage response ) { On_Join_General_Channel_Response( response, session_id, client_request_id ); } ); }
private void Handle_Ignore_Player_Request( CIgnorePlayerRequest message, EPersistenceID source_player ) { CAddIgnoredPlayerPersistenceRequest ignore_request = new CAddIgnoredPlayerPersistenceRequest( source_player, message.PlayerName ); ignore_request.Handler = delegate( CPersistenceResponse response ) { On_Ignore_Persistence_Return( response, message.RequestID, source_player ); }; CDatabaseProxy.Instance.Submit_Request( ignore_request ); }
// Methods // Public interface public static bool Is_Ignoring( EPersistenceID source_player_id, EPersistenceID target_player_id ) { CPersistentPlayerData source_data = CDatabaseProxy.Instance.Get_Player_Data( source_player_id ); if ( source_data == null ) { return false; } return source_data.IgnoreList.Contains( target_player_id ); }
// Construction public CConnectedPlayer( EPersistenceID persistence_id, ESessionID session_id, string name ) { PersistenceID = persistence_id; SessionID = session_id; Name = name; LobbyID = ELobbyID.Invalid; MatchID = EMatchInstanceID.Invalid; State = EConnectedPlayerState.Chat_Idle; ConnectionState = EConnectedPlayerConnectionState.Connecting; }
public CClientPlayerInfo( EPersistenceID persistence_id, string player_name ) : base(persistence_id) { if ( player_name != null ) { Name = player_name; } Initialized = false; }
public void On_Player_Connection_State_Change( EPersistenceID player_id, bool is_connected ) { if ( is_connected ) { MatchState.On_Player_Reconnect( player_id ); } else { MatchState.On_Player_Disconnect( player_id ); } }
// Construction public CServerLobbyBrowser( EPersistenceID player_id, CBrowseLobbyMatchCriteria browse_criteria, bool join_first_available ) { PlayerID = player_id; WatchStartInterval = ELobbyID.Invalid; WatchEndInterval = ELobbyID.Invalid; BrowseCriteria = browse_criteria; JoinFirstAvailable = join_first_available; }
public static string Get_Player_Log_Name( EPersistenceID persistence_id ) { CConnectedPlayer player = Instance.Get_Player_By_Persistence_ID( persistence_id ); if ( player != null ) { return player.Name; } else { return String.Format( "Player#{0}", (int)persistence_id ); } }
// Public interface // Operations // Channel Creation public static void Create_Lobby_Chat_Channel( CChatChannelConfig channel_config, ELobbyID lobby_id, EPersistenceID source_player ) { CCreateChatChannelRequestServerMessage create_lobby_channel_message = new CCreateChatChannelRequestServerMessage( channel_config ); create_lobby_channel_message.Handler = delegate( CResponseMessage response ) { CCreateChatChannelResponseServerMessage response_msg = response as CCreateChatChannelResponseServerMessage; On_Lobby_Chat_Channel_Creation_Response( lobby_id, source_player, response_msg ); }; CServerMessageRouter.Send_Message_To_Chat_Server( create_lobby_channel_message ); }
// 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 ); }
// Construction public CChatChannelConfig( string internal_name, string external_name, EPersistenceID creator_id, EChannelGameProperties properties ) { InternalName = internal_name; ExternalName = external_name; CreatorID = creator_id; GameProperties = properties; ModeratorPermissions = EChannelModeratorPermissions.None; AllowsModeration = false; MaxMembers = 0; AnnounceJoinLeave = false; DestroyWhenEmpty = false; IsMembershipClientLocked = false; }
private void Cancel_Pending_Quickmatch( EPersistenceID player_id ) { EPersistenceID other_player_id = EPersistenceID.Invalid; if ( m_QuickmatchInvitesForward.TryGetValue( player_id, out other_player_id ) ) { m_QuickmatchInvitesForward.Remove( player_id ); m_QuickmatchInvitesBackward.Remove( other_player_id ); return; } if ( m_QuickmatchInvitesBackward.TryGetValue( player_id, out other_player_id ) ) { m_QuickmatchInvitesBackward.Remove( player_id ); m_QuickmatchInvitesForward.Remove( other_player_id ); return; } throw new CApplicationException( "Attempt to cancel a quickmatch with no record" ); }
public void Add_Member( EPersistenceID player_id ) { LobbyState.Members.Add( player_id, new CLobbyMember( player_id ) ); if ( LobbyState.PlayerCount < CGameModeUtils.Player_Count_For_Game_Mode( GameMode ) ) { LobbyState.PlayersBySlot.Add( Find_Open_Player_Slot(), player_id ); Mark_Players_Not_Ready(); if ( IsPublic && LobbyState.PlayerCount == CGameModeUtils.Player_Count_For_Game_Mode( GameMode ) ) { CServerLobbyBrowserManager.Instance.Notify_Browsers_Of_Full_Lobby( ID ); } } else { LobbyState.Observers.Add( player_id ); } On_Lobby_Delta_Change(); }
public void Add_Gagged( EPersistenceID id ) { Gagged.Add( id ); }
// Construction public CChatClientNotificationMessage( EChannelID channel_id, string target_name, EPersistenceID target_id, EChatNotification chat_event, string source_name ) : base() { ChannelID = channel_id; TargetName = target_name; TargetID = target_id; SourceName = source_name; ChatEvent = chat_event; }
// Public interface public IObservedClonableDelta Clone( EPersistenceID player_id, bool admin ) { bool visible = admin || player_id == PlayerID; return new CPlayerHandDelta( PlayerID, DeltaType, visible ? Color : ECardColor.Invalid, visible ? CardValue : ECardValue.Invalid ); }
// Construction public CRemoveIgnoredPlayerPersistenceResponse( EPersistenceRequestID request_id, EPersistenceID ignored_player_id ) : base(request_id, EPersistenceError.None) { IgnoredPlayerID = ignored_player_id; Result = EUnignorePlayerResult.Success; }
private void Send_Notification_To_Channel( EChannelID channel_id, EPersistenceID source_player_id, EPersistenceID target_player_id, EChatNotification chat_event, EPersistenceID skip_id ) { string source_player_name = Get_Player_Name_By_Persistence_ID( source_player_id ); string target_player_name = Get_Player_Name_By_Persistence_ID( target_player_id ); CChatClientNotificationMessage notification_message = new CChatClientNotificationMessage( channel_id, target_player_name, target_player_id, chat_event, source_player_name ); Send_Message_To_Channel( channel_id, notification_message, skip_id ); }
private void Send_Notification_To_Channel( EChannelID channel_id, EPersistenceID player_id, EChatNotification chat_event, EPersistenceID skip_id ) { Send_Notification_To_Channel( channel_id, EPersistenceID.Invalid, player_id, chat_event, skip_id ); }
public void Add_Member( EPersistenceID id ) { Members.Add( id ); }
// Construction public CGetPlayerIDPersistenceResponse( EPersistenceRequestID request_id, EPersistenceID player_id ) : base(request_id, EPersistenceError.None) { PlayerID = player_id; }
private bool Announce_Player( ESessionID session_id, EPersistenceID persistence_id, string name, List< EPersistenceID > ignore_list ) { if ( Get_Player_By_Session_ID( session_id ) != null || Get_Player_By_Persistence_ID( persistence_id ) != null ) { return false; } CChatPlayer new_player = new CChatPlayer( persistence_id, session_id, name, ignore_list ); m_Players.Add( persistence_id, new_player ); m_ActiveSessions.Add( session_id, persistence_id ); m_PlayersByName.Add( name.ToUpper(), persistence_id ); return true; }
public CAddIgnoredPlayerPersistenceRequest( EPersistenceID source_player, string ignored_player_name ) { SourcePlayer = source_player; IgnoredPlayerName = ignored_player_name; }
public CPlayerHandDelta( EPersistenceID player_id, ECardDelta delta_type, ECardColor color, ECardValue card_value ) { PlayerID = player_id; DeltaType = delta_type; Color = color; CardValue = card_value; }