Ejemplo n.º 1
0
        /// <summary>
        ///vip活动礼包
        /// </summary>
        public static void GetVipFestival(string userID)
        {
            FestivalInfo info = GetInfo(FestivalType.VIPFestival);

            if (info != null && info.FestivalExtend != null)
            {
                var cacheSet           = new GameDataCacheSet <FestivalRestrain>();
                FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID);
                if (fRest == null || fRest.RefreashDate < info.StartDate ||
                    (fRest.RestrainNum < info.RestrainNum && fRest.RefreashDate >= info.StartDate &&
                     fRest.RefreashDate <= info.EndDate))
                {
                    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 = DateTime.Now;
                        fRest.RestrainNum  = 1;
                        fRest.UserID       = userID;
                        cacheSet.Add(fRest);
                    }
                    else
                    {
                        fRest.RestrainNum  = MathUtils.Addition(fRest.RestrainNum, 1);
                        fRest.RefreashDate = DateTime.Now;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取配置信息
 /// </summary>
 /// <param name="itemInfo"></param>
 /// <returns></returns>
 public static List <PrizeInfo> GetPrizeInfo(ItemBaseInfo itemInfo)
 {
     if (itemInfo.ItemPack == null || itemInfo.ItemPack.Count <= 0)
     {
         return(null);
     }
     return(PrizeHelper.GetPrizeInfo(itemInfo.ItemPack).ToList());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 累计消费活动奖励(晶石,金币,精力)
        /// </summary>
        private static void FestivalConsumeCount(FestivalInfo info, string userID)
        {
            UserConsume consume = new PersonalCacheStruct <UserConsume>().FindKey(userID);

            if (consume == null)
            {
                return;
            }
            var cacheSet           = new PersonalCacheStruct <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.º 4
0
        /// <summary>
        /// 累计充值活动
        /// </summary>
        public static void FestivalPayCount(FestivalInfo info, GameUser user)
        {
            UserRecharge recharge = new PersonalCacheStruct <UserRecharge>().FindKey(user.UserID);

            if (recharge == null)
            {
                return;
            }
            var cacheSet           = new PersonalCacheStruct <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.º 5
0
        /// <summary>
        /// 日常活动领取
        /// </summary>
        /// <param name="user"></param>
        /// <param name="festivalID"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static bool UseFestivalRestrain(GameUser user, int festivalID, out string content)
        {
            content = string.Empty;
            FestivalInfo     info      = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);
            var              cacheSet  = new PersonalCacheStruct <FestivalRestrain>();
            FestivalRestrain restrain  = cacheSet.FindKey(user.UserID, festivalID);
            short            isReceive = FestivalIsReceive(user, festivalID);

            if (info != null && isReceive == 1)
            {
                if (info.FestivalType == FestivalType.UpgradeGiveGift && user.UserLv < info.RestrainNum)
                {
                    content = LanguageManager.GetLang().St_LevelNotEnough;
                    return(false);
                }
                if (info.FestivalType == FestivalType.FirstReward ||
                    info.FestivalType == FestivalType.UpgradeGiveGift || info.FestivalType == FestivalType.PayAccumulation)
                {
                    content = PrizeHelper.PrizeContent(user, info.Reward.ToList());
                    if (!string.IsNullOrEmpty(content))
                    {
                        return(false);
                    }
                    content = PrizeHelper.GetPrizeUserTake(user, info.Reward.ToList());
                    if (!string.IsNullOrEmpty(content))
                    {
                        if (info.FestivalExtend != null && !string.IsNullOrEmpty(info.FestivalExtend.Desc))
                        {
                            content = string.Format(info.FestivalExtend.Desc, content);
                        }
                        return(true);
                    }
                }
                if (restrain != null && (info.FestivalType == FestivalType.PayReward || info.FestivalType == FestivalType.FirstPayDoubleSpar))
                {
                    if (info.FestivalExtend != null)
                    {
                        int payNum = (info.RestrainNum * info.FestivalExtend.MinusNum).ToInt();
                        user.GiftGold = MathUtils.Addition(user.GiftGold, payNum);
                        if (!string.IsNullOrEmpty(info.FestivalExtend.Desc))
                        {
                            content = string.Format(info.FestivalExtend.Desc, payNum);
                        }
                        return(true);
                    }
                }
                if (info.FestivalType == FestivalType.LoginGiveGift)
                {
                    List <PrizeInfo> prizeList = info.Reward.FindAll(s => s.RefreshDate.Date == DateTime.Now.Date);
                    content = PrizeHelper.GetPrizeUserTake(user, prizeList);
                    if (!string.IsNullOrEmpty(content))
                    {
                        if (info.FestivalExtend != null && !string.IsNullOrEmpty(info.FestivalExtend.Desc))
                        {
                            content = string.Format(info.FestivalExtend.Desc, content);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }