Exemple #1
0
        /// <summary>
        /// 将加入本轮天梯赛的经理推进比赛池.
        /// </summary>
        /// <returns></returns>
        public LadderInfoEntity GetCompetitorToMatch()
        {
            //将状态置为分组
            var fightList   = new List <LadderManagerEntity>();
            var arenaLadder = new LadderInfoEntity();

            lock (_competitorLock)
            {
                ManagerFightDic = new Dictionary <Guid, Guid>();
                foreach (var dic in CompetitorDic)
                {
                    //将经理推进比赛池
                    ManagerFightDic.Add(dic.Key, Guid.Empty);
                    fightList.Add(dic.Value);
                }
                Status                   = EnumLadderStatus.Grouping;
                arenaLadder.Idx          = ShareUtil.GenerateComb();
                arenaLadder.FightList    = fightList;
                arenaLadder.StartTime    = StartTime;
                arenaLadder.GroupingTime = DateTime.Now;

                //开始新一轮报名
                CreateLadder();
            }

            return(arenaLadder);
        }
Exemple #2
0
        private MessageCode Start(DateTime startTime, DateTime endTime)
        {
            var      crowd   = CrosscrowdInfoMgr.GetCurrent(_domainId);
            DateTime curTime = DateTime.Now;

            if (crowd != null && crowd.EndTime > curTime)
            {
                return(MessageCode.CrowdNotEnding);
            }
            if (startTime >= endTime || endTime < curTime)
            {
                return(MessageCode.NbParameterError);
            }
            crowd           = new CrosscrowdInfoEntity();
            crowd.DomainId  = _domainId;
            crowd.StartTime = startTime;
            crowd.EndTime   = endTime;
            crowd.RowTime   = DateTime.Now;
            if (CrosscrowdInfoMgr.Insert(crowd))
            {
                CrowdManagerDic = new ConcurrentDictionary <Guid, int>();
                _crowdInfo      = crowd;
                _status         = EnumLadderStatus.Running;
                //CrossChatHelper.SendBannerCrowdOpen(_domainId);
                RobotCore.Instance.RunHook(EnumMatchType.CrossCrowd, endTime);
                return(MessageCode.Success);
            }
            else
            {
                return(MessageCode.NbUpdateFail);
            }
        }
Exemple #3
0
        /// <summary>
        /// 检查是否达到进入配对条件.
        /// </summary>
        void CheckStatus()
        {
            if (_status != EnumLadderStatus.Running)//前一轮还在分组中,请勿打扰
            {
                return;
            }
            DateTime curTime = DateTime.Now;

            if (curTime >= _crowdInfo.EndTime)
            {
                if (CheckProcessEnd())
                {
                    _status = EnumLadderStatus.End;
                    ISKillDouble();
                    SendKillPrize(_crowdInfo, _crowdMaxPoint, _crowdMaxLegendCount);
                    SendRankPrize(_crowdInfo);
                    SendMaxKillerPrize(_crowdInfo);
                    CrowdEnd();
                }
                return;
            }
            double timeInterval = curTime.Subtract(_startTime).TotalSeconds;
            int    playerNumber = CompetitorDic.Count;

            //SystemlogMgr.Info("CrowdThread-CheckStatus", string.Format("当前配对池状态:时间{0}s,人数{1}", timeInterval, playerNumber));
            foreach (var condition in _conditions)
            {
                if (timeInterval >= condition.WaitTime && playerNumber >= condition.PlayerNumber)
                {
                    _clearTimer.Stop();
                    RunPair();
                    break;
                }
            }
        }
Exemple #4
0
        private void Initialize()
        {
            CrowdManagerDic      = new ConcurrentDictionary <Guid, int>();
            CompetitorDic        = new ConcurrentDictionary <Guid, CrosscrowdManagerEntity>();
            ManagerFightDic      = new Dictionary <Guid, CrowdHeartEntity>();
            _crowdResurrectionCd = CacheFactory.AppsettingCache.GetAppSettingToInt(EnumAppsetting.CrowdResurrectionCd);
            _crowdCd             = CacheFactory.AppsettingCache.GetAppSettingToInt(EnumAppsetting.CrowdCd);
            _crowdMaxPoint       = CacheFactory.AppsettingCache.GetAppSettingToInt(EnumAppsetting.CrowdMaxPoint);
            _crowdMaxLegendCount = CacheFactory.AppsettingCache.GetAppSettingToInt(EnumAppsetting.CrowdMaxLegendCount);
            _startTime           = DateTime.Now;
            //初始化分组模板
            InitGroupTemplate();

            #region Init Condition dic
            string condition = CacheFactory.AppsettingCache.GetAppSetting(EnumAppsetting.CrowdCondition);
            _conditions = new List <ArenaCondition>();
            if (!string.IsNullOrEmpty(condition))
            {
                string[] tempConditions = condition.Split('|');
                foreach (var s in tempConditions)
                {
                    string[] temp = s.Split(',');
                    _conditions.Add(new ArenaCondition(Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1])));
                }
            }
            #endregion
            _nbThreadPool = new NBThreadPool(5);
            _clearTimer   = new Timer {
                Interval = ClearFightdicTime
            };
            _clearTimer.Elapsed += new ElapsedEventHandler(ClearFightDic);

            _timer = new Timer {
                Interval = 5000
            };
            _timer.Elapsed += new ElapsedEventHandler(CheckStatusJob);
            var      crowd   = CrosscrowdInfoMgr.GetCurrent(_domainId);
            DateTime curTime = DateTime.Now;
            if (crowd != null && crowd.EndTime > curTime)
            {
                _crowdInfo = crowd;
                _status    = EnumLadderStatus.Running;
                RobotCore.Instance.RunHook(EnumMatchType.CrossCrowd, _crowdInfo.EndTime);
            }
            else
            {
                _status = EnumLadderStatus.End;
            }
        }
Exemple #5
0
 void CrowdEnd()
 {
     try
     {
         _crowdInfo.Status = (int)EnumLadderStatus.End;
         CrosscrowdInfoMgr.Update(_crowdInfo);
         _crowdInfo    = null;
         CompetitorDic = new ConcurrentDictionary <Guid, CrosscrowdManagerEntity>();
         //CrossChatHelper.SendBannerCrowdEnd(_domainId);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("CrossCrowd-CrowdEnd", ex);
     }
     finally
     {
         _status = EnumLadderStatus.End;
     }
 }
Exemple #6
0
        /// <summary>
        /// Runs the arena match.
        /// </summary>
        void RunMatch()
        {
            if (_matchDic == null)
            {
                return;
            }
            try
            {
                Status = EnumLadderStatus.Running;
                foreach (var item in _matchDic.Values)
                {
                    var matchHome = new MatchManagerInfo(item.HomeId, item.HomeSiteId);
                    var matchAway = new MatchManagerInfo(item.AwayId, item.AwaySiteId);
                    var matchData = new BaseMatchData((int)EnumMatchType.CrossCrowd, item.Idx, matchHome, matchAway);
                    matchData.ErrorCode = (int)MessageCode.MatchWait;
                    MemcachedFactory.MatchClient.Set(matchData.MatchId, matchData);
                    Fight(matchData, item);
                }

                _matchDic           = null;
                _pairRecord.RowTime = DateTime.Now;
                CrosscrowdPairrecordMgr.Insert(_pairRecord);
                _pairRecord = null;
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("CrossCrowdProcess-RunMatch", ex);
            }
            finally
            {
                Status = EnumLadderStatus.End;
                if (_clearFightDicDelegate != null)
                {
                    _clearFightDicDelegate();
                }
            }
        }