Ejemplo n.º 1
0
        /// <summary>
        /// Runs the arena match.
        /// </summary>
        void RunMatch()
        {
            if (_fightDic == null)
            {
                return;
            }
            foreach (var item in _fightDic.Values)
            {
                var matchHome = new MatchManagerInfo(item.HomeId, item.HomeSiteId, false, item.HomeIsBot);
                var matchAway = new MatchManagerInfo(item.AwayId, item.AwaySiteId, false, item.AwayIsBot);
                var matchData = new BaseMatchData((int)EnumMatchType.CrossLadder, item.Idx, matchHome, matchAway);
                matchData.ErrorCode = (int)MessageCode.MatchWait;

                MemcachedFactory.MatchClient.Set(matchData.MatchId, matchData);

                //使用多线程
                _nbThreadPool.Add(() => Fight(matchData, item));
            }

            _nbThreadPool.WaitAll();
            _ladderInfo.Groups  = _fightDic.Count;
            _ladderInfo.RowTime = DateTime.Now;

            _ladderInfo.Season     = CacheFactory.CrossLadderCache.GetCurrentSeasonIndex();
            _ladderInfo.Status     = 2;
            _ladderInfo.UpdateTime = DateTime.Now;

            _ladderInfo.FightList = null;
            _fightDic             = null;

            CrossladderInfoMgr.Insert(_ladderInfo);
            _ladderInfo = null;
        }
Ejemplo n.º 2
0
 public MessageCode ScoreToHonorJob()
 {
     var season = CacheFactory.CrossLadderCache.GetCurrentSeason();
     if (season == null)
     {
         return MessageCode.LadderNoSeason;
     }
     var curDate = DateTime.Today;
     if (season.Idx == 1 && curDate == season.Startdate)
         return MessageCode.LadderSeasonDonotNeedSend;
     int isNewSeason = 0;
     int curSeason = season.Idx;
     if (season.Startdate == curDate && season.Idx > 1)
     {
         isNewSeason = 1;
         curSeason = curSeason - 1;
     }
     CrossladderInfoMgr.ScoreToHonor(DateTime.Today, curSeason, isNewSeason,_domainId);
     SendDailyHonor();
     //SendDailyPrize(curDate.AddDays(-1),season.Status);
     if (isNewSeason == 1)
     {
         var curSeasonEntity = CacheFactory.CrossLadderCache.GetEntity(curSeason);
         SendSeasonPrize(curSeason, curSeasonEntity==null?0:curSeasonEntity.Status);
     }
     return MessageCode.Success;
 }