Example #1
0
 protected override void DoExecute(object obj)
 {
     try
     {
         DateTime   nextDate;
         FightStage stage = GuildFightCombat.GetStage(out nextDate);
         GuildFightCombat.GetCombatPrize();
         GuildFightCombat.ChangStage(stage);
         if (stage == FightStage.quarter_final || stage == FightStage.semi_final || stage == FightStage.final)
         {
             GuildFightCombat.ServerFinal(stage);
             new BaseLog().SaveLog("公会争斗战正在运行!");
         }
         GuildFightCombat.RemoveGuildFight();
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("GuildFightCombatTaskError-->{0}", ex);
     }
 }
Example #2
0
 public override bool TakeAction()
 {
     status = ContextUser.UserStatus;
     if (!string.IsNullOrEmpty(sportID))
     {
         MemberGroup memberGroup = new ShareCacheStruct <MemberGroup>().FindKey(sportID);
         if (memberGroup != null && !memberGroup.IsRemove)
         {
             isWin = memberGroup.Win ? (short)1 : (short)0;
             processList.Add(memberGroup.CombatProcess);
         }
     }
     else
     {
         DateTime   nextDate;
         FightStage stage = GuildFightCombat.GetStage(out nextDate);
         if (stage == FightStage.quarter_final || stage == FightStage.semi_final || stage == FightStage.final)
         {
             processList = GuildFightCombat.GetCombatProcess(ContextUser.UserID, stage);
         }
     }
     return(true);
 }
Example #3
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, GameEnvironment.CacheUserPeriod);
            }


            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);
        }
Example #4
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough;
                return(false);
            }
            string   guildFight = string.Empty;
            DateTime nextDate;

            stage = GuildFightCombat.GetStage(out nextDate);
            if (stage != FightStage.Apply)
            {
                codeTime = (int)(nextDate - DateTime.Now).TotalSeconds;
            }

            ServerFight fight = new ShareCacheStruct <ServerFight>().FindKey(fightCombat.FastID, ContextUser.MercenariesID);

            if (fight != null)
            {
                CityInfo cityInfo = new ConfigCacheSet <CityInfo>().FindKey(fight.CityID);
                if (cityInfo != null)
                {
                    cityName = cityInfo.CityName;
                }
                FightStage fightStage;
                if (stage <= FightStage.quarter_final)
                {
                    fightStage = FightStage.quarter_final;
                }
                else if (stage > FightStage.quarter_final && stage < FightStage.final_Wait)
                {
                    fightStage = FightStage.semi_final;
                }
                else
                {
                    fightStage = FightStage.final;
                }
                var fightGroupList = new ShareCacheStruct <ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage == fightStage);
                if (fightGroupList.Count == 0)
                {
                    fightGroupList = new ShareCacheStruct <ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage < fightStage);
                    if (fightGroupList.Count == 0)
                    {
                        fightGroupList = new ShareCacheStruct <ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage >= fightStage);
                    }
                }
                foreach (var fightGroup in fightGroupList)
                {
                    if (!string.IsNullOrEmpty(fightGroup.WinGuildID) && fightGroup.WinGuildID == ContextUser.MercenariesID)
                    {
                        guildFight = fightGroup.WinGuildID;
                        continue;
                    }
                    if (fightGroup.GuildIDA == ContextUser.MercenariesID || fightGroup.GuildIDB == ContextUser.MercenariesID)
                    {
                        guildFight = fightGroup.GuildIDA + "," + fightGroup.GuildIDB;
                    }
                }
                if (!string.IsNullOrEmpty(guildFight))
                {
                    guildStr = guildFight.Split(',');
                }
                TraceLog.ReleaseWriteFatal("6409公会争斗战配对城市{0} 阶段:{1},公会:{2}。", fight.CityID, stage, guildFight.ToNotNullString());
            }
            var totalfatigue = ContextUser.Fatigue * GameConfigSet.Fatigue;
            int tfatigue     = (int)(totalfatigue * 100);

            fatigue = string.Format(LanguageManager.GetLang().St6409_fatigueDesc, ContextUser.Fatigue, tfatigue);
            if (guildStr.Length == 0)
            {
                guildFight = ContextUser.MercenariesID + ",";
                guildStr   = guildFight.Split(',');
            }
            return(true);
        }
Example #5
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough;
                return(false);
            }
            GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);

            if (member == null || member.PostType == PostType.Member)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_OrdinaryMemberNotCompetence;
                return(false);
            }
            UserGuild guild = new ShareCacheStruct <UserGuild>().FindKey(ContextUser.MercenariesID);

            if (guild == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }

            FightCombat fightCombat = new FightCombat();
            var         cacheSet    = new ShareCacheStruct <ServerFight>();
            ServerFight fight       = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID);

            if (fight != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_HaveSignedUp;
                return(false);
            }

            DateTime   nextDate;
            FightStage stage = GuildFightCombat.GetStage(out nextDate);

            if (GuildFightCombat.IsFightDate())
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime;
                return(false);
            }

            if (stage != FightStage.Apply)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime;
                return(false);
            }

            //if (DateTime.Now > fightCombat.GuildEndTime && DateTime.Now < fightCombat.GuildStartTime)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St6404_OutRegistrationTime;
            //    return false;
            //}

            GuildFightInfo fightInfo = new ShareCacheStruct <GuildFightInfo>().FindKey(cityID);

            if (fightInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (guild.GuildLv < fightInfo.GuildLv)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_GuildLvNotEnough;
                return(false);
            }
            if (guild.CurrDonateNum < fightInfo.SkillNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CurrDonateNumNotEnough;
                return(false);
            }
            guild.CurrDonateNum = MathUtils.Subtraction(guild.CurrDonateNum, fightInfo.SkillNum);

            fight             = new ServerFight(fightCombat.FastID, ContextUser.MercenariesID);
            fight.GuildBanner = string.Empty;
            fight.CityID      = cityID;
            fight.RankID      = 0;
            fight.ApplyDate   = DateTime.Now;
            fight.IsRemove    = false;
            fight.IsBanner    = false;
            cacheSet.Add(fight);
            ErrorCode = 0;
            ErrorInfo = LanguageManager.GetLang().St6401_SuccessfulRegistration;
            return(true);
        }