Ejemplo n.º 1
0
 /// <summary>
 /// 报名天梯赛.
 /// </summary>
 /// <returns></returns>
 public MessageCodeResponse AttendLadder(Guid managerId, bool hasTask, bool isGuide = false)
 {
     if (_ManagerMatchCD.ContainsKey(managerId))
     {
         if (_ManagerMatchCD[managerId] > DateTime.Now)
         {
             return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.LadderMatchCding));
         }
     }
     if (ManagerFightDic != null && ManagerFightDic.ContainsKey(managerId))
     {
         ManagerFightDic.Remove(managerId);
     }
     if (isGuide) //引导
     {
         var response = GuideMatch(managerId);
         if (response.Code == (int)MessageCode.Success)
         {
             return(response);
         }
     }
     if (!CompetitorDic.ContainsKey(managerId))
     {
         var manager = ManagerCore.Instance.GetManager(managerId);
         if (manager == null)
         {
             return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.LoginNoManager));
         }
         var arenaManager = InnerGetLadderManager(managerId);
         if (arenaManager == null)
         {
             return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.NbParameterError));
         }
         arenaManager.IsBot      = false;
         arenaManager.Name       = manager.Name;
         arenaManager.UpdateTime = DateTime.Now;
         arenaManager.HasTask    = true;
         //锁住
         lock (_competitorLock)
         {
             if (_playerNum == 0)
             {
                 StartTime = DateTime.Now;
             }
             CompetitorDic.Add(managerId, arenaManager);
             _playerNum++;
         }
     }
     return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.Success));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 将已进入比赛池的经理重新丢回排序池.
 /// </summary>
 /// <param name="arenaCompetitor">The arena competitor.</param>
 public void PushFightToCompetitor(LadderManagerEntity arenaCompetitor)
 {
     lock (_competitorLock)
     {
         if (ManagerFightDic != null && ManagerFightDic.ContainsKey(arenaCompetitor.ManagerId))
         {
             ManagerFightDic.Remove(arenaCompetitor.ManagerId);
             if (!CompetitorDic.ContainsKey(arenaCompetitor.ManagerId))
             {
                 if (_playerNum == 0)
                 {
                     StartTime = DateTime.Now;
                 }
                 CompetitorDic.Add(arenaCompetitor.ManagerId, arenaCompetitor);
                 _playerNum++;
             }
         }
     }
 }