예제 #1
0
        public override bool TakeAction()
        {
            PlantType        pType            = (PlantType)Enum.Parse(typeof(PlantType), plantType.ToString());
            UserPlantQuality userPlantQuality = new GameDataCacheSet <UserPlantQuality>().FindKey(ContextUser.UserID, generalID, pType);

            if (userPlantQuality != null)
            {
                plantQualityType = (short)userPlantQuality.PlantQuality;
            }
            else
            {
                UserPlantQuality plant = new UserPlantQuality()
                {
                    UserID       = ContextUser.UserID,
                    GeneralID    = generalID,
                    PlantQuality = PlantQualityType.PuTong,
                    PlantType    = pType,
                    RefreshNum   = 0,
                    RefreshDate  = DateTime.Now,
                };
                new GameDataCacheSet <UserPlantQuality>().Add(plant);
                plantQualityType = 1;
            }
            PlantQualityType qualityType = (PlantQualityType)Enum.Parse(typeof(PlantQualityType), plantQualityType.ToString());
            short            generalLv   = 0;

            userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID);
            if (userGeneral == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (pType == PlantType.Experience)
            {
                generalLv = ContextUser.UserLv;
            }
            else if (pType == PlantType.GameGoin)
            {
                generalLv = userGeneral.GeneralLv;
            }
            plantInfo = new ConfigCacheSet <PlantInfo>().FindKey(generalLv, plantType, qualityType);
            double addNum = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.ManorAddition);//活动加成

            rewardNum = plantInfo.GainNum;
            UserLand land = new GameDataCacheSet <UserLand>().FindKey(ContextUser.UserID, landPostion);

            if (land != null && land.IsRedLand == 1)
            {
                rewardNum = MathUtils.Addition(rewardNum, (int)(rewardNum * 0.2), int.MaxValue);
            }
            if (land != null && land.IsBlackLand == 1)
            {
                rewardNum = MathUtils.Addition(rewardNum, (int)(rewardNum * 0.4), int.MaxValue);
            }
            rewardNum = (rewardNum * addNum).ToInt();
            return(true);
        }
예제 #2
0
        public override bool TakeAction()
        {
            int energyNum = ConfigEnvSet.GetInt("User.EnergyNum");

            UserHelper.ChechDailyRestrain(ContextUser.UserID);
            var               cacheSet     = new PersonalCacheStruct <UserDailyRestrain>();
            double            addNum       = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.PurchasedEnergy);//活动加成
            int               payNum       = FestivalHelper.SurplusEnergyNum(ContextUser.UserID);
            UserDailyRestrain userRestrain = cacheSet.FindKey(ContextUser.UserID);

            if (payNum == 0)
            {
                if (userRestrain != null && DateTime.Now.Date != userRestrain.RefreshDate.Date)
                {
                    userRestrain.Funtion4 = 0;
                }

                if (userRestrain != null && userRestrain.Funtion4 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.GouMaiJingLi) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St1010_JingliFull;
                    return(false);
                }
            }

            int useGold = (GetPayEnergyGold(ContextUser.UserID, ContextUser.VipLv, payType) * addNum).ToInt();

            if (payType == 1)
            {
                if (ops == 1)
                {
                    this.ErrorCode = 1;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, energyNum);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum < useGold)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }

                    ContextUser.UseGold   = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
                    ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType), short.MaxValue);
                    if (payNum == 0)
                    {
                        if (userRestrain != null)
                        {
                            userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue);
                        }
                        else
                        {
                            userRestrain             = new UserDailyRestrain();
                            userRestrain.UserID      = ContextUser.UserID;
                            userRestrain.RefreshDate = DateTime.Now;
                            userRestrain.Funtion4    = 1;
                            cacheSet.Add(userRestrain);
                        }
                    }

                    UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, 0, userRestrain.Funtion4, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue));
                    FestivalHelper.PurchasedEnergy(ContextUser.UserID);
                }
            }
            else if (payType == 2)
            {
                short payEnergy = GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType);
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ZiDongGouMaiJingLi))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                if (ops == 1)
                {
                    this.ErrorCode = 1;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, payEnergy);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum < useGold)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }

                    ContextUser.UseGold   = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
                    ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, payEnergy, short.MaxValue);

                    if (userRestrain != null)
                    {
                        userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue);
                    }
                    else
                    {
                        userRestrain             = new UserDailyRestrain();
                        userRestrain.UserID      = ContextUser.UserID;
                        userRestrain.RefreshDate = DateTime.Now;
                        userRestrain.Funtion4    = 1;
                        cacheSet.Add(userRestrain);
                    }

                    UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, userRestrain.Funtion4, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue));
                }
            }
            return(true);
        }
예제 #3
0
        public override bool TakeAction()
        {
            short     optype       = 0;
            short     plantQuality = 0;
            PlantType pType        = (PlantType)Enum.Parse(typeof(PlantType), plantType.ToString());

            if (pType == PlantType.Experience)
            {
                optype = 6;
            }
            else
            {
                optype = 7;
            }
            short       generalLv   = 0;
            UserGeneral userGeneral = new PersonalCacheStruct <UserGeneral>().FindKey(ContextUser.UserID, generalID);

            if (userGeneral == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().LoadDataError;
                return(false);
            }
            generalLv = userGeneral.GeneralLv;

            if (pType == PlantType.Experience)
            {
                generalLv = ContextUser.UserLv;
            }
            else if (pType == PlantType.GameGoin)
            {
                generalLv = userGeneral.GeneralLv;
            }
            int      upexpNum = 0;
            int      expeNum  = 0;
            double   addNum   = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.ManorAddition);//活动加成
            UserLand userLand = new PersonalCacheStruct <UserLand>().FindKey(ContextUser.UserID, landPositon);

            if (userLand != null)
            {
                if (userLand.IsGain == 2 || userLand.GeneralID == 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }
                plantQuality = (short)userLand.PlantQuality;
                PlantInfo plantInfo = new ShareCacheStruct <PlantInfo>().FindKey(generalLv, plantType, userLand.PlantQuality);
                if (plantInfo != null)
                {
                    if (userLand.IsGain == 1)
                    {
                        userLand.GeneralID    = 0;
                        userLand.PlantType    = PlantType.Experience;
                        userLand.IsGain       = 2;
                        userLand.GainDate     = DateTime.Now;
                        userLand.PlantQuality = PlantQualityType.PuTong;
                    }
                    else
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        return(false);
                    }
                    gainNum = plantInfo.GainNum;
                    UserLand land = new PersonalCacheStruct <UserLand>().FindKey(ContextUser.UserID, landPositon);
                    if (land != null && land.IsRedLand == 1)
                    {
                        gainNum = MathUtils.Addition(gainNum, (int)(gainNum * 0.2), int.MaxValue);
                    }
                    if (land != null && land.IsBlackLand == 1)
                    {
                        gainNum = MathUtils.Addition(gainNum, (int)(gainNum * 0.4), int.MaxValue);
                    }
                    gainNum = (gainNum * addNum).ToInt();
                    if (pType == PlantType.Experience)
                    {
                        expeNum = MathUtils.Addition(userGeneral.CurrExperience, gainNum, int.MaxValue);

                        GeneralEscalateInfo generalEscalate = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(userGeneral.GeneralLv);
                        if (generalEscalate != null)
                        {
                            upexpNum = generalEscalate.UpExperience;
                        }

                        if (gainNum > 0)
                        {
                            userGeneral.Experience2 = MathUtils.Addition(userGeneral.Experience2, gainNum, int.MaxValue);
                            //userGeneral.CurrExperience = MathUtils.Addition(userGeneral.CurrExperience, gainNum, int.MaxValue);
                            UserHelper.TriggerGeneral(userGeneral, gainNum);
                        }
                    }
                    else if (pType == PlantType.GameGoin)
                    {
                        if (gainNum > 0)
                        {
                            ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, gainNum, int.MaxValue);
                        }
                    }
                }
                UserLogHelper.AppenLandLog(ContextUser.UserID, optype, generalID, landPositon, 0, plantQuality, gainNum, 0);
            }

            if (pType == PlantType.Experience && expeNum >= upexpNum)
            {
                var    chatService = new TjxChatService();
                string content     = string.Format(LanguageManager.GetLang().St10006_UserGeneralUpLv,
                                                   userGeneral.GeneralName,
                                                   userGeneral.GeneralLv);
                chatService.SystemSendWhisper(ContextUser, content);
            }

            return(true);
        }