コード例 #1
0
        /// <summary>
        /// Helper method to update <see cref="Player"/> data in the database
        /// </summary>
        /// <param name="playerDAO">DAO for <see cref="Player"/>s</param>
        /// <param name="session">The current game <see cref="Session"/></param>
        /// <param name="serverInfo">The current <see cref="ServerInfo"/></param>
        /// <param name="missionSession">The current <see cref="MissionSession"/></param>
        /// <returns>The current set of <see cref="PlayerSession"/>s</returns>
        private ISet<PlayerSession> UpdatePlayerData(PlayerDAO playerDAO, Session session, ServerInfo serverInfo, MissionSession missionSession) {
            ISet<PlayerSession> playerSessions = playerDAO.GetOrCreatePlayerSessions(serverInfo.Players, session);

            foreach (PlayerSession playerSession in playerSessions) {
                playerSession.Updated = true;
                playerSession.Length += (Settings.Default.pollRate / 1000);
                if (playerSession.Played == false && CheckPlayedThreshold(playerSession.Length)) {
                    playerSession.Played = true;
                }
            }

            playerDAO.UpdatePlayerSessions(playerSessions);
            return playerSessions;
        }
コード例 #2
0
        /// <summary>
        /// Build DAOs if we need to build DAOs
        /// </summary>
        /// <param name="connection">the current <see cref="MySqlConnection"/></param>
        /// <param name="playerDAO">DAO for <see cref="Player"/>s</param>
        /// <param name="missionDAO">DAO for <see cref="Mission"/>s</param>
        /// <param name="sessionDAO">DAO for <see cref="Session"/>s</param>
        /// <param name="pstmsDAO">DAO for <see cref="PlayerSessionToMissionSession"/>s</param>
        private void BuildDAOsIfNeeded(ref MySqlConnection connection,
                                       ref PlayerDAO playerDAO,
                                       ref MissionDAO missionDAO,
                                       ref SessionDAO sessionDAO,
                                       ref PlayerSessionToMissionSessionDAO pstmsDAO) {

            if (connection == null || connection.State == ConnectionState.Closed) {
                connection = DatabaseUtil.OpenDataSource();
                playerDAO = new PlayerDAO(connection);
                missionDAO = new MissionDAO(connection);
                sessionDAO = new SessionDAO(connection);
                pstmsDAO = new PlayerSessionToMissionSessionDAO(connection);
            }
        }
コード例 #3
0
 /// <summary>
 /// Helper method to update the session info
 /// </summary>
 /// <param name="serverInfoService">service to get info from an A3 server</param>
 /// <param name="sessionDAO">DAO for <see cref="Session"/>s</param>
 /// <param name="playerDAO">DAO for <see cref="Player"/>s</param>
 /// <param name="missionDAO">DAO for <see cref="Mission"/>s</param>
 /// <param name="pstmsDAO">DAO for <see cref="PlayerSessionToMissionSession"/>s</param>
 /// <param name="host">A3 server host</param>
 /// <param name="port">A3 server port</param>
 /// <param name="session">The current game <see cref="Session"/></param>
 /// <param name="missionCount">The number of missions played</param>
 /// <param name="inGame">Boolean to check if the server is currently in game</param>
 /// <returns>The current mission session</returns>
 private Session UpdateInfo(ServerInfoService serverInfoService, SessionDAO sessionDAO, PlayerDAO playerDAO, MissionDAO missionDAO, PlayerSessionToMissionSessionDAO pstmsDAO,
                            string host, int port, Session session, ref int missionCount, ref bool inGame) {
     ServerInfo serverInfo = serverInfoService.GetServerInfo(host, port);
     inGame = CheckServerRunningState(serverInfo.ServerState);
     if (inGame) {
         UpdateSessionData(sessionDAO, session, serverInfo);
         MissionSession missionSession = UpdateMissionData(missionDAO, session, serverInfo, ref missionCount);
         ISet<PlayerSession> playerSessions = UpdatePlayerData(playerDAO, session, serverInfo, missionSession);
         UpdatePTSTMTSData(pstmsDAO, missionSession, playerSessions);
     }
     return session;
 }