Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            short currMaxLv = ConfigEnvSet.GetInt("User.CurrMaxLv").ToShort();
            //NoviceHelper.CheckFestival(ContextUser);

            NoviceHelper.GetFunctionEnum(Uid); //默认开启金币,精力大作战功能
            if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                UserHelper.ChecheDailyContribution(ContextUser.MercenariesID, ContextUser.UserID);
            }
            PaymentService.Trigger(ContextUser);
            if (ContextUser.UserLv > currMaxLv)
            {
                genlv = currMaxLv;
            }
            else
            {
                genlv = ContextUser.UserLv;
            }
            var cacheSetGeneralEscalate = new ConfigCacheSet<GeneralEscalateInfo>();
            GeneralEscalateHelper.AddUserLv(ContextUser, 0);
            _honourNum = ContextUser.HonourNum;
            int lv = ContextUser.UserLv;
            lv = lv < 0 ? 1 : lv + 1;
            var generalEscalate =
                cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv);
            if (generalEscalate != null)
            {
                _nextHonourNum = generalEscalate.UpExperience;
            }
            guildID = ContextUser.MercenariesID;
            var userGeneralList = new GameDataCacheSet<UserGeneral>().FindAll(ContextUser.UserID);
            if (userGeneralList.Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }

            userGeneralInfo = userGeneralList[0]; //UserGeneral.GetMainGeneral(ContextUser.UserID);
            if (userGeneralInfo != null)
            {
                //wuzf 去掉刷新血量,其它改变血量接口有触发刷新
                //userGeneralInfo.RefreshMaxLife();
                generalID = userGeneralInfo.GeneralID;
                //careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(userGeneralInfo.CareerID);
                headID = userGeneralInfo.HeadID; //ContextUser.Sex ? careerInfo.HeadID2 : careerInfo.HeadID;
                escalateInfo = new ConfigCacheSet<GeneralEscalateInfo>().FindKey(genlv);
                lifeNum = userGeneralInfo.LifeNum;
                careerID = userGeneralInfo.CareerID;
            }
            lifeMaxNum = UserHelper.GetMaxLife(ContextUser.UserID, generalID);
            maxEnergyNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum");
            sex = ContextUser.Sex ? 1 : 0;

            //道具图标
            _blessingList = UserHelper.BlessingInfoList(ContextUser);
            //变身卡图标
            List<UserProps> userPropsList = new GameDataCacheSet<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 3 && u.ItemID != 5200 && u.ItemID != 7003);
            if (userPropsList.Count > 0)
            {
                UserProps props = userPropsList[0];
                int pTime = props.DoRefresh();
                ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(props.ItemID);
                if (itemInfo != null && pTime > pictureTime)
                {
                    pictureID = itemInfo.PictrueID;
                    pictureTime = pTime;
                }
            }
            //兼容客户端上已版本血量图标
            List<UserProps> userPropsList2 = new GameDataCacheSet<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1);
            if (userPropsList2.Count > 0)
            {
                UserProps props = userPropsList2[0];
                int pTime = props.DoRefresh();
                ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(props.ItemID);
                if (itemInfo != null && pTime > pictureTime)
                {
                    _itemLiveNum = props.SurplusNum;
                    _itemLiveMaxNum = itemInfo.EffectNum;
                }
            }


            //加量,领土战不能加血wuzf)
            if (ContextUser.UserStatus != UserStatus.CountryCombat)
            {
                UserHelper.GetGeneralLife(ContextUser.UserID);
            }
          


            //精力恢复
            List<UserQueue> energyQueueArray = new GameDataCacheSet<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EnergyHuiFu);
            if (energyQueueArray.Count > 0)
            {
                UserQueue energyQueue = energyQueueArray[0];
                short energyMaxNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum");
                int restorationDate = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationDate"); //半小时
                int restorationNum = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationNum"); //恢复5点

                if (energyQueue.Timing > DateTime.Now)
                {
                    energyQueue.Timing = DateTime.Now;
                }
                //原因:玩家满精力时,精力恢复累加
                int timeCount = (int)(DateTime.Now - energyQueue.Timing).TotalSeconds / restorationDate;
                if (timeCount > 0)
                {
                    short energyNum = (short)(timeCount * restorationNum);
                    if (ContextUser.EnergyNum < energyMaxNum)
                    {
                        ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, energyNum, energyMaxNum);
                    }
                    energyQueue.Timing = DateTime.Now;
                }
                else
                {
                    if (energyMaxNum > ContextUser.EnergyNum)
                    {
                        rstore = (int)(energyQueue.Timing.AddSeconds(restorationDate) - DateTime.Now).TotalSeconds;
                        totalRstore =
                            (energyQueue.Timing.AddSeconds((energyMaxNum - ContextUser.EnergyNum) * restorationDate) -
                             DateTime.Now).TotalSeconds.ToInt();
                    }
                }

            }
            else
            {
                UserQueue queue = new UserQueue()
                {
                    QueueID = Guid.NewGuid().ToString(),
                    UserID = ContextUser.UserID,
                    QueueType = QueueType.EnergyHuiFu,
                    QueueName = QueueType.EnergyHuiFu.ToString(),
                    Timing = DateTime.Now,
                    ColdTime = 0,
                    TotalColdTime = 0,
                    IsSuspend = false,
                    StrengNum = 0
                };
                new GameDataCacheSet<UserQueue>().Add(queue);
            }


            VipLvInfo lvInfo = new ConfigCacheSet<VipLvInfo>().FindKey(MathUtils.Addition(ContextUser.VipLv, 1, int.MaxValue));
            if (lvInfo != null)
            {
                demandGold = MathUtils.Subtraction(lvInfo.PayGold, ContextUser.PayGold, 0);
                demandGold = MathUtils.Subtraction(demandGold, ContextUser.ExtGold, 0);
            }
            UserHelper.GetGameUserCombat(ContextUser.UserID);

            if ((int)(DateTime.Now - ContextUser.DailyLoginTime).TotalSeconds <= 5 && ContextUser.UserLv > 10)
            {
                isHelper = 1;
            }
            FestivalHelper.DoFestival(ContextUser);
            if (ContextUser.UserExtend != null)
            {
                if ((plotstatucID > 0 || ContextUser.TempEnergyNum == 0) && !ContextUser.UserExtend.IsBoss)
                {
                    ContextUser.TempEnergyNum = 1;
                }

                if ((plotstatucID == 0 && ContextUser.TempEnergyNum == 0) || ContextUser.UserExtend.IsBoss)
                {
                    ContextUser.UserExtend.UpdateNotify(obj =>
                    {
                        ContextUser.UserExtend.PlotStatusID = 0;
                        ContextUser.UserExtend.PlotNpcID = -1;
                        ContextUser.UserExtend.MercenarySeq = 0;
                        ContextUser.UserExtend.IsBoss = false;
                        return true;
                    });
                }

                plotstatucID = ContextUser.UserExtend.PlotStatusID;
                mercenarySeq = ContextUser.UserExtend.MercenarySeq;
                cardUserID = ContextUser.UserExtend.CardUserID;
            }

            //公会晨练结束,退出公会晨练
            int activeID = 11;
            GameActive active = new ShareCacheStruct<GameActive>().FindKey(activeID);
            if (active != null)
            {
                DateTime stratTime = active.BeginTime;
                DateTime endTime = active.BeginTime.AddMinutes(active.Minutes);
                if (ContextUser.UserLocation == Location.GuildExercise && (DateTime.Now < stratTime || DateTime.Now > endTime))
                {
                    ContextUser.UserLocation = Location.Guid;
                }
            }
            DateTime nextDate;
            FightStage stage = GuildFightCombat.GetStage(out nextDate);
            //公会战结束后
            if (stage == FightStage.Apply && ContextUser.UserStatus == UserStatus.FightCombat)
            {
                ContextUser.UserStatus = UserStatus.Normal;
            }
            battleNum = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true).Count;
            totalBattle = EmbattleHelper.CurrEmbattle(ContextUser.UserID, false).Count;
            var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true);
            foreach (var userEmbattle in userEmbattleList)
            {
                _talPriority = MathUtils.Addition(_talPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID));
            }
            functionList = new GameDataCacheSet<UserFunction>().FindAll(ContextUser.UserID);

            // 精灵祝福
            if (ContextUser != null)
            {
                if (MathUtils.SqlMinDate == ContextUser.WizardDate)  // 玩家第一次进入
                {
                    ContextUser.WizardDate = DateTime.Now;
                    ContextUser.WizardNum = 1;
                }
                else
                {

                    double diffHours = (DateTime.Now - ContextUser.WizardDate).TotalHours;
                    if (diffHours >= 1)
                    {
                        ContextUser.WizardNum = MathUtils.Addition(ContextUser.WizardNum, Convert.ToInt32(diffHours), 3);
                        ContextUser.WizardDate = DateTime.Now;
                    }
                }
            }

            // 未读信件的数量
            TjxMailService tjxMailService = new TjxMailService(ContextUser);
            tjxMailService.GetMail(out unReadCount);
            return true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 佣兵升级
        /// </summary>
        /// <param name="userGeneral"></param>
        public static void GeneralUp(UserGeneral userGeneral)
        {

            var cacheSetGeneralEscalate = new ShareCacheStruct<GeneralEscalateInfo>();
            var GeneralEscalateList = cacheSetGeneralEscalate.FindAll(s => s.GeneralType == GeneralType.YongBing && s.UpExperience <= userGeneral.CurrExperience);
            short generalLv = userGeneral.GeneralLv;
            GeneralEscalateInfo generalEscalateInfo = new GeneralEscalateInfo();
            GeneralEscalateList.ForEach(item =>
            {
                if (item.GeneralLv > generalLv)
                {
                    generalLv = item.GeneralLv;
                    generalEscalateInfo = item;
                }
            });
            if (generalLv > userGeneral.GeneralLv)
            {
                userGeneral.GeneralLv = generalLv;

                userGeneral.CurrExperience = MathUtils.Subtraction(userGeneral.CurrExperience, generalEscalateInfo.UpExperience);

            }
        }