Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            CountryCombat countryCombat = new CountryCombat(ContextUser);

            countryCombat.Exit();
            return(true);
        }
Ejemplo n.º 2
0
        public override bool TakeAction()
        {
            this.ErrorCode = ops;
            CountryCombat countryCombat = new CountryCombat(ContextUser);

            if (ops == 1)
            {
                this.ErrorInfo = string.Format(LanguageManager.GetLang().St5202_InspireTip, ExpNum);
            }
            else if (ops == 2)
            {
                if (ContextUser.ExpNum < ExpNum)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_ExpNumNotEnough;
                    return(false);
                }
                if (!countryCombat.Inspire(false, out inspirePercent))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_InspireFailed;
                }
                ContextUser.ExpNum = MathUtils.Subtraction(ContextUser.ExpNum, ExpNum, 0);
                //ContextUser.Update();
            }
            else if (ops == 3)
            {
                if (ContextUser.GoldNum < GlodNum)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                this.ErrorInfo = string.Format(LanguageManager.GetLang().St5202_InspireGoldTip, GlodNum);
            }
            else if (ops == 4)
            {
                if (ContextUser.VipLv < CountryCombat.CombatInspireVipLv)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                    return(false);
                }
                if (ContextUser.GoldNum < GlodNum)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                if (!countryCombat.Inspire(true, out inspirePercent))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_InspireFailed;
                }
                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, GlodNum, int.MaxValue);
                //ContextUser.Update();
            }
            return(true);
        }
Ejemplo n.º 3
0
        public override bool TakeAction()
        {
            CountryCombat countryCombat = new CountryCombat(ContextUser);

            _countryUserList = countryCombat.GetCountryUser(_countryID, _lv);
            _countryUserList = _countryUserList.GetPaging(_pageIndex, _pageSize, out _pageCount);
            return(true);
        }
Ejemplo n.º 4
0
        public override bool TakeAction()
        {
            if (ContextUser.CountryID == CountryType.None)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_NoJoinCountry;
                return(false);
            }
            CountryCombat countryCombat = new CountryCombat(ContextUser);

            if (countryCombat.GameActive == null ||
                countryCombat.GameActive.RefreshStatus() == CombatStatus.NoStart ||
                countryCombat.GameActive.RefreshStatus() == CombatStatus.Over)
            {
                if (ContextUser.UserStatus == UserStatus.CountryCombat)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_CombatNoStart;
                return(false);
            }
            //wuzf 检查战斗状态
            if (ContextUser.UserStatus != UserStatus.CountryCombat || UserHelper.IsUserEmbattle(ContextUser.UserID, ContextUser.UseMagicID))
            {
                countryCombat.Exit();
                //ErrorCode = LanguageManager.GetLang().ErrorCode;
                //ErrorInfo = LanguageManager.GetLang().St5201_NoJoinCountry;
                //return false;
            }

            if (ops == 1)
            {
                processList = countryCombat.GetCombatProcess(true);
            }
            else if (ops == 2)
            {
                processList = countryCombat.GetCombatProcess(false);
            }
            coldTime    = countryCombat.GameActive.ColdTime;
            countryUser = countryCombat.GetCountryUser();
            firstUser   = CountryCombat.FistCountryUser ?? new CountryUser();
            CountryGroup mogemaGroup;
            CountryGroup hashideGroup;

            if (CountryCombat.TryGroup(CountryType.M, out mogemaGroup) && CountryCombat.TryGroup(CountryType.H, out hashideGroup))
            {
                _mscoreNum = mogemaGroup.Score;
                _hscoreNum = hashideGroup.Score;
            }
            if (coldTime == 0)
            {
            }
            return(true);
        }
Ejemplo n.º 5
0
        public override bool TakeAction()
        {
            CountryCombat countryCombat = new CountryCombat(ContextUser);

            if (countryCombat.GameActive == null || countryCombat.GameActive.RefreshStatus() == CombatStatus.NoStart)
            {
                if (ContextUser.UserStatus == UserStatus.CountryCombat)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_CombatNoStart;
                return(false);
            }
            if (countryCombat.GameActive == null || countryCombat.GameActive.RefreshStatus() == CombatStatus.Over)
            {
                if (ContextUser.UserStatus == UserStatus.CountryCombat)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St5201_CombatOver;
                return(false);
            }
            if (UserHelper.IsUserEmbattle(ContextUser.UserID, ContextUser.UseMagicID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty;
                return(false);
            }
            countryCombat.JoinCombat();

            return(true);
        }
Ejemplo n.º 6
0
        public override bool TakeAction()
        {
            if (ContextUser.UserStatus == UserStatus.CountryCombat)
            {
                CountryCombat countryCombat = new CountryCombat(ContextUser);
                if (countryCombat.GameActive != null && countryCombat.GameActive.RefreshStatus() == CombatStatus.Combat)
                {
                    countryCombat.Exit();
                }
            }

            if (ContextUser.EnergyNum <= 0 && ContextUser.SurplusEnergy <= 0)
            {
                ErrorCode = 3;
                ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            //if (_ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID))
            //{
            //    ErrorCode = 1;
            //    ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood;
            //    return false;
            //}
            //if (_ops != 1 && UserItemHelper.CheckItemOut(ContextUser, ItemStatus.BeiBao))
            //{
            //    ErrorCode = 1;
            //    ErrorInfo = LanguageManager.GetLang().St_User_BeiBaoMsg;
            //    return false;
            //}

            UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血

            plotInfo = new ShareCacheStruct <PlotInfo>().FindKey(plotID);

            if (plotInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().LoadDataError;
                return(false);
            }
            int challengeNum = PlotHelper.GetPlotChallengeNum(UserId.ToString(), plotInfo.PlotID);

            if (plotInfo.PlotType == PlotType.Elite && challengeNum >= plotInfo.ChallengeNum)
            {
                ErrorCode = 4;
                ErrorInfo = LanguageManager.GetLang().St4002_IsPlotEliteNotChallengeNum;
                return(false);
            }

            if ((challengeNum >= plotInfo.ChallengeNum && ContextUser.VipLv < 3))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4002_NotChallengeNum;
                return(false);
            }

            int num = challengeNum;
            int challengeDefSoldNum    = ConfigEnvSet.GetInt("UserPlot.ChallengeDefSoldNum");
            int challengeDoubleSoldNum = ConfigEnvSet.GetInt("UserPlot.ChallengeDoubleSoldNum");

            if (_ops != 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID))
            {
                ErrorCode = 1;
                _plotNum  = challengeDefSoldNum;
                return(false);
            }
            else
            {
                if (_ops != 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID) == false)
                {
                    int openNum = num - plotInfo.ChallengeNum + 1;
                    _plotNum = challengeDoubleSoldNum * openNum + challengeDefSoldNum;
                }
            }

            if (_ops != 1 && num >= plotInfo.ChallengeNum)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4002_IsPlotNum, _plotNum);
                return(false);
            }
            if (_ops == 1 && num >= plotInfo.ChallengeNum)
            {
                if (ContextUser.GoldNum < _plotNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                ContextUser.UseGold = MathUtils.Subtraction(ContextUser.UseGold, _plotNum);
            }
            if (_ops == 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID) == false)
            {
                int openNum = num - plotInfo.ChallengeNum + 1;
                _plotNum = challengeDoubleSoldNum * openNum + challengeDefSoldNum;;
                if (ContextUser.GoldNum < _plotNum)
                {
                    ErrorCode = 2;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, _plotNum);
            }
            if (_ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull;
                return(false);
            }
            //var cacheSetUserPlot = new PersonalCacheStruct<UserPlotPackage>();
            //var userPlotPack = cacheSetUserPlot.FindKey(ContextUser.UserID);
            //var userPlot = userPlotPack != null ? userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null;
            var userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotID);

            if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum)
            {
                if (plotInfo.PlotType == PlotType.Elite)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed;
                    return(false);
                }
                else if (plotInfo.PlotType == PlotType.HeroPlot)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum;
                    return(false);
                }
            }
            npcList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            //if (ContextUser.EnergyNum < (npcList.Count * PlotInfo.BattleEnergyNum))
            //{
            //    ErrorCode = 3;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            ContextUser.InPlotDate = DateTime.Now;
            //if (ContextUser.UserExtend == null || ContextUser.UserExtend.PlotStatusID == 0 || ContextUser.UserExtend.MercenarySeq == 0)
            //{
            //    ContextUser.TempEnergyNum = PlotInfo.BattleEnergyNum;
            //    //ContextUser.RemoveEnergyNum(PlotInfo.BattleEnergyNum);
            //}
            //ContextUser.Update();
            if (ContextUser.UserExtend != null && ContextUser.UserExtend.PlotStatusID <= 0)
            {
                ContextUser.UserExtend.UpdateNotify(obj =>
                {
                    ContextUser.UserExtend.PlotStatusID = plotID;
                    ContextUser.UserExtend.PlotNpcID    = -1;
                    ContextUser.UserExtend.MercenarySeq = 1;
                    ContextUser.UserExtend.IsBoss       = false;
                    return(true);
                });
            }

            _isOverCombat             = userPlot != null && userPlot.PlotStatus == PlotStatus.Completed;
            ContextUser.TempEnergyNum = PlotInfo.BattleEnergyNum;
            return(true);
        }
Ejemplo n.º 7
0
        //private static void LoadServerCombatUser()
        //{
        //    try
        //    {
        //        new BaseLog().SaveLog("系统跨服战用户加载开始...");
        //        Stopwatch stopwatch = new Stopwatch();
        //        stopwatch.Start();
        //        int periodTime = GameEnvironment.CacheGlobalPeriod;
        //        int capacity = int.MaxValue;
        //        int FastID = ServerCombatHelper.GetFastID();
        //        DbDataFilter filter = new DbDataFilter(capacity);
        //        filter.Condition = "FastID = @FastID";
        //        filter.Parameters.Add("@FastID", FastID);
        //        var cacheSet = new ShareCacheStruct<UserServerCombatApply>();
        //        cacheSet.AutoLoad(filter, periodTime, false);
        //        List<UserServerCombatApply> applyList = cacheSet.FindAll();
        //        new BaseLog().SaveLog(string.Format("系统跨服战加载用户数{0}", applyList.Count));
        //        foreach (var item in applyList)
        //        {
        //            UserCacheGlobal.LoadOffline(item.UserID);
        //        }
        //        stopwatch.Stop();
        //        new BaseLog().SaveLog(string.Format("系统跨服战用户加载时间:{0}ms", stopwatch.Elapsed.TotalMilliseconds));

        //    }
        //    catch (Exception ex)
        //    {
        //        new BaseLog().SaveLog("跨服战服务器出错", ex);
        //    }
        //}

        public static void Stop()
        {
            CountryCombat.Stop();
            GameActiveCenter.Stop();
            GuildGameActiveCenter.Stop();
        }