Пример #1
0
 static MessageCode doSendRankPrize(CrosscrowdInfoEntity crowd, CrosscrowdSendRankPrizeEntity entity, int maxPoint, int maxLegendCount)
 {
     try
     {
         if (entity.Status != 0)
         {
             return(MessageCode.Success);
         }
         if (entity.Score <= 0)
         {
             return(MessageCode.Success);
         }
         string      prizeItemString = "";
         var         mail            = new MailBuilder(entity.ManagerId, EnumMailType.CrossCrowdRank, entity.Rank);
         MessageCode mess            = BuildPrizeMail(crowd, mail, EnumCrowdPrizeCategory.CrossRank, entity.Rank, maxPoint, maxLegendCount, ref prizeItemString);
         if (mess != MessageCode.Success)
         {
             return(mess);
         }
         entity.Status = 1;
         CrosscrowdInfoMgr.SaveRankPrizeStatus(entity.Idx, entity.Status);
         if (!mail.Save(entity.SiteId))
         {
             return(MessageCode.NbParameterError);
         }
         SavePrizeRecord(entity.ManagerId, EnumCrowdPrizeCategory.CrossRank, "history:" + entity.Idx,
                         prizeItemString, entity.SiteId);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("CrossCrowd-doSendRankPrize", ex);
         return(MessageCode.NbParameterError);
     }
     return(MessageCode.Success);
 }
Пример #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);
            }
        }
Пример #3
0
 static void SendRankPrize(CrosscrowdInfoEntity crowdInfo)
 {
     if (crowdInfo.IsSendRankPrize)
     {
         return;
     }
     try
     {
         var  maxKiller = CrosscrowdInfoMgr.GetMaxKiller(crowdInfo.Idx);
         var  list      = CrosscrowdInfoMgr.GetForSendRankPrize(crowdInfo.Idx);
         bool isSend    = true;
         if (list != null)
         {
             bool isMaxKiller = false;
             foreach (var entity in list)
             {
                 isMaxKiller = false;
                 if (doSendRankPrize(crowdInfo, entity, -1, -1) != MessageCode.Success)
                 {
                     SystemlogMgr.Error("跨服群雄发奖", "发奖失败,idx=" + entity.Idx);
                     isSend = false;
                 }
             }
         }
         crowdInfo.IsSendRankPrize = isSend;
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("CrossCrowd-SendRankPrize", ex);
     }
 }
Пример #4
0
 void RunPairAfter()
 {
     CrosscrowdInfoMgr.Update(_crowdInfo);
     //将服务状态置为结束
     _status              = EnumLadderStatus.Running;
     _needClearFightDic   = true;
     _clearTimer.Interval = ClearFightdicTime; //启动清除上一轮比赛池计时器
     _clearTimer.Start();
 }
Пример #5
0
        public static MessageCode SendPrize()
        {
            var prizeList = CrosscrowdInfoMgr.C_CrossCrowdNotSendPrize();

            foreach (var item in prizeList)
            {
                AdminSendPrize(item.Idx);
            }
            return(MessageCode.Success);
        }
Пример #6
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;
            }
        }
Пример #7
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;
     }
 }
Пример #8
0
 static void SendKillPrize(CrosscrowdInfoEntity crowdInfo, int maxPoint, int maxLegendCount)
 {
     if (crowdInfo.IsSendKillPrize)
     {
         return;
     }
     try
     {
         var list = CrosscrowdInfoMgr.GetForSendKillPrize(crowdInfo.Idx);
         if (list != null)
         {
             foreach (var entity in list)
             {
                 doSendKillPrize(crowdInfo, entity, maxPoint, maxLegendCount);
             }
         }
         crowdInfo.IsSendKillPrize = true;
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("CrossCrowd-SendKillPrize", ex);
     }
 }
Пример #9
0
 public static string AdminSendPrize(int crowdId)
 {
     try
     {
         var crowd = CrosscrowdInfoMgr.GetById(crowdId);
         if (crowd == null)
         {
             return("crowd is null");
         }
         SendMaxKillerPrize(crowd);
         if (crowd.IsSendKillPrize && crowd.IsSendRankPrize)
         {
             return("prize has sended");
         }
         DateTime curTime        = DateTime.Now;
         var      crowdMaxPoint  = CacheFactory.AppsettingCache.GetAppSettingToInt(EnumAppsetting.CrowdMaxPoint);
         int      maxLegendCount = CacheFactory.AppsettingCache.GetAppSettingToInt(EnumAppsetting.CrowdMaxLegendCount);
         if (curTime >= crowd.EndTime)
         {
             ISKillDouble();
             SendKillPrize(crowd, crowdMaxPoint, maxLegendCount);
             SendRankPrize(crowd);
             crowd.Status = (int)EnumLadderStatus.End;
             CrosscrowdInfoMgr.Update(crowd);
             return("success");
         }
         else
         {
             return("the crowd not ending");
         }
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("AdminSendPrize", ex);
         return("cause exception:" + ex.Message);
     }
 }