Beispiel #1
0
        public override bool TakeAction()
        {
            UserStatus status = ContextUser.UserStatus;

            if (status == UserStatus.FengJin)
            {
                return(false);
            }
            UserGeneral        general = UserGeneral.GetMainGeneral(ContextUser.UserID);
            Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
            UserRank           rankInfo;

            if (ranking.TryGetRankNo(m => m.UserID == ContextUser.UserID, out rankID))
            {
                rankInfo = ranking.Find(s => s.UserID == ContextUser.UserID);
                //ContextUser.RankID = rankID;
            }
            else
            {
                rankInfo = new UserRank()
                {
                    UserID         = ContextUser.UserID,
                    HeadID         = general.HeadID,
                    GameCoin       = ContextUser.GameCoin,
                    NickName       = ContextUser.NickName,
                    ObtainNum      = ContextUser.ObtainNum,
                    UserLv         = ContextUser.UserLv,
                    RankId         = int.MaxValue,
                    RankDate       = DateTime.Now,
                    SportsIntegral = 0
                };
                ranking.TryAppend(rankInfo);
            }

            sportsName = UserHelper.SportTitleName(ContextUser.ObtainNum);

            sportNum       = GetChallGeNum(ContextUser.UserID);
            sportsIntegral = ContextUser.SportsIntegral.ToInt();
            sportsReward   = new ShareCacheStruct <SportsRewardInfo>().FindKey(rankInfo.RankId);
            receiveDate    = (int)(RankingHelper.GetNextReceiveDate() - DateTime.Now).TotalSeconds;

            CombatRanking combatrank = (CombatRanking)ranking;

            _userRankArray = combatrank.GetRanking(ContextUser);
            _userRankArray.Add(rankInfo);
            _userRankArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(x.RankId.CompareTo(y.RankId));
            });

            _userCombatArray = ContextUser.GetSportsCombat();
            _userCombatArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(y.CombatDate.CompareTo(x.CombatDate));
            });

            if (rankInfo != null && rankID > 0)
            {
                victoryNum = rankInfo.VictoryNum;
            }

            //NoviceHelper.SportVictoryNum(ContextUser, 2001, victoryNum); //竞技场奖励
            if (victoryNum >= 7)
            {
                ActivitiesAward.HolidayFestival(ContextUser.UserID);
            }
            rankID = ContextUser.RankID;



            int count     = 10;
            int pagecount = 0;

            userRankArray = ranking.GetRange(1, count, out pagecount);
            return(true);
        }
Beispiel #2
0
        public override bool TakeAction()
        {
            int sportsIndex;

            if (int.TryParse(userSportsID, out sportsIndex))
            {
                var tempList = ContextUser.GetSportsCombat();
                if (tempList.Count > 0 && sportsIndex < tempList.Count)
                {
                    sportsIndex        = MathUtils.Addition(sportsIndex, 1);
                    _uSportsCombat     = tempList[tempList.Count - sportsIndex] ?? new SportsCombat();
                    _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer();

                    _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0);

                    if (_combatProcessList.DefenseList.Count > 0)
                    {
                        _npcTalPriority = CombatHelper.TotalPriorityNum(_combatProcessList.DefenseList[0].UserID, 0);
                    }
                }
            }
            else if (!string.IsNullOrEmpty(toUserID))
            {
                UserHelper.ChechDailyRestrain(ContextUser.UserID);
                if (ContextUser.UserID == toUserID)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                if (GetChallGeNum(ContextUser.UserID) <= 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St5107_ChallGeNumFull;
                    return(false);
                }

                toGameUser = UserCacheGlobal.LoadOffline(toUserID);
                if (ContextUser.UseMagicID == 0 || toGameUser == null || toGameUser.UseMagicID == 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic;
                    return(false);
                }
                RankingHelper.SportSRewardGain(toUserID, toGameUser.RankID);   //被挑战者的竞技排名
                //todo 竞技场冷却时间清除
                //var userQueueCache = new GameDataCacheSet<UserQueue>();
                //var queueArray = userQueueCache.FindAll(Uid, m => m.QueueType == QueueType.JingJiTiaoZhan);
                //if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0)
                //{
                //    ErrorCode = LanguageManager.GetLang().ErrorCode;
                //    ErrorInfo = LanguageManager.GetLang().St5107_Colding;
                //    return false;
                //}
                //if (queueArray.Count > 0)
                //{
                //    var userQueue = queueArray[0];
                //    userQueue.ColdTime = codeTime;
                //    userQueue.TotalColdTime = codeTime;
                //    userQueue.Timing = DateTime.Now;
                //}
                //else
                //{
                //    UserQueue queue = new UserQueue()
                //    {
                //        QueueID = Guid.NewGuid().ToString(),
                //        QueueType = QueueType.JingJiTiaoZhan,
                //        QueueName = QueueType.JingJiTiaoZhan.ToString(),
                //        UserID = ContextUser.UserID,
                //        ColdTime = codeTime,
                //        IsSuspend = false,
                //        TotalColdTime = codeTime,
                //        Timing = DateTime.Now
                //    };
                //    userQueueCache.Add(queue);
                //    //queue.Append();
                //}
                //次数限制修改
                int sportNum = 0;
                UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);
                if (dailyRestrain != null)
                {
                    sportNum = MathUtils.Addition(dailyRestrain.Funtion9, 1, int.MaxValue);
                    dailyRestrain.Funtion9 = sportNum;
                    //dailyRestrain.Update();
                }
                else
                {
                    sportNum = 1;
                }
                TriggerSportCombat(ContextUser, toGameUser, sportNum, ref sportsPrizeStr, userMail);

                var tempList = ContextUser.GetSportsCombat();
                if (tempList.Count > 0)
                {
                    _uSportsCombat     = tempList[tempList.Count - 1] ?? new SportsCombat();
                    _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer();
                }
                //日常任务-竞技
                TaskHelper.TriggerDailyTask(Uid, 4006);
                _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0);
                _npcTalPriority  = CombatHelper.TotalPriorityNum(toUserID, 0);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }

            userMail.GameCoin = _uSportsCombat.RewardGoin;
            userMail.Obtion   = _uSportsCombat.RewardObtian;
            var tjxMailService = new TjxMailService(toGameUser);

            tjxMailService.Send(userMail);

            _selfAbilityEffectList    = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0);
            _defSelfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(toUserID, 1);
            _selfAbilityEffectList.AddRange(_defSelfAbilityEffectList);
            return(true);
        }