Ejemplo n.º 1
0
 public override bool TakeAction()
 {
     festivalList = NoviceHelper.LimitFestivalList();
     if (festivalList.Count > 0)
     {
         string shortDateFormat = LanguageManager.GetLang().FestivalDataFormat;
         festivalInfo = festivalList[0];
         beginDate = festivalInfo.StartDate.ToString(shortDateFormat);
         if (festivalInfo.EndDate != MathUtils.SqlMinDate)
         {
             endDate = festivalInfo.EndDate.ToString(shortDateFormat);
         }
         else
         {
             endDate = festivalInfo.StartDate.AddHours(festivalInfo.ContinuedTime).ToString(shortDateFormat);
         }
     }
     festivalList.QuickSort((x, y) =>
     {
         if (x == null && y == null) return 0;
         if (x != null && y == null) return 1;
         if (x == null) return -1;
         return x.FestivalID.CompareTo(y.FestivalID);
     });
     return true;
 }
Ejemplo n.º 2
0
 public override bool TakeAction()
 {
     festivalInfo = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID);
     if (festivalInfo != null)
     {
         string shortDateFormat = LanguageManager.GetLang().FestivalDataFormat;
         beginDate = festivalInfo.StartDate.ToString(shortDateFormat);//yyyy-MM-dd HH:mm:ss;ms
        // beginDate = string.Format("{0:M}", festivalInfo.StartDate);
         if (festivalInfo.EndDate != MathUtils.SqlMinDate)
         {
            // endDate = string.Format("{0:M}", festivalInfo.EndDate);
             endDate = festivalInfo.EndDate.ToString(shortDateFormat);
         }
         else
         {
            // endDate = string.Format("{0:M}", festivalInfo.StartDate.AddHours(festivalInfo.ContinuedTime));
             endDate = festivalInfo.StartDate.AddHours(festivalInfo.ContinuedTime).ToString(shortDateFormat);
         }
     }
     return true;
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 累计消费活动奖励(晶石,金币,精力)
 /// </summary>
 private static void FestivalConsumeCount(FestivalInfo info, string userID)
 {
     UserConsume consume = new GameDataCacheSet<UserConsume>().FindKey(userID);
     if (consume == null)
     {
         return;
     }
     var cacheSet = new GameDataCacheSet<FestivalRestrain>();
     FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID);
     if (fRest != null && fRest.RestrainNum >= 1 && fRest.RefreashDate == info.StartDate)
         return;
     if ((info.FestivalType == FestivalType.SparConsumption && consume.GoldDate >= info.StartDate && consume.GoldNum >= info.RestrainNum) ||
         (info.FestivalType == FestivalType.GameCoin && consume.CoinDate >= info.StartDate && consume.GameCoin >= info.RestrainNum) ||
         (info.FestivalType == FestivalType.Energy && consume.EnergyDate >= info.StartDate && consume.EnergyNum >= info.RestrainNum))
     {
         CacheList<PrizeInfo> prizeList = PrizeHelper.GetPrizeInfo(info.Reward);
         foreach (PrizeInfo prize in prizeList)
         {
             UserTakePrize userTask = PrizeHelper.GetUserTake(prize, userID, info);
             new ShareCacheStruct<UserTakePrize>().Add(userTask);
         }
         if (fRest == null)
         {
             fRest = new FestivalRestrain();
             fRest.FestivalID = info.FestivalID;
             fRest.RefreashDate = info.StartDate;
             fRest.RestrainNum = 1;
             fRest.UserID = userID;
             cacheSet.Add(fRest);
         }
         else
         {
             fRest.RefreashDate = info.StartDate;
             fRest.RestrainNum = 1;
             //fRest.Update();
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 累计充值活动
 /// </summary>
 public static void FestivalPayCount(FestivalInfo info, GameUser user)
 {
     UserRecharge recharge = new GameDataCacheSet<UserRecharge>().FindKey(user.UserID);
     if (recharge == null)
         return;
     var cacheSet = new GameDataCacheSet<FestivalRestrain>();
     FestivalRestrain fRest = cacheSet.FindKey(user.UserID, info.FestivalID);
     if (fRest != null && fRest.RestrainNum >= 1 && fRest.RefreashDate == info.StartDate)
         return;
     if (recharge.FestivalDate >= info.StartDate
         && recharge.FestivalCount >= info.RestrainNum)
     {
         CacheList<PrizeInfo> prizeList = PrizeHelper.GetPrizeInfo(info.Reward);
         foreach (PrizeInfo prize in prizeList)
         {
             UserTakePrize userTask = PrizeHelper.GetUserTake(prize, user.UserID, info);
             new ShareCacheStruct<UserTakePrize>().Add(userTask);
         }
         if (fRest == null)
         {
             fRest = new FestivalRestrain();
             fRest.FestivalID = info.FestivalID;
             fRest.RefreashDate = info.StartDate;
             fRest.RestrainNum = 1;
             fRest.UserID = user.UserID;
             cacheSet.Add(fRest);
         }
         else
         {
             fRest.RefreashDate = info.StartDate;
             fRest.RestrainNum = 1;
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 活动限制次数
        /// </summary>
        /// <param name="info"></param>
        /// <param name="user"></param>
        /// <param name="maxNum"></param>
        /// <param name="festivalRestrain"></param>
        private static void GetFestivalRestrain(FestivalInfo info, GameUser user, int maxNum, int festivalID)
        {
            var cacheSet = new PersonalCacheStruct<FestivalRestrain>();
            FestivalRestrain festivalRestrain = cacheSet.FindKey(user.UserID, festivalID);
            if (festivalRestrain == null)
            {
                festivalRestrain = new FestivalRestrain()
                {
                    FestivalID = info.FestivalID,
                    UserID = user.UserID,
                    RestrainNum = 1,
                    RefreashDate = DateTime.Now
                };
                cacheSet.Add(festivalRestrain);
                festivalRestrain = cacheSet.FindKey(user.UserID, festivalID);
            }

            RestrainExtend extend = new RestrainExtend();
            extend.ID = maxNum;
            extend.Num = 1;
            if (festivalRestrain.UserExtend == null)
            {
                festivalRestrain.UserExtend = new CacheList<RestrainExtend>();
            }
            festivalRestrain.UserExtend.Add(extend);
            festivalRestrain.RestrainNum = MathUtils.Addition(festivalRestrain.RestrainNum, 1);
            //festivalRestrain.Update();

        }