Exemple #1
0
        /// <summary>
        /// Builds the bot.
        /// </summary>
        private void BuildBot(LadderInfoEntity ladderInfo)
        {
            var managerFightList = ladderInfo.FightList;

            var competitorCount = managerFightList.Count;

            try
            {
                var botCount = 4 - competitorCount % 4;
                if (botCount > 0 && botCount < 4)
                {
                    managerFightList.Sort(new CompareArenaManager());

                    var minScore = managerFightList[0].Score;
                    var maxScore = managerFightList[competitorCount - 1].Score;

                    var botList = LadderManagerMgr.GetBot(botCount, minScore, maxScore);
                    if (botList != null)
                    {
                        foreach (var list in botList)
                        {
                            list.Name  = _botName;
                            list.IsBot = true;
                            managerFightList.Add(list);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("LadderThread-BuildBot", ex.Message, ex.StackTrace);
            }
        }
Exemple #2
0
        public LadderRefreshExchangeResponse RefreshExchange(Guid managerId)
        {
            var entity = GetLadderManager(managerId);

            entity.RefreshTimes++;
            var mallDirect = new MallDirectFrame(managerId, EnumConsumeSourceType.RefreshLadderExchange,
                                                 entity.RefreshTimes);
            var checkCode = mallDirect.Check();

            if (checkCode != MessageCode.Success)
            {
                return(ResponseHelper.Create <LadderRefreshExchangeResponse>(checkCode));
            }
            var equipmentProperties = "";
            var equipmentItemcode   = "";

            entity.ExchangeIds         = CacheFactory.LadderCache.GetExchanges(out equipmentItemcode, out equipmentProperties);
            entity.ExchangedIds        = "";
            entity.EquipmentProperties = equipmentProperties;
            entity.EquipmentItems      = equipmentItemcode;
            using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
            {
                transactionManager.BeginTransaction();
                checkCode = mallDirect.Save(Guid.NewGuid().ToString(), transactionManager.TransactionObject);
                if (checkCode != MessageCode.Success)
                {
                    transactionManager.Rollback();
                    return(ResponseHelper.Create <LadderRefreshExchangeResponse>(checkCode));
                }
                if (!LadderManagerMgr.Update(entity, transactionManager.TransactionObject))
                {
                    transactionManager.Rollback();
                    return(ResponseHelper.Create <LadderRefreshExchangeResponse>(MessageCode.NbUpdateFail));
                }
                transactionManager.Commit();
            }
            var response = ResponseHelper.CreateSuccess <LadderRefreshExchangeResponse>();

            response.Data              = new LadderRefreshExchangeEntity();
            response.Data.ExchangeIds  = entity.ExchangeIds;
            response.Data.ManagerPoint = mallDirect.RemainPoint;
            response.Data.RefreshPoint =
                CacheFactory.MallCache.GetDirectPoint(EnumConsumeSourceType.RefreshLadderExchange,
                                                      entity.RefreshTimes + 1);
            response.Data.Honor = entity.Honor;
            if (DateTime.Now.Hour >= 21)
            {
                response.Data.ExchangeRefreshTick = ShareUtil.GetTimeTick(DateTime.Today.AddDays(1).AddHours(21));
            }
            else
            {
                response.Data.ExchangeRefreshTick = ShareUtil.GetTimeTick(DateTime.Today.AddHours(21));
            }

            response.Data.AllEquipmentProperties =
                CacheFactory.LadderCache.AnalysisProperties(entity.EquipmentProperties);
            response.Data.LadderCoin = entity.LadderCoin;
            return(response);
        }
Exemple #3
0
 MessageCode Tran_SaveExchange(DbTransaction transaction, LadderManagerEntity ladderManager, ItemPackageFrame package, LadderExchangerecordEntity ladderExchangerecord)
 {
     if (!LadderManagerMgr.Update(ladderManager, transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!package.Save(transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LadderExchangerecordMgr.Insert(ladderExchangerecord, transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     return(MessageCode.Success);
 }
Exemple #4
0
 public void GetLadderInfoTest()
 {
     try
     {
         var list = CrossladderManagerMgr.GetDailyHonor();
         if (list != null)
         {
             foreach (var entity in list)
             {
                 LadderManagerMgr.AddDailyHonor(entity.ManagerId, entity.NewlyHonor, entity.NewlyLadderCoin, null, entity.SiteId);
             }
         }
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("SendDailyHonor", ex);
     }
 }
Exemple #5
0
 protected void btnCrossLadderCoin_Click(object sender, EventArgs e)
 {
     try
     {
         ShowMessage("开始补发天梯币...");
         var list = CrossladderManagerMgr.GetDailyHonor();
         if (list != null)
         {
             foreach (var entity in list)
             {
                 LadderManagerMgr.AddDailyHonor(entity.ManagerId, entity.NewlyHonor, entity.NewlyLadderCoin, null,
                                                entity.SiteId);
             }
         }
         ShowMessage("补发成功...");
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("SendDailyHonor", ex);
     }
 }
Exemple #6
0
 public LadderManagerEntity InnerGetLadderManager(Guid managerId)
 {
     return(LadderManagerMgr.GetById(managerId, _ladderRegisterScore));
 }
Exemple #7
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));
        }
Exemple #8
0
        public LadderManagerResponse GetManagerInfo(Guid managerId)
        {
            var manager = GetLadderManager(managerId);

            if (string.IsNullOrEmpty(manager.ExchangeIds) || CheckExchangeRefresh(manager.RefreshDate))
            {
                var equipmentProperties = "";
                var equipmentItemcode   = "";
                manager.ExchangeIds         = CacheFactory.LadderCache.GetExchanges(out equipmentItemcode, out equipmentProperties);
                manager.RefreshDate         = DateTime.Today.AddHours(21);//每天21点刷新
                manager.RefreshTimes        = 0;
                manager.ExchangedIds        = "";
                manager.EquipmentProperties = equipmentProperties;
                manager.EquipmentItems      = equipmentItemcode;
                LadderManagerMgr.Update(manager);
            }
            var season = CacheFactory.SeasonCache.GetCurrentSeason();

            season.StartTick = ShareUtil.GetTimeTick(season.Startdate);
            season.EndTick   = ShareUtil.GetTimeTick(season.Enddate.Date.AddDays(1).AddSeconds(-1));
            season.NowTick   = ShareUtil.GetTimeTick(DateTime.Now);
            var response = ResponseHelper.CreateSuccess <LadderManagerResponse>();

            response.Data        = manager;
            response.Data.Season = season;
            if (DateTime.Now.Hour >= 21)
            {
                response.Data.ExchangeRefreshTick =
                    ShareUtil.GetTimeTick(DateTime.Today.AddDays(1).AddHours(21));
            }
            else
            {
                response.Data.ExchangeRefreshTick =
                    ShareUtil.GetTimeTick(DateTime.Today.AddHours(21));
            }
            var rankEntity = RankLadderThread.Instance.GetMyRank(managerId, (int)EnumRankType.LadderRank);

            if (rankEntity != null)
            {
                response.Data.MyRank        = rankEntity.Rank;
                response.Data.YesterdayRank = rankEntity.YesterdayRank;
            }
            else
            {
                response.Data.MyRank        = -1;
                response.Data.YesterdayRank = -1;
            }
            response.Data.WinRate      = ManagerUtil.GetWinRate(managerId, EnumMatchType.Ladder);
            response.Data.RefreshPoint =
                CacheFactory.MallCache.GetDirectPoint(EnumConsumeSourceType.RefreshLadderExchange, manager.RefreshTimes + 1);
            response.Data.AllEquipmentProperties =
                CacheFactory.LeagueCache.AnalysisProperties(manager.EquipmentProperties);
            if (LadderCore.Instance._ManagerMatchCD.ContainsKey(managerId))
            {
                response.Data.CDTick = ShareUtil.GetTimeTick(_ManagerMatchCD[managerId]);
            }
            else
            {
                response.Data.CDTick = ShareUtil.GetTimeTick(DateTime.Now);
            }
            return(response);
        }