Example #1
0
 private bool IsRefreshKalpa(UserDailyRestrain dailyRestrain, RestrainType refresh, int useGold)
 {
     if (dailyRestrain.UserExtend != null)
     {
         int kalpaNum = 0;
         if (refresh == RestrainType.RefreshKalpa)
         {
             kalpaNum = dailyRestrain.UserExtend.KalpaNum;
         }
         else if (refresh == RestrainType.RefreshLastKalpa)
         {
             kalpaNum = dailyRestrain.UserExtend.LastKalpaNum;
         }
         if (VipHelper.DailyRestrainSurplusNum(ContextUser, refresh, kalpaNum) > 0)
         {
             //DailyUserExtend userExtend = dailyRestrain.UserExtend;
             dailyRestrain.UserExtend.UpdateNotify(obj =>
             {
                 dailyRestrain.UserExtend.KalpaDate = DateTime.Now;
                 if (refresh == RestrainType.RefreshKalpa)
                 {
                     dailyRestrain.UserExtend.KalpaNum = MathUtils.Addition(dailyRestrain.UserExtend.KalpaNum, 1, int.MaxValue);
                 }
                 else if (refresh == RestrainType.RefreshLastKalpa)
                 {
                     dailyRestrain.UserExtend.LastKalpaNum = MathUtils.Addition(dailyRestrain.UserExtend.LastKalpaNum, 1, int.MaxValue);
                 }
                 dailyRestrain.UserExtend.KalpaPlot = new CacheList<FunPlot>();
                 return true;
             });
             //dailyRestrain.Update();
             if (ContextUser.UserExtend != null)
             {
                 ContextUser.UserExtend.UpdateNotify(obj =>
                 {
                     if (refresh == RestrainType.RefreshLastKalpa)
                     {
                         ContextUser.UserExtend.LayerNum = MathUtils.Subtraction(ContextUser.UserExtend.LayerNum, 1, 1);
                     }
                     ContextUser.UserExtend.HurdleNum = 1;
                     return true;
                 });
                 ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
                 //ContextUser.Update();
             }
             return true;
         }
     }
     return false;
 }
Example #2
0
        /// <summary>
        /// 天地劫挑战次数
        /// </summary>
        /// <param name="plotNPCInfo"></param>
        private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo)
        {
            UserDailyRestrain userRestrain = new PersonalCacheStruct<UserDailyRestrain>().FindKey(Uid);
            if (userRestrain == null)
            {
                userRestrain = new UserDailyRestrain() { UserID = Uid, FunPlot = new CacheList<FunPlot>() };
            }
            if (userRestrain.UserExtend == null)
            {
                userRestrain.UserExtend = new DailyUserExtend();
                userRestrain.UserExtend.KalpaPlot = new CacheList<FunPlot>();
            }
            int plotNum = 0;
            FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID);
            if (funPlot == null)
            {
                plotNum = 1;
            }
            else
            {
                plotNum = MathUtils.Addition(funPlot.Num, 1, int.MaxValue);
                userRestrain.UserExtend.UpdateNotify(obj =>
                    {
                        userRestrain.UserExtend.KalpaPlot.Remove(funPlot);
                        return true;
                    });
            }
            funPlot = new FunPlot
            {
                PlotID = plotNPCInfo.PlotID,
                Num = plotNum
            };
            userRestrain.UserExtend.UpdateNotify(obj =>
                {
                    userRestrain.UserExtend.KalpaPlot.Add(funPlot);
                    return true;
                });

        }
Example #3
0
        private void CreateDailyRestrain()
        {
            if (new PersonalCacheStruct<UserDailyRestrain>().FindKey(UserId.ToString()) == null)
            {
                UserDailyRestrain dailyRestrain = new UserDailyRestrain();

                dailyRestrain.UserID = UserId.ToString();
                dailyRestrain.RefreshDate = DateTime.Now;
                dailyRestrain.Funtion1 = 0;
                dailyRestrain.Funtion2 = 0;
                dailyRestrain.Funtion3 = 0;
                dailyRestrain.Funtion4 = 0;
                dailyRestrain.Funtion5 = 0;
                dailyRestrain.Funtion6 = 0;
                dailyRestrain.Funtion7 = 0;
                dailyRestrain.Funtion8 = 0;
                dailyRestrain.Funtion9 = 0;
                var cacheSet = new PersonalCacheStruct<UserDailyRestrain>();
                cacheSet.Add(dailyRestrain);
                cacheSet.Update();
            }
        }
Example #4
0
        /// <summary>
        /// 精英副本挑战次数
        /// </summary>
        /// <param name="plotNPCInfo"></param>
        private void EliteDailyRestrain(PlotNPCInfo plotNPCInfo)
        {
            UserDailyRestrain userRestrain = new PersonalCacheStruct<UserDailyRestrain>().FindKey(Uid);
            if (userRestrain == null)
            {
                userRestrain = new UserDailyRestrain() { UserID = Uid, FunPlot = new CacheList<FunPlot>() };
            }

            int plotNum = 0;
            FunPlot funPlot = null;
            if (userRestrain.FunPlot.Count > 0)
            {
                funPlot = userRestrain.FunPlot.Find(m => m.PlotID == plotNPCInfo.PlotID);
            }
            if (funPlot == null)
            {
                plotNum = 1;
            }
            else
            {
                plotNum = MathUtils.Addition(funPlot.Num, 1, int.MaxValue);
                userRestrain.FunPlot.Remove(funPlot);
            }
            funPlot = new FunPlot
                          {
                              PlotID = plotNPCInfo.PlotID,
                              Num = plotNum
                          };
            userRestrain.FunPlot.Add(funPlot);

        }
Example #5
0
        private void DoPrecess(UserDailyRestrain restrain, int petUseGold)
        {
            if (ContextUser.GoldNum >= petUseGold)
            {
                petId = ContextUser.UserExtend.LightPetID;
                restrain.UserID = Uid;
                if (restrain.UserExtend == null) restrain.UserExtend = new DailyUserExtend();
                restrain.UserExtend.UpdateNotify(obj =>
                {
                    restrain.UserExtend.PetRefeshNum++;
                    return true;
                });
                //restrain.Update();

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, petUseGold, int.MaxValue);
                //ContextUser.Update();
            }
        }
Example #6
0
        /// <summary>
        /// 天地劫挑战次数
        /// </summary>
        /// <param name="plotNPCInfo"></param>
        private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo)
        {
            var cacheSet = new GameDataCacheSet<UserDailyRestrain>();
            UserDailyRestrain userRestrain = cacheSet.FindKey(Uid);
            if (userRestrain == null)
            {
                userRestrain = new UserDailyRestrain() { UserID = Uid };
                cacheSet.Add(userRestrain);
                userRestrain = cacheSet.FindKey(Uid);
            }
            if (userRestrain.UserExtend == null)
            {
                userRestrain.UserExtend = new DailyUserExtend();
                //userRestrain.UserExtend.KalpaPlot = new List<FunPlot>();
            }
            int plotNum = 0;
            FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID);
            if (funPlot == null)
            {
                plotNum = 1;
                funPlot = new FunPlot
                {
                    PlotID = plotNPCInfo.PlotID,
                    Num = plotNum
                };
                userRestrain.UserExtend.UpdateNotify(obj =>
                    {
                        userRestrain.UserExtend.KalpaPlot.Add(funPlot);
                        return true;
                    });

            }
        }
Example #7
0
        public override bool TakeAction()
        {
            int energyNum = ConfigEnvSet.GetInt("User.EnergyNum");
            UserHelper.ChechDailyRestrain(ContextUser.UserID);
            var cacheSet = new GameDataCacheSet<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, GameEnvironment.CacheUserPeriod);
                        }
                    }

                    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, GameEnvironment.CacheUserPeriod);
                    }

                    UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, userRestrain.Funtion4, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue));
                }
            }
            return true;
        }
Example #8
0
        private void CreateDailyRestrain()
        {
            if (new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid) == null)
            {
                UserDailyRestrain dailyRestrain = new UserDailyRestrain();

                dailyRestrain.UserID = Uid;
                dailyRestrain.RefreshDate = DateTime.Now;
                dailyRestrain.Funtion1 = 0;
                dailyRestrain.Funtion2 = 0;
                dailyRestrain.Funtion3 = 0;
                dailyRestrain.Funtion4 = 0;
                dailyRestrain.Funtion5 = 0;
                dailyRestrain.Funtion6 = 0;
                dailyRestrain.Funtion7 = 0;
                dailyRestrain.Funtion8 = 0;
                dailyRestrain.Funtion9 = 0;
                var cacheSet = new GameDataCacheSet<UserDailyRestrain>();
                cacheSet.Add(dailyRestrain);
                cacheSet.Update();
            }
        }