Beispiel #1
0
        void RunMatch(ConcurrentDictionary <Guid, LadderMatchEntity> fightDic, LadderInfoEntity ladderInfo)
        {
            var process = new LadderProcess(fightDic, ladderInfo, _ladderProctiveScore);

            process.StartProcess();
        }
Beispiel #2
0
        /// <summary>
        /// 引导比赛
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        private MessageCodeResponse GuideMatch(Guid managerId)
        {
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager == null)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.NbParameterError));
            }
            var arenaManager = InnerGetLadderManager(managerId);

            if (arenaManager == null)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.NbParameterError));
            }


            if (ManagerGuideFightDic == null)
            {
                ManagerGuideFightDic = new Dictionary <Guid, Guid>();
            }
            var laddermanager = GetLadderManager(managerId);

            if (laddermanager.MatchTime > 0)
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.NbParameterError));
            }
            LadderManagerEntity bot = new LadderManagerEntity();
            var botList             = LadderManagerMgr.GetBot(1, 0, 1201);

            if (botList != null)
            {
                bot       = botList[0];
                bot.Name  = "送分小王子";
                bot.IsBot = true;
                bot.Score = laddermanager.Score;
            }

            laddermanager.IsBot      = false;
            laddermanager.Name       = manager.Name;
            laddermanager.UpdateTime = DateTime.Now;
            laddermanager.HasTask    = true;

            var ladderInfo = new LadderInfoEntity();

            ladderInfo.Idx       = ShareUtil.GenerateComb();
            ladderInfo.FightList = new List <LadderManagerEntity>()
            {
                laddermanager, bot
            };
            ladderInfo.StartTime     = DateTime.Now;
            ladderInfo.GroupingTime  = DateTime.Now;
            ladderInfo.CountdownTime = DateTime.Now;

            ladderInfo.CountdownTime = DateTime.Now.AddSeconds(1);

            ladderInfo.PlayerNumber = 2;
            ladderInfo.AvgWaitTime  = 2;

            var matchId     = ShareUtil.GenerateComb();
            var ladderMatch = new LadderMatchEntity(laddermanager, bot, matchId, ladderInfo.Idx, 1);
            ConcurrentDictionary <Guid, LadderMatchEntity> fightDic = new ConcurrentDictionary <Guid, LadderMatchEntity>();

            fightDic.TryAdd(ladderMatch.Idx, ladderMatch);

            MemcachedFactory.LadderMatchClient.Set(ladderMatch.Idx, ladderMatch);
            var process = new LadderProcess(fightDic, ladderInfo, LadderThread.Instance._ladderProctiveScore, true);

            process.StartProcess();
            if (!ManagerGuideFightDic.ContainsKey(managerId))
            {
                ManagerGuideFightDic.Add(managerId, matchId);
            }
            return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.Success));
        }