Пример #1
0
        public static int GameState(int gameId, int state)
        {
            int result;

            lock (EscapeBattle_K.Mutex)
            {
                EscapeBattlePkLogData log = null;
                if (!EscapeBattle_K.ThisLoopPkLogs.TryGetValue(gameId, out log))
                {
                    result = -11003;
                }
                else
                {
                    log.State = state;
                    foreach (int zhanDuiID in log.ZhanDuiIDs)
                    {
                        EscapeBattle_K.JoinPkData pkData;
                        if (EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out pkData))
                        {
                            EscapeBattle_K.ZhanDuiChangeState(pkData, state);
                        }
                    }
                    result = 0;
                }
            }
            return(result);
        }
Пример #2
0
 private static void PrepareGameFuBen(DateTime now)
 {
     for (int i = 0; i < EscapeBattle_K.JoinList.Count - (EscapeBattleConsts.MinZhanDuiNumPerGame - 1); i += EscapeBattleConsts.MinZhanDuiNumPerGame)
     {
         if (EscapeBattleConsts.MinZhanDuiNumPerGame == 3)
         {
             EscapeBattle_K.CreateGameFuBen(now, new EscapeBattle_K.JoinPkData[]
             {
                 EscapeBattle_K.JoinList[i],
                 EscapeBattle_K.JoinList[i + 1],
                 EscapeBattle_K.JoinList[i + 2]
             });
         }
         else if (EscapeBattleConsts.MinZhanDuiNumPerGame == 2)
         {
             EscapeBattle_K.CreateGameFuBen(now, new EscapeBattle_K.JoinPkData[]
             {
                 EscapeBattle_K.JoinList[i],
                 EscapeBattle_K.JoinList[i + 1]
             });
         }
         else if (EscapeBattleConsts.MinZhanDuiNumPerGame == 1)
         {
             EscapeBattle_K.CreateGameFuBen(now, new EscapeBattle_K.JoinPkData[]
             {
                 EscapeBattle_K.JoinList[i]
             });
         }
     }
 }
Пример #3
0
 public static void Update()
 {
     if (EscapeBattle_K.Initialize)
     {
         DateTime now        = TimeUtil.NowDateTime();
         TimeSpan timeOfWeek = TimeUtil.TimeOfWeek(now);
         bool     open       = false;
         lock (EscapeBattle_K.Mutex)
         {
             List <TimeSpan> list = EscapeBattle_K._Config.MatchConfigList[0].TimePoints;
             for (int i = 0; i < list.Count - 1; i += 2)
             {
                 if (list[i] <= timeOfWeek && timeOfWeek < list[i + 1])
                 {
                     open = true;
                     break;
                 }
             }
             if (EscapeBattle_K.SyncData.State != open)
             {
                 EscapeBattle_K.SyncData.State = open;
             }
             int nowSecs = (int)now.TimeOfDay.TotalSeconds;
             if (nowSecs / EscapeBattleConsts.BattleSignSecs != EscapeBattle_K.LastMatchMinute / EscapeBattleConsts.BattleSignSecs)
             {
                 EscapeBattle_K.LastMatchMinute = nowSecs;
                 EscapeBattle_K.PrepareMatchList();
             }
             EscapeBattle_K.PrepareGameFuBen(now);
             if (open)
             {
                 if (!EscapeBattle_K.NeedUpdateRank)
                 {
                     EscapeBattle_K.NeedUpdateRank = true;
                 }
             }
             else if ((EscapeBattle_K.NeedUpdateRank && EscapeBattle_K.ThisLoopPkLogs.Count == 0) || EscapeBattle_K.lastUpdateTime.Day != now.Day)
             {
                 EscapeBattle_K.NeedUpdateRank = false;
                 EscapeBattle_K.LoadSyncData(now, true);
             }
             EscapeBattle_K.ClearTimeOverGameFuBen(now);
         }
         KFCallMsg[] asyncEvArray = null;
         lock (EscapeBattle_K.Mutex)
         {
             asyncEvArray = EscapeBattle_K.AsyncEvQ.ToArray();
             EscapeBattle_K.AsyncEvQ.Clear();
         }
         foreach (KFCallMsg msg in asyncEvArray)
         {
             ClientAgentManager.Instance().BroadCastMsg(msg, 0);
         }
         EscapeBattle_K.lastUpdateTime = now;
     }
 }
Пример #4
0
        public static int GameResult(int gameId, List <int> zhanDuiScoreList)
        {
            int result;

            lock (EscapeBattle_K.Mutex)
            {
                EscapeBattlePkLogData log = null;
                LogManager.WriteLog(LogTypes.Trace, string.Format("EscapeBattle::GameResult,gameid={0},scoreList={1}", gameId, string.Join <int>("_", zhanDuiScoreList)), null, true);
                if (!EscapeBattle_K.ThisLoopPkLogs.TryGetValue(gameId, out log))
                {
                    result = 3;
                }
                else
                {
                    DateTime now = TimeUtil.NowDateTime();
                    for (int i = 0; i < zhanDuiScoreList.Count - 1; i += 2)
                    {
                        int zhanDuiID = zhanDuiScoreList[i];
                        int score     = zhanDuiScoreList[i + 1];
                        if (log.ZhanDuiIDs.Contains(zhanDuiID))
                        {
                            EscapeBattle_K.JoinPkData pkData;
                            if (EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out pkData))
                            {
                                if (pkData.InGame)
                                {
                                    pkData.InGame       = false;
                                    pkData.CurrGameID   = 0;
                                    pkData.DuanWeiJiFen = TianTi5v5Service.UpdateEscapeZhanDui(pkData.ZhanDuiID, score, now);
                                }
                            }
                            LogManager.WriteLog(LogTypes.Trace, string.Format("EscapeBattle::GameResult,gameid={0},zhanduiid={1},score={2}", gameId, zhanDuiID, score), null, true);
                            EscapeBattle_K.ZhanDuiChangeState(pkData, 5);
                        }
                    }
                    bool canRemove = true;
                    foreach (int zhanDuiID in log.ZhanDuiIDs)
                    {
                        EscapeBattle_K.JoinPkData pkData;
                        if (EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out pkData) && pkData.InGame)
                        {
                            canRemove = false;
                        }
                    }
                    if (canRemove)
                    {
                        EscapeBattle_K.ThisLoopPkLogs.Remove(gameId);
                        ClientAgentManager.Instance().RemoveKfFuben(EscapeBattle_K.GameType, log.ToServerID, (long)log.GameID);
                    }
                    result = 0;
                }
            }
            return(result);
        }
Пример #5
0
        private static void ClearTimeOverGameFuBen(DateTime now)
        {
            List <int> PkLogsRemoveList = new List <int>();

            foreach (int gameID in EscapeBattle_K.ThisLoopPkLogs.Keys.ToList <int>())
            {
                EscapeBattlePkLogData log;
                if (EscapeBattle_K.ThisLoopPkLogs.TryGetValue(gameID, out log))
                {
                    if (log.EndTime < now || log.State >= 7)
                    {
                        List <int> scoreList = new List <int>();
                        foreach (int zhanDuiID in log.ZhanDuiIDs)
                        {
                            scoreList.Add(zhanDuiID);
                            scoreList.Add(int.MinValue);
                        }
                        try
                        {
                            EscapeBattle_K.GameResult(gameID, scoreList);
                        }
                        catch (Exception ex)
                        {
                            LogManager.WriteException(ex.ToString());
                            PkLogsRemoveList.Add(log.GameID);
                        }
                    }
                }
            }
            foreach (int gameid in PkLogsRemoveList)
            {
                EscapeBattlePkLogData log;
                if (EscapeBattle_K.ThisLoopPkLogs.TryGetValue(gameid, out log))
                {
                    EscapeBattle_K.ThisLoopPkLogs.Remove(gameid);
                    ClientAgentManager.Instance().RemoveKfFuben(EscapeBattle_K.GameType, log.ToServerID, (long)log.GameID);
                }
            }
        }
Пример #6
0
 public static int _M4(int zhanDuiID, out int gameId, out int kuaFuServerID, out string[] ips, out int[] ports)
 {
     return(EscapeBattle_K.ZhengBaRequestEnter(zhanDuiID, out gameId, out kuaFuServerID, out ips, out ports));
 }
Пример #7
0
 public static int _M2(AutoCSer.Net.TcpInternalServer.ServerSocketSender _sender_, int zhanDuiID, int gameId, int srcServerID, out EscapeBattleFuBenData copyData)
 {
     return(EscapeBattle_K.ZhengBaKuaFuLogin(_sender_, zhanDuiID, gameId, srcServerID, out copyData));
 }
Пример #8
0
 public static int _M20(int zhanDuiID, int jiFen, int readyNum)
 {
     return(EscapeBattle_K.ZhanDuiJoin(zhanDuiID, jiFen, readyNum));
 }
Пример #9
0
 public static EscapeBattleSyncData _M1(EscapeBattleSyncData lastSyncData)
 {
     return(EscapeBattle_K.SyncZhengBaData(lastSyncData));
 }
Пример #10
0
 public static int _M22(int zhanDuiID)
 {
     return(EscapeBattle_K.GetZhanDuiState(zhanDuiID));
 }
Пример #11
0
 public static int _M21(int gameId, int state)
 {
     return(EscapeBattle_K.GameState(gameId, state));
 }
Пример #12
0
 public static int _M3(int gameId, List <int> zhanDuiScoreList)
 {
     return(EscapeBattle_K.GameResult(gameId, zhanDuiScoreList));
 }