Exemple #1
0
 public static void AddPrize(string UserID, int itemID, string mailContent)
 {
     string ItemPackage = itemID + "=1=1";
     var cacheset = new ShareCacheStruct<UserTakePrize>();
     UserTakePrize takeprize = new UserTakePrize()
     {
         CreateDate = DateTime.Now,
         CrystalPackage = string.Empty,
         EnergyNum = 0,
         ExpNum = 0,
         GainBlessing = 0,
         GameCoin = 0,
         Gold = 0,
         ID = Guid.NewGuid().ToString(),
         ItemPackage = ItemPackage,
         IsTasked = false,
         MailContent = mailContent,
         ObtainNum = 0,
         OpUserID = 0,
         SparePackage = string.Empty,
         UserID = UserID.ToInt(),
         VipLv = 0,
     };
     cacheset.Add(takeprize, GameEnvironment.CacheGlobalPeriod);
 }
Exemple #2
0
        private void AddUserItem(string userID, int itemID, int itemNum)
        {
            if (itemID > 0 && itemNum > 0)
            {
                UserTakePrize userPrizeLog = new UserTakePrize
                {
                    ID = Guid.NewGuid().ToString(),
                    UserID = userID.ToInt(),
                    ItemPackage = string.Format("{0}={1}={2}", itemID, 1, itemNum),
                    MailContent = string.Format("GM发送物品"),
                    IsTasked = false,
                    TaskDate = MathUtils.SqlMinDate,
                    OpUserID = 10000,
                    CreateDate = DateTime.Now

                };
                var sender = DataSyncManager.GetDataSender();
                sender.Send(userPrizeLog);
            }
            else
            {
                throw new Exception("无此物品");
            }
        }
Exemple #3
0
 ///// <summary>
 ///// 奖励配置
 ///// </summary>
 ///// <param name="user"></param>
 //public static UserTakePrize GetUserTake(TreasureInfo prize, string userID)
 //{
 //    UserTakePrize userPrize = new UserTakePrize();
 //    userPrize.CreateDate = DateTime.Now;
 //    userPrize.ID = Guid.NewGuid().ToString();
 //    userPrize.UserID = Convert.ToInt32(userID);
 //    userPrize.MailContent = LanguageManager.GetLang().St12004_YouWheelOfFortune.Substring(0, 9);
 //    userPrize.IsTasked = false;
 //    userPrize.TaskDate = MathUtils.SqlMinDate;
 //    userPrize.ItemPackage = string.Empty;
 //    userPrize.SparePackage = string.Empty;
 //    userPrize.CrystalPackage = string.Empty;
 //    userPrize.OpUserID = 10000;
 //    switch (prize.Type)
 //    {
 //        case RewardType.GameGoin:
 //            userPrize.GameCoin = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GameCoin, userPrize.GameCoin) + ",";
 //            break;
 //        case RewardType.Obtion:
 //            userPrize.ObtainNum = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ObtionNum, userPrize.ObtainNum) + ",";
 //            break;
 //        case RewardType.ExpNum:
 //            userPrize.ExpNum = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ExpNum, userPrize.ExpNum) + ",";
 //            break;
 //        case RewardType.EnergyNum:
 //            userPrize.EnergyNum = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_EnergyNum, userPrize.EnergyNum) + ",";
 //            break;
 //        case RewardType.Experience:
 //            break;
 //        case RewardType.Gold:
 //            userPrize.Gold = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GiftGoldNum, userPrize.Gold) + ",";
 //            break;
 //        case RewardType.Item:
 //            ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(prize.ItemID);
 //            if (itemInfo != null)
 //            {
 //                userPrize.ItemPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", itemInfo.ItemName, (int)prize.Num) + ",";
 //            }
 //            break;
 //        case RewardType.CrystalId:
 //            CrystalInfo crystal = new ConfigCacheSet<CrystalInfo>().FindKey(prize.ItemID);
 //            if (crystal != null)
 //            {
 //                userPrize.CrystalPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", crystal.CrystalName, (int)prize.Num) + ",";
 //            }
 //            break;
 //        case RewardType.Spare:
 //            SparePartInfo spare = new ConfigCacheSet<SparePartInfo>().FindKey(prize.ItemID);
 //            if (spare != null)
 //            {
 //                userPrize.SparePackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", spare.Name, (int)prize.Num) + ",";
 //            }
 //            break;
 //        case RewardType.Enchant:
 //            EnchantInfo enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(prize.ItemID);
 //            if (enchantInfo != null)
 //            {
 //                userPrize.EnchantPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", enchantInfo.EnchantName, (int)prize.Num) + ",";
 //            }
 //            break;
 //        default:
 //            break;
 //    }
 //    userPrize.MailContent = userPrize.MailContent.TrimEnd(',');
 //    return userPrize;
 //}
 /// <summary>
 /// 充值返还
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="goldNum"></param>
 /// <returns></returns>
 public static void ReturnRatioGold(string userID, int goldNum)
 {
     UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID);
     if (userDial != null && userDial.ReturnRatio > 0)
     {
         int giftGold = MathUtils.RoundCustom(goldNum * userDial.ReturnRatio);
         var cachePrize = new ShareCacheStruct<UserTakePrize>();
         UserTakePrize userPrize = new UserTakePrize();
         userPrize.CreateDate = DateTime.Now;
         userPrize.ID = Guid.NewGuid().ToString();
         userPrize.UserID = Convert.ToInt32(userID);
         userPrize.MailContent = string.Format(LanguageManager.GetLang().St12004_RechargeReturnGoldNum, GetTransformData(userDial.ReturnRatio), giftGold);
         userPrize.IsTasked = false;
         userPrize.TaskDate = MathUtils.SqlMinDate;
         userPrize.ItemPackage = string.Empty;
         userPrize.SparePackage = string.Empty;
         userPrize.CrystalPackage = string.Empty;
         userPrize.EnchantPackage = string.Empty;
         userPrize.OpUserID = 10000;
         userPrize.GameCoin = 0;
         userPrize.ObtainNum = 0;
         userPrize.ExpNum = 0;
         userPrize.EnergyNum = 0;
         userPrize.Gold = giftGold;
         userDial.ReturnRatio = 0;
         cachePrize.Add(userPrize, GameEnvironment.CacheGlobalPeriod);
     }
 }
Exemple #4
0
        public override void Process(JsonParameter[] paramList)
        {
            JsonParameterList parameters = JsonParameter.Convert(paramList);
            string op = parameters["op"];
            string[] UserList = Convert.ToString(parameters["UserID"]).Split(new char[] { ',' });
            string itemPackage = Convert.ToString(parameters["Item"]);
            string crystalList = Convert.ToString(parameters["Crystal"]);
            string sparePackage = Convert.ToString(parameters["SparePackage"]);
            string enchantPackage = Convert.ToString(parameters["EnchantPackage"]);

            int obtainNum = 0;
            if (parameters["ObtainNum"].Length > 0)
            {
                obtainNum = Convert.ToInt32(parameters["ObtainNum"]);
            }
            short energyNum = 0;
            if (parameters["EnergyNum"].Length > 0)
            {
                energyNum = Convert.ToInt16(parameters["EnergyNum"]);
            }
            int gameCoin = 0;
            if (parameters["GameCoin"].Length > 0)
            {
                gameCoin = Convert.ToInt32(parameters["GameCoin"]);
            }
            int gold = 0;
            if (parameters["Gold"].Length > 0)
            {
                gold = Convert.ToInt32(parameters["Gold"]);
            }
            int expNum = 0;
            if (parameters["ExpNum"].Length > 0)
            {
                expNum = Convert.ToInt32(parameters["ExpNum"]);
            }
            int vipLv = 0;
            if (parameters["VipLv"].Length > 0)
            {
                vipLv = Convert.ToInt32(parameters["VipLv"]);
            }
            int gainBlessing = 0;
            if (parameters["GainBlessing"].Length > 0)
            {
                gainBlessing = Convert.ToInt32(parameters["GainBlessing"]);
            }
            int honourNum = 0;
            if (parameters["HonourNum"].Length > 0)
            {
                honourNum = Convert.ToInt32(parameters["HonourNum"]);
            }
            string mailContent = Convert.ToString(parameters["MailContent"]);
            int opUserID = Convert.ToInt32(parameters["OpUserID"]);
            //var cacheSetUserItem = new GameDataCacheSet<UserItemPackage>();
            var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>();
            var itemArray = itemPackage.Split(',');
            foreach (string str in UserList)
            {
                try
                {
                    int userID = str.Trim().ToInt();

                    var user = new GameDataCacheSet<GameUser>().FindKey(str);
                    if(user!=null)
                    {
                        user.GiftGold = MathUtils.Addition(user.GiftGold, gold);
                        user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum);
                        user.EnergyNum = MathUtils.Addition(user.EnergyNum, energyNum);
                        user.GameCoin = MathUtils.Addition(user.GameCoin, gameCoin);
                        user.ExpNum = MathUtils.Addition(user.ExpNum, expNum);
                        user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum);
                    }

                    foreach (var item in itemArray)
                    {
                        if(item.Split('=').Length==2)
                        {
                            var itemInfo = cacheSetItemInfo.FindKey(item.Split('=')[0]);
                            if(itemInfo!=null)
                            {
                                UserItemHelper.AddUserItem(str, item.Split('=')[0].ToInt(), item.Split('=')[1].ToInt());
                            }
                        }
                    }
                    Guid newGuid = Guid.NewGuid();
                    UserTakePrize userPrizeLog = new UserTakePrize
                    {
                        ID = newGuid.ToString(),
                        UserID = userID,
                        ObtainNum = obtainNum,
                        EnergyNum = energyNum,
                        GameCoin = gameCoin,
                        Gold = gold,
                        ExpNum = expNum,
                        VipLv = vipLv,
                        GainBlessing = gainBlessing,
                        ItemPackage = itemPackage,
                        CrystalPackage = crystalList,
                        SparePackage = sparePackage,
                        EnchantPackage = enchantPackage,
                        MailContent = mailContent,
                        IsTasked = false,
                        TaskDate = MathUtils.SqlMinDate,
                        OpUserID = opUserID,
                        CreateDate = DateTime.Now,
                        HonourNum = honourNum,
                        Items = itemPackage,

                    };
                    var cacheSet = new ShareCacheStruct<UserTakePrize>();
                    cacheSet.Add(userPrizeLog, GameEnvironment.CacheGlobalPeriod);
                    cacheSet.Update();
                    PutCrystal(crystalList.Split(','), str);

                    // 发送系统信件
                    UserMail userMail = new UserMail(newGuid);
                    userMail.UserId = userID;
                    userMail.MailType = (int)MailType.System;
                    userMail.Title = LanguageManager.GetLang().St_SystemMailTitle;
                    userMail.Content = mailContent;
                    userMail.SendDate = DateTime.Now;
                    TjxMailService mailService=new TjxMailService(user);
                    mailService.Send(userMail);
                }
                catch (Exception ex)
                {
                    new BaseLog().SaveLog(ex);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// 公会城市争斗战冠军奖励
        /// </summary>
        /// <param name="user"></param>
        public static UserTakePrize GetUserTake(CacheList<PrizeInfo> prizeList, string userID, int userlv, string cityName)
        {
            UserTakePrize userPrize = new UserTakePrize();
            userPrize.CreateDate = DateTime.Now;
            userPrize.ID = Guid.NewGuid().ToString();
            userPrize.UserID = Convert.ToInt32(userID);
            userPrize.IsTasked = false;
            userPrize.TaskDate = MathUtils.SqlMinDate;
            userPrize.ItemPackage = string.Empty;
            userPrize.SparePackage = string.Empty;
            userPrize.CrystalPackage = string.Empty;
            userPrize.OpUserID = 10000;
            foreach (var prize in prizeList)
            {
                if (prize.Type == RewardType.GameGoin)
                {
                    userPrize.GameCoin = (prize.Coefficient * userlv).ToInt();

                }
                else if (prize.Type == RewardType.ExpNum)
                {
                    userPrize.ExpNum = (prize.Coefficient * userlv).ToInt();

                }
                else if (prize.Type == RewardType.Gold)
                {
                    userPrize.Gold = (prize.Coefficient * userlv).ToInt();
                }
            }
            userPrize.MailContent = string.Format(LanguageManager.GetLang().ChampionWelfare, cityName,
                                                  userPrize.GameCoin, userPrize.Gold, userPrize.ExpNum);
            return userPrize;
        }
Exemple #6
0
        public static UserTakePrize GetUserTake(PrizeInfo prize, string userID, FestivalInfo info)
        {
            UserTakePrize userPrize = new UserTakePrize();
            userPrize.CreateDate = DateTime.Now;
            userPrize.ID = Guid.NewGuid().ToString();
            userPrize.UserID = Convert.ToInt32(userID);
            userPrize.MailContent = info.FestivalExtend.KeyWord;
            userPrize.IsTasked = false;
            userPrize.TaskDate = MathUtils.SqlMinDate;
            userPrize.ItemPackage = string.Empty;
            userPrize.SparePackage = string.Empty;
            userPrize.CrystalPackage = string.Empty;
            userPrize.EnchantPackage = string.Empty;
            userPrize.OpUserID = 10000;
            switch (prize.Type)
            {
                case RewardType.GameGoin:
                    userPrize.GameCoin = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num);
                    break;
                case RewardType.Obtion:
                    userPrize.ObtainNum = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ObtionNum, prize.Num);
                    break;
                case RewardType.ExpNum:
                    userPrize.ExpNum = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num);
                    break;
                case RewardType.EnergyNum:
                    userPrize.EnergyNum = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num);
                    break;
                case RewardType.Experience:
                    break;
                case RewardType.Gold:
                    userPrize.Gold = prize.Num;
                    userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GiftGoldNum, prize.Num);
                    break;
                case RewardType.Item:
                    userPrize.ItemPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(prize.ItemID);
                    if (itemInfo != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", itemInfo.ItemName, prize.Num);
                    }
                    break;
                case RewardType.CrystalType:
                    //List<CrystalInfo> crystalArray2 = new ShareCacheStruct<CrystalInfo>().FindAll(CrystalInfo.Index_CrystalQuality, prize.CrystalType);
                    //userPrize.CrystalPackage = string.Format("{0}={1}={2}", itemID, prize.UserLv, itemNum);
                    break;
                case RewardType.CrystalId:

                    userPrize.CrystalPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    CrystalInfo crystal = new ShareCacheStruct<CrystalInfo>().FindKey(prize.ItemID);
                    if (crystal != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", crystal.CrystalName, prize.Num);
                    }
                    break;
                case RewardType.Spare:
                    userPrize.SparePackage = string.Format("{0}={1}={2}", prize.ItemID, prize.Num, prize.Num);
                    SparePartInfo spare = new ShareCacheStruct<SparePartInfo>().FindKey(prize.ItemID);
                    if (spare != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", spare.Name, prize.Num);
                    }
                    break;
                case RewardType.Enchant:
                    userPrize.EnchantPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    EnchantInfo enchantInfo = new ShareCacheStruct<EnchantInfo>().FindKey(prize.ItemID);
                    if (enchantInfo != null)
                    {
                        userPrize.MailContent += string.Format("{0}*{1}", enchantInfo.EnchantName, prize.Num);
                    }
                    break;
                default:
                    break;
            }
            return userPrize;
        }
Exemple #7
0
        /// <summary>
        /// 获得奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="prize"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static UserTakePrize GetUserTake(string userID, PrizeInfo prize, string content)
        {
            GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID);
            if (user == null)
            {
                return null;
            }
            UserTakePrize userPrize = new UserTakePrize();
            userPrize.CreateDate = DateTime.Now;
            userPrize.ID = Guid.NewGuid().ToString();
            userPrize.UserID = Convert.ToInt32(userID);
            userPrize.MailContent = content;
            userPrize.IsTasked = false;
            userPrize.TaskDate = MathUtils.SqlMinDate;
            userPrize.ItemPackage = string.Empty;
            userPrize.SparePackage = string.Empty;
            userPrize.CrystalPackage = string.Empty;
            userPrize.EnchantPackage = string.Empty;
            userPrize.OpUserID = 10000;
            string prizeContent = string.Empty;
            switch (prize.Type)
            {
                case RewardType.GameGoin:
                    userPrize.GameCoin = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num);
                    break;
                case RewardType.Obtion:
                    userPrize.ObtainNum = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_ObtionNum, prize.Num);
                    break;
                case RewardType.ExpNum:
                    userPrize.ExpNum = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num);
                    break;
                case RewardType.EnergyNum:
                    userPrize.EnergyNum = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num);
                    break;
                case RewardType.Experience:
                    break;
                case RewardType.Gold:
                    userPrize.Gold = prize.Num;
                    prizeContent = string.Format(LanguageManager.GetLang().St_GiftGoldNum, prize.Num);
                    break;
                case RewardType.Item:
                    userPrize.ItemPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(prize.ItemID);
                    if (itemInfo != null)
                    {
                        prizeContent = string.Format("{0}*{1}", itemInfo.ItemName, prize.Num);
                    }
                    break;
                case RewardType.CrystalId:

                    userPrize.CrystalPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    CrystalInfo crystal = new ConfigCacheSet<CrystalInfo>().FindKey(prize.ItemID);
                    if (crystal != null)
                    {
                        prizeContent = string.Format("{0}*{1}", crystal.CrystalName, prize.Num);
                    }
                    break;
                case RewardType.Spare:
                    userPrize.SparePackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    SparePartInfo spare = new ConfigCacheSet<SparePartInfo>().FindKey(prize.ItemID);
                    if (spare != null)
                    {
                        prizeContent = string.Format("{0}*{1}", spare.Name, prize.Num);
                    }
                    break;
                case RewardType.Enchant:
                    userPrize.EnchantPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.UserLv, prize.Num);
                    EnchantInfo enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(prize.ItemID);
                    if (enchantInfo != null)
                    {
                        prizeContent = string.Format("{0}*{1}", enchantInfo.EnchantName, prize.Num);
                    }
                    break;
                default:
                    break;
            }
            if (!string.IsNullOrEmpty(prizeContent))
            {
                userPrize.MailContent = string.Format(content, user.NickName, prizeContent);
            }
            return userPrize;
        }
Exemple #8
0
 /// <summary>
 /// 获得奖励物品
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="gamecoin"></param>
 /// <param name="item"></param>
 /// <param name="content"></param>
 public static void GainNewCardPackage(string userID, int gamecoin, string item, string content)
 {
     UserTakePrize userPrize = new UserTakePrize();
     userPrize.ID = Guid.NewGuid().ToString();
     userPrize.UserID = Convert.ToInt32(userID);
     userPrize.ObtainNum = 0;
     userPrize.EnergyNum = 0;
     userPrize.GameCoin = gamecoin;
     userPrize.Gold = 0;
     userPrize.ExpNum = 0;
     userPrize.VipLv = 0;
     userPrize.GainBlessing = 0;
     userPrize.ItemPackage = item;
     userPrize.SparePackage = string.Empty;
     userPrize.CrystalPackage = string.Empty;
     userPrize.EnchantPackage = string.Empty;
     userPrize.MailContent = content;
     userPrize.IsTasked = false;
     userPrize.TaskDate = MathUtils.SqlMinDate;
     userPrize.OpUserID = 10000;
     userPrize.CreateDate = DateTime.Now;
     new ShareCacheStruct<UserTakePrize>().Add(userPrize);
 }
Exemple #9
0
        private bool doProcessPrize(UserTakePrize userPrize)
        {
            Base.BaseLog log = new Base.BaseLog();
            if (userPrize == null) return false;
            string userID = userPrize.UserID.ToString();
            var gameUser = new GameDataCacheSet<GameUser>().FindKey(userID);
            if (gameUser == null) return false;

            log.SaveDebugLog(string.Format("玩家{0}领取奖励{1}:{2}", userID, userPrize.ID, userPrize.MailContent));
            userPrize.IsTasked = true;
            userPrize.TaskDate = DateTime.Now;
            //userPrize.Update();

            gameUser.ObtainNum = MathUtils.Addition(gameUser.ObtainNum, userPrize.ObtainNum);
            gameUser.EnergyNum = MathUtils.Addition(gameUser.EnergyNum, userPrize.EnergyNum.ToShort());
            gameUser.GameCoin = MathUtils.Addition(gameUser.GameCoin, userPrize.GameCoin);
            gameUser.GiftGold = MathUtils.Addition(gameUser.GiftGold, userPrize.Gold);
            gameUser.ExpNum = MathUtils.Addition(gameUser.ExpNum, userPrize.ExpNum);
            if (gameUser.UserExtend == null)
            {
                gameUser.UserExtend = new GameUserExtend();
            }
            gameUser.UserExtend.GainBlessing = MathUtils.Addition(gameUser.UserExtend.GainBlessing, userPrize.GainBlessing);
            if (userPrize.VipLv > 0)
            {
                var vipLv = new ConfigCacheSet<VipLvInfo>().FindKey(userPrize.VipLv.ToShort()) ?? new VipLvInfo();
                gameUser.ExtGold = vipLv.PayGold;
            }
            //gameUser.Update();

            PutItemPackage(userPrize.ItemPackage.Split(','), userID);
            PutCrystal(userPrize.CrystalPackage.Split(','), userID);
            PutSparePackage(userPrize.SparePackage.Split(','), userID);
            if (!string.IsNullOrEmpty(userPrize.EnchantPackage))
            {
                PutEnchant(userPrize.EnchantPackage.Split(','), userID);
            }
            var chatService = new TjxChatService();
            chatService.SystemSendWhisper(gameUser, string.Format("{0}", userPrize.MailContent));

            return true;
        }
Exemple #10
0
        /// <summary>
        /// 物品个数
        /// </summary>
        /// <param name="list"></param>
        /// <param name="userID"></param>
        private static int PutItemNum(UserTakePrize userPrize)
        {
            int packNum = 0;
            int subNum = 0;
            int sumNum = 0;
            string[] list = userPrize.ItemPackage.Split(',');
            foreach (string item in list)
            {
                if (string.IsNullOrEmpty(item)) continue;
                string[] itemList = item.Split(new char[] { '=' });

                int itemID = itemList.Length > 0 ? Convert.ToInt32(itemList[0]) : 0;
                int itemNum = itemList.Length > 2 ? Convert.ToInt32(itemList[2]) : 0;
                ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(itemID);
                if (itemInfo != null)
                {
                    packNum = itemNum / itemInfo.PackMaxNum;
                    subNum = itemNum % itemInfo.PackMaxNum;
                }
                if (subNum > 0)
                {
                    sumNum = MathUtils.Addition(sumNum, packNum);
                    sumNum = MathUtils.Addition(sumNum, 1);
                }
                else
                {
                    sumNum = MathUtils.Addition(sumNum, packNum);
                }
            }
            return sumNum;
        }
Exemple #11
0
 /// <summary>
 /// 老友礼包
 /// </summary>
 /// <param name="user"></param>
 public static void OldFriendPack(string userID, DateTime loginTime)
 {
     int loginDate = ConfigEnvSet.GetInt("LoginIntervalDate") > 0 ? ConfigEnvSet.GetInt("LoginIntervalDate") : 10;
     if ((DateTime.Now - loginTime).TotalDays >= loginDate && loginTime > MathUtils.SqlMinDate)
     {
         UserTakePrize userPrize = new UserTakePrize();
         userPrize.ID = Guid.NewGuid().ToString();
         userPrize.UserID = Convert.ToInt32(userID);
         userPrize.ObtainNum = 0;
         userPrize.EnergyNum = 0;
         userPrize.GameCoin = 0;
         userPrize.Gold = 0;
         userPrize.ExpNum = 0;
         userPrize.VipLv = 0;
         userPrize.GainBlessing = 0;
         userPrize.ItemPackage = "5025=1=1";
         userPrize.SparePackage = string.Empty;
         userPrize.CrystalPackage = string.Empty;
         userPrize.EnchantPackage = string.Empty;
         userPrize.MailContent = LanguageManager.GetLang().OldFriendPack;
         userPrize.IsTasked = false;
         userPrize.TaskDate = MathUtils.SqlMinDate;
         userPrize.OpUserID = 10000;
         userPrize.CreateDate = DateTime.Now;
         new ShareCacheStruct<UserTakePrize>().Add(userPrize);
     }
 }