示例#1
0
        public override bool TakeAction()
        {
            if (latticeNum > ContextUser.WarehouseNum)
            {
                int maxWarehouseNum = ConfigEnvSet.GetInt("User.WarehouseMaxNum");
                int openGold        = GetOpenGoldNum(latticeNum, ContextUser.WarehouseNum);
                int UserGridNum     = ContextUser.WarehouseNum;
                int OpenGridNum     = MathUtils.Addition(UserGridNum, latticeNum, maxWarehouseNum);//开启的格子数
                int subGridNum      = MathUtils.Subtraction(latticeNum, UserGridNum, 0);
                if (ops == 1)
                {
                    //开启第n个格子所需的晶石
                    this.ErrorCode = 1;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1108_WarehouseNumUseGold, subGridNum, openGold);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum >= openGold)
                    {
                        this.ErrorCode = 2;

                        ContextUser.UseGold      = MathUtils.Addition(ContextUser.UseGold, openGold, int.MaxValue);
                        ContextUser.WarehouseNum = latticeNum;
                        //ContextUser.Update();
                        UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 5, latticeNum, OpenGridNum, openGold,
                                                      ContextUser.GoldNum,
                                                      MathUtils.Addition(ContextUser.GoldNum, openGold, int.MaxValue));
                    }
                    else
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                }
                else
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        public override bool TakeAction()
        {
            if (ContextUser.UserExtend != null && latticeNum > ContextUser.UserExtend.EnchantGridNum)
            {
                int openGold   = EnchantHelper.EnchantOpenGoldNum(latticeNum, ContextUser.UserExtend.EnchantGridNum);
                int subGridNum = MathUtils.Subtraction(latticeNum, ContextUser.UserExtend.EnchantGridNum);
                if (ops == 1)
                {
                    ErrorCode = ops;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1260_UseGoldOpenPackage, openGold, subGridNum);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum >= openGold)
                    {
                        ErrorCode = ops;
                        int goldNum = ContextUser.GoldNum;
                        ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, openGold);
                        ContextUser.UserExtend.UpdateNotify(obj =>
                        {
                            ContextUser.UserExtend.EnchantGridNum = (short)latticeNum;
                            return(true);
                        });

                        UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 8, latticeNum, subGridNum, openGold, ContextUser.GoldNum, goldNum);
                    }
                    else
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                }
                else
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
            }
            return(true);
        }
示例#3
0
 public override bool TakeAction()
 {
     if (latticeNum > ContextUser.CrystalNum)
     {
         int openGold       = GetOpenGoldNum(latticeNum, ContextUser.CrystalNum);
         int UserCrystalNum = ContextUser.CrystalNum;
         int openGridNum    = MathUtils.Addition(UserCrystalNum, latticeNum, 20);//开启的格子数
         int subNum         = MathUtils.Subtraction(latticeNum, ContextUser.CrystalNum, 0);
         if (ops == 1)
         {
             //开启第n个格子所需的晶石
             ErrorCode = 1;
             ErrorInfo = string.Format(LanguageManager.GetLang().St1310_UseCrystalGold, subNum, openGold);
             return(false);
         }
         else if (ops == 2)
         {
             if (ContextUser.GoldNum >= openGold)
             {
                 ErrorCode              = 2;
                 ContextUser.UseGold    = MathUtils.Addition(ContextUser.UseGold, openGold, int.MaxValue);
                 ContextUser.CrystalNum = latticeNum;
                 //ContextUser.Update();
                 UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 5, latticeNum, openGridNum, openGold,
                                               ContextUser.GoldNum,
                                               MathUtils.Addition(ContextUser.GoldNum, openGold, int.MaxValue));
             }
             else
             {
                 ErrorCode = LanguageManager.GetLang().ErrorCode;
                 ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                 return(false);
             }
         }
         else
         {
             ErrorCode = LanguageManager.GetLang().ErrorCode;
             return(false);
         }
     }
     return(true);
 }
示例#4
0
        public override bool TakeAction()
        {
            //UserHelper.ChechDailyRestrain(ContextUser.UserID);
            if (ContextUser.VipLv < 5)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St10009_NotPayDew;
                return(false);
            }
            int       sumGold    = 0;
            int       payDewTime = 0;
            UserPlant plant      = new PersonalCacheStruct <UserPlant>().FindKey(ContextUser.UserID);

            if (plant.DewNum == 8)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St10009_DewNumFull;
                return(false);
            }
            if (plant != null && DateTime.Now.Date == plant.DewDate.Date)
            {
                payDewTime = MathUtils.Addition(plant.PayDewTime, 1, int.MaxValue);
                sumGold    = (payDewTime * 2);
            }
            else
            {
                payDewTime = 1;
                sumGold    = 2;
            }
            if (ops == 1)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St10009_PayDewUseGold, sumGold);
                return(false);
            }
            else if (ops == 2)
            {
                if (ContextUser.GoldNum < sumGold)
                {
                    ErrorCode = 2;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                if (ContextUser.GoldNum >= sumGold)
                {
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, sumGold, int.MaxValue);
                    //ContextUser.Update();
                    dewNum           = MathUtils.Addition(plant.DewNum, 1, int.MaxValue);
                    plant.DewNum     = dewNum;
                    plant.PayDewTime = payDewTime;
                    plant.DewDate    = DateTime.Now;
                    //plant.Update();
                    UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 3, 0, dewNum, sumGold,
                                                  ContextUser.GoldNum,
                                                  MathUtils.Addition(ContextUser.GoldNum, sumGold, int.MaxValue));
                    UserLogHelper.AppenLandLog(ContextUser.UserID, 8, 0, 0, sumGold, 0, 0, dewNum);
                }
            }

            return(true);
        }
示例#5
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);
        }
示例#6
0
        public override bool TakeAction()
        {
            ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(_itemId);

            //UserItemHelper.AddUserItem(ContextUser.UserID, 1702, 1);
            //UserItemHelper.AddUserItem(ContextUser.UserID, 1701, 1);
            //UserItemHelper.AddUserItem(ContextUser.UserID, 1213, 1);
            if (itemInfo == null)
            {
                return(false);
            }
            //判断背包是否已满

            string fullTitle = string.Empty;
            bool   isFull    = false;

            if (itemInfo.ItemType == ItemType.ZhuangBei)
            {
                isFull = UserPackHelper.PackIsFull(ContextUser, BackpackType.ZhuangBei, _num, out fullTitle);
            }
            else
            {
                isFull = UserPackHelper.PackIsFull(ContextUser, BackpackType.BeiBao, _num, out fullTitle);
            }

            if (isFull)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = fullTitle;
                //ErrorInfo = LanguageManager.GetLang().St7004_BeiBaoTimeOut;
                return(false);
            }
            //读取物品信息
            MallItemsInfo mallItemInfo = new ConfigCacheSet <MallItemsInfo>().FindKey(_itemId, CityId, _commandType);

            if (mallItemInfo == null)
            {
                return(false);
            }
            //物品价格
            int mallPrice = mallItemInfo.Price;

            if (mallItemInfo.MallType == ShopType.Props || mallItemInfo.MallType == ShopType.PresendBox)
            {
                mallPrice = (FestivalHelper.StoreDiscount() * mallPrice).ToInt();
            }
            else if (mallItemInfo.SpecialPrice > 0)
            {
                mallPrice = mallItemInfo.SpecialPrice;
            }
            //根据物品类型进行扣钱
            if (_commandType == ShopType.Props || _commandType == ShopType.PresendBox)
            {
                int useGold = mallPrice * _num;
                //if (mallItemInfo.MallType == ShopType.PresendBox)
                //{
                if (ContextUser.GoldNum < useGold)
                {
                    ErrorCode = 3;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
                //增加道具日志统计
                var mallItemLog = new MallItemLog
                {
                    Amount     = useGold,
                    CreateDate = DateTime.Now,
                    ItemID     = _itemId,
                    ItemName   = itemInfo.ItemName,
                    ItemNum    = _num,
                    MobileType = ContextUser.MobileType,
                    Pid        = ContextUser.Pid,
                    PropType   = itemInfo.PropType,
                    RetailID   = ContextUser.RetailID,
                    Uid        = ContextUser.UserID.ToInt()
                };

                var sender = DataSyncManager.GetDataSender();
                sender.Send(mallItemLog);
                UserItemHelper.AddUserItem(ContextUser.UserID, _itemId, _num);
                UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 8, 1, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue));
                //}
                //预留判断消耗的是金币还是晶石
                //else
                //{
                //    if (ContextUser.GameCoin <useGold)
                //    {
                //        ErrorCode = LanguageManager.GetLang().ErrorCode;
                //        ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                //        return false;
                //    }
                //    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, useGold);
                //    UserItemHelper.AddUserItem(ContextUser.UserID, _itemId, _num);
                //}
            }
            return(true);
        }
示例#7
0
        public override bool TakeAction()
        {
            UserChallengeNum userchallenge = new GameDataCacheSet <UserChallengeNum>().FindKey(ContextUser.UserID);

            int openGold = GetChallengeNum(ContextUser.UserID);

            if (ops == 1)
            {
                this.ErrorCode = 1;
                this.ErrorInfo = openGold.ToString();
                return(false);
            }
            else if (ops == 2)
            {
                if (ContextUser.GoldNum >= openGold)
                {
                    this.ErrorCode      = 2;
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, openGold, int.MaxValue);
                    int num = 0;

                    if (userchallenge == null)
                    {
                        num = 1;
                        UserChallengeNum userChallengeNum = new UserChallengeNum()
                        {
                            UserID       = ContextUser.UserID,
                            ChallengeNum = 1,
                            InsertDate   = DateTime.Now
                        };
                        new GameDataCacheSet <UserChallengeNum>().Add(userChallengeNum, GameEnvironment.CacheUserPeriod);
                    }
                    else
                    {
                        if (userchallenge.InsertDate.Date == DateTime.Now.Date)
                        {
                            num = MathUtils.Addition(userchallenge.ChallengeNum, 1, int.MaxValue);
                            userchallenge.ChallengeNum = num;
                        }
                        else
                        {
                            userchallenge.ChallengeNum = 1;
                            num = 1;
                        }
                        userchallenge.InsertDate = DateTime.Now;
                    }
                    UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 4, 0, num, openGold,
                                                  ContextUser.GoldNum,
                                                  MathUtils.Addition(ContextUser.GoldNum, openGold, int.MaxValue));
                }
                else
                {
                    //todo 客户端跳转充值页面的特殊值 10
                    this.ErrorCode = LanguageManager.GetLang().RechargeError;
                    this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            return(true);
        }
示例#8
0
        public override bool TakeAction()
        {
            UserHelper.ChechDailyRestrain(ContextUser.UserID);
            int wjkNum = 0;
            int subNum = 0;
            int maxNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.WaJinKuang);
            UserDailyRestrain userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);

            if (userRestrain != null && DateTime.Now.Date == userRestrain.RefreshDate.Date)
            {
                wjkNum = userRestrain.Funtion3;
                subNum = MathUtils.Subtraction(maxNum, wjkNum);
            }
            else
            {
                wjkNum = 0;
                subNum = maxNum;
            }

            if ((userRestrain != null && userRestrain.Funtion3 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.WaJinKuang) && DateTime.Now.Date == userRestrain.RefreshDate.Date))
            {
                ErrorCode = 2;
                ErrorInfo = LanguageManager.GetLang().St1011_WaJinKuangFull;
                return(false);
            }

            int useGold    = GetPayCoinGold(ContextUser.UserID, ContextUser.VipLv, payType);
            int payCoinNum = GetPayCoinNum(ContextUser.UserID, ContextUser.VipLv, payType, ContextUser.UserLv);

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

                    if (ContextUser.GoldNum >= useGold)
                    {
                        int goldNum = ContextUser.GoldNum;
                        ContextUser.UseGold  = MathUtils.Addition(ContextUser.UseGold, useGold);
                        ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, payCoinNum);
                        //ContextUser.Update();

                        if (userRestrain != null)
                        {
                            userRestrain.Funtion3 = MathUtils.Addition(wjkNum, 1);
                            //userRestrain.Update();
                            UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 2, 0, userRestrain.Funtion3, useGold,
                                                          ContextUser.GoldNum, goldNum);
                        }
                    }
                    this.ErrorCode = 0;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1011_PayCoinUseGold, useGold, payCoinNum, subNum - 1);
                    return(false);
                }
            }
            else if (payType == 2)
            {
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ZiDongJinRuJinKuangDong))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                if (ops == 1)
                {
                    this.ErrorCode = 0;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1011_PayCoinUseGold, useGold, payCoinNum, subNum);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.VipLv < 6)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                        return(false);
                    }
                    if (ContextUser.GoldNum < useGold)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }


                    if (userRestrain != null)
                    {
                        userRestrain.Funtion3 = MathUtils.Addition(wjkNum, 1);
                        //userRestrain.Update();
                    }
                    int gamecoin = GetPayCoinNum(ContextUser.UserID, ContextUser.VipLv, payType, ContextUser.UserLv);
                    ContextUser.UseGold  = MathUtils.Addition(ContextUser.UseGold, useGold);
                    ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, gamecoin);
                    //ContextUser.Update();
                }
            }
            return(true);
        }