/// <summary> /// 副本倍数掉落活动限制次数 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static void DuplicateDropDoubleRestrain(string userID) { int multiple = 1; FestivalInfo info = GetInfo(FestivalType.DuplicateDropDouble); if (info != null && info.FestivalExtend != null) { var cacheSet = new GameDataCacheSet <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null) { fRest = new FestivalRestrain(); fRest.UserID = userID; fRest.FestivalID = info.FestivalID; fRest.RefreashDate = DateTime.Now; fRest.RestrainNum = 1; cacheSet.Add(fRest, GameEnvironment.CacheUserPeriod); } else { if (fRest.RefreashDate.Date != DateTime.Now.Date) { fRest.RestrainNum = 0; fRest.RefreashDate = DateTime.Now; } fRest.RestrainNum = MathUtils.Addition(fRest.RestrainNum, 1); } } }
/// <summary> ///vip活动礼包 /// </summary> public static void GetVipFestival(string userID) { FestivalInfo info = GetInfo(FestivalType.VIPFestival); if (info != null && info.FestivalExtend != null) { var cacheSet = new PersonalCacheStruct <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; } } } }
/// <summary> /// 购买精力限制次数 /// </summary> /// <param name="userID"></param> /// <param name="festivalType"></param> /// <param name="typeID"></param> public static void PurchasedEnergy(string userID) { FestivalInfo info = GetInfo(FestivalType.PurchasedEnergy); if (info != null) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null) { fRest = new FestivalRestrain(); fRest.FestivalID = info.FestivalID; fRest.RefreashDate = DateTime.Now; fRest.RestrainNum = 1; fRest.UserID = userID; cacheSet.Add(fRest); } else { if (DateTime.Now.Date == fRest.RefreashDate.Date) { fRest.RestrainNum = MathUtils.Addition(fRest.RestrainNum, 1); } else { fRest.RestrainNum = 1; } fRest.RefreashDate = DateTime.Now; } } }
/// <summary> /// 升级送好礼 /// </summary> /// <param name="userID"></param> public static void GetUpgradeGiveGift(string userID, short userLv) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); var festivalList = new ShareCacheStruct <FestivalInfo>().FindAll(s => s.FestivalType == FestivalType.UpgradeGiveGift); foreach (var info in festivalList) { if (!info.IsStop) { continue; } if (info.StartDate > DateTime.Now) { continue; } if (info.EndDate < DateTime.Now) { continue; } FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null && info.RestrainNum <= userLv) { AppendFestivalRestrain(userID, info.FestivalID, info.RestrainNum); } } }
/// <summary> /// 副本倍数掉落活动限制次数 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static void DuplicateDropDoubleRestrain(string userID) { FestivalInfo info = GetInfo(FestivalType.DuplicateDropDouble); if (info != null && info.FestivalExtend != null) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null) { fRest = new FestivalRestrain(); fRest.UserID = userID; fRest.FestivalID = info.FestivalID; fRest.RefreashDate = DateTime.Now; fRest.RestrainNum = 1; cacheSet.Add(fRest); } else { if (fRest.RefreashDate.Date != DateTime.Now.Date) { fRest.RestrainNum = 0; fRest.RefreashDate = DateTime.Now; } fRest.RestrainNum = MathUtils.Addition(fRest.RestrainNum, 1); } } }
/// <summary> /// 累计消费送礼 /// </summary> public static void PayAccumulation(string userID, int consumeNum) { FestivalInfo fest = GetInfo(FestivalType.PayAccumulation); if (fest == null) { return; } var cacheSet = new PersonalCacheStruct <UserConsume>(); UserConsume userConsume = cacheSet.FindKey(userID); if (userConsume == null) { userConsume = new UserConsume(); userConsume.UserID = userID; userConsume.GameCoin = 0; userConsume.GoldNum = 0; userConsume.EnergyNum = 0; cacheSet.Add(userConsume); cacheSet.Update(); userConsume = new PersonalCacheStruct <UserConsume>().FindKey(userID); } if (userConsume.GoldDate < fest.StartDate) { userConsume.GoldDate = fest.StartDate; userConsume.GoldNum = consumeNum; } else { userConsume.GoldNum = MathUtils.Addition(userConsume.GoldNum, consumeNum); } var cacheSetRestrain = new PersonalCacheStruct <FestivalRestrain>(); var festivalList = new ShareCacheStruct <FestivalInfo>().FindAll(s => s.FestivalType == FestivalType.PayAccumulation); foreach (var info in festivalList) { if (!info.IsStop) { continue; } if (info.StartDate > DateTime.Now) { continue; } if (info.EndDate < DateTime.Now) { continue; } if (info.FestivalType == FestivalType.PayAccumulation) { FestivalRestrain fRest = cacheSetRestrain.FindKey(userID, info.FestivalID); if (fRest != null && userConsume.GoldNum >= info.RestrainNum) { AppendFestivalRestrain(userID, fest.FestivalID, fest.RestrainNum); } } } }
/// <summary> /// 假日狂欢活动--竞技场幸运数字七 /// </summary> /// <param name="userID"></param> public static void HolidayFestival(string userID) { GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID); int festivalID = 0;// 1004; FestivalRestrain restrain = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festivalID); if (restrain != null) { if (restrain.RefreashDate.Date != DateTime.Now.Date) { restrain.RestrainNum = 0; restrain.RefreashDate = DateTime.Now; } } var chatService = new TjxChatService(); FestivalInfo festival = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID); if (festival != null) { List <PrizeInfo> rewardsArray = festival.Reward.ToList(); if (NoviceHelper.IsFestivalOpen(festivalID)) { if (restrain != null && restrain.RestrainNum <= festival.RestrainNum) { restrain.RestrainNum = MathUtils.Addition(restrain.RestrainNum, 1, int.MaxValue); restrain.RefreashDate = DateTime.Now; //restrain.Update(); foreach (PrizeInfo reward in rewardsArray) { GameUserReward(userID, reward.Type, reward.ItemID, reward.Num); } if (userInfo != null) { chatService.SystemSendWhisper(userInfo, LanguageManager.GetLang().St_HolidayFestival); } } else if (restrain == null) { foreach (PrizeInfo reward in rewardsArray) { GameUserReward(userID, reward.Type, reward.ItemID, reward.Num); } if (userInfo != null) { chatService.SystemSendWhisper(userInfo, LanguageManager.GetLang().St_HolidayFestival); } restrain = new FestivalRestrain { UserID = userID, FestivalID = festivalID, RefreashDate = DateTime.Now, RestrainNum = 1, }; new GameDataCacheSet <FestivalRestrain>().Add(restrain); } } } }
/// <summary> /// 增加活动未领取活动 /// </summary> /// <param name="userID"></param> /// <param name="festivalID"></param> public static void AppendFestivalRestrain(string userID, int festivalID, int reNum) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = new FestivalRestrain(); fRest.UserID = userID; fRest.FestivalID = festivalID; fRest.RefreashDate = DateTime.Now; fRest.RestrainNum = reNum; fRest.IsReceive = false; cacheSet.Add(fRest); }
/// <summary> /// 增加活动未领取活动 /// </summary> /// <param name="userID"></param> /// <param name="festivalID"></param> public static void AppendFestivalRestrain(string userID, int festivalID, int reNum) { var cacheSet = new GameDataCacheSet <FestivalRestrain>(); FestivalRestrain fRest = new FestivalRestrain(); fRest.UserID = userID; fRest.FestivalID = festivalID; fRest.RefreashDate = DateTime.Now; fRest.RestrainNum = reNum; fRest.IsReceive = false; cacheSet.Add(fRest, GameEnvironment.CacheUserPeriod); }
/// <summary> /// 七夕、端午节奖励 /// </summary> public static void DragonBoatFestival(string userID, int festivalID) { GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID); FestivalRestrain restrain = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festivalID); FestivalInfo festival = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID); var chatService = new TjxChatService(); if (festival != null) { CacheList <PrizeInfo> rewardsArray = festival.Reward; if (NoviceHelper.IsFestivalOpen(festivalID)) { if (restrain != null && restrain.RestrainNum <= festival.RestrainNum) { restrain.RestrainNum = MathUtils.Addition(restrain.RestrainNum, 1, int.MaxValue); restrain.RefreashDate = DateTime.Now; //restrain.Update(); foreach (PrizeInfo reward in rewardsArray) { GameUserReward(userID, reward.Type, reward.ItemID, reward.Num); } if (userInfo != null && festival.FestivalExtend != null) { chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc); } } else if (restrain == null) { foreach (PrizeInfo reward in rewardsArray) { GameUserReward(userID, reward.Type, reward.ItemID, reward.Num); } if (userInfo != null && festival.FestivalExtend != null) { chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc); } restrain = new FestivalRestrain { UserID = userID, FestivalID = festivalID, RefreashDate = DateTime.Now, RestrainNum = 1, }; new GameDataCacheSet <FestivalRestrain>().Add(restrain); } } } }
/// <summary> /// 副本倍数掉落活动 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static int DuplicateDropDouble(string userID) { int multiple = 1; FestivalInfo info = GetInfo(FestivalType.DuplicateDropDouble); if (info != null && info.FestivalExtend != null && info.FestivalExtend.MinusNum > 0) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null || fRest.RefreashDate.Date != DateTime.Now.Date || fRest.RestrainNum < info.RestrainNum) { multiple = info.FestivalExtend.MinusNum.ToInt(); } } return(multiple); }
/// <summary> /// 购买精力,庄园加成 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static double SurplusPurchased(string userID, FestivalType festivalType) { double addNum = 1; FestivalInfo info = GetInfo(festivalType); if (info != null && info.FestivalExtend != null && info.FestivalExtend.MinusNum > 0) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null || fRest.RefreashDate < info.StartDate || (fRest.RefreashDate >= info.StartDate && fRest.RefreashDate <= info.EndDate)) { addNum = info.FestivalExtend.MinusNum; } } return(addNum); }
/// <summary> /// 根据类型获取活动奖励 首充奖励、登入送好礼 /// </summary> /// <param name="userID"></param> /// <param name="type"></param> public static void GetFirstReward(string userID, FestivalType type) { FestivalInfo info = GetInfo(type); if (info != null && info.FestivalExtend != null) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null) { AppendFestivalRestrain(userID, info.FestivalID, 1); //if (PrizeHelper.GetUserMail(userID, info)) //{ //} } } }
/// <summary> /// 活动剩余次数 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static int SurplusEnergyNum(string userID) { int surplusNum = 0; FestivalInfo info = GetInfo(FestivalType.PurchasedEnergy); if (info != null && info.FestivalExtend != null && info.FestivalExtend.MinusNum > 0) { surplusNum = info.RestrainNum; var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest != null && fRest.RefreashDate.Date == DateTime.Now.Date) { surplusNum = MathUtils.Subtraction(surplusNum, fRest.RestrainNum, 0); } } return(surplusNum); }
/// <summary> /// 充值获得奖励 首次充值晶石翻倍、充值返利 /// </summary> /// <param name="user"></param> /// <param name="payNum"></param> /// <param name="type"></param> public static void GetPayReward(GameUser user, int payNum, FestivalType type) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); var festivalList = new ShareCacheStruct <FestivalInfo>().FindAll(s => s.FestivalType == type); foreach (var info in festivalList) { if (!info.IsStop) { continue; } if (info.StartDate > DateTime.Now) { continue; } if (info.EndDate < DateTime.Now) { continue; } if (info.FestivalType == type) { if (info.FestivalExtend != null) { FestivalRestrain fRest = cacheSet.FindKey(user.UserID, info.FestivalID); UserRecharge userRecharge = new PersonalCacheStruct <UserRecharge>().FindKey(user.UserID); if (type == FestivalType.PayReward) { if (fRest == null && userRecharge != null && userRecharge.TotalGoldNum >= info.RestrainNum) { AppendFestivalRestrain(user.UserID, info.FestivalID, info.RestrainNum); } } else { if (fRest == null && payNum >= info.RestrainNum) { AppendFestivalRestrain(user.UserID, info.FestivalID, payNum); } } } } } }
/// <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(); } } }
/// <summary> /// 活动有效次数 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static int FestivalSurplusNum(string userID, int festID) { int surplusNum = 0; FestivalInfo info = new ShareCacheStruct <FestivalInfo>().FindKey(festID); if (info != null && info.RestrainNum > 0) { surplusNum = info.RestrainNum; if (info.FestivalType == FestivalType.UpgradeGiveGift) { return(surplusNum); } var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest != null && fRest.RefreashDate.Date == DateTime.Now.Date) { surplusNum = MathUtils.Subtraction(surplusNum, fRest.RestrainNum, 0); } } return(surplusNum); }
/// <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; } } }
/// <summary> /// 登入送好礼 /// </summary> /// <param name="userID"></param> /// <param name="type"></param> public static void GetLoginGainReward(string userID, FestivalType type) { FestivalInfo info = GetInfo(type); if (info != null && info.FestivalExtend != null) { var cacheSet = new PersonalCacheStruct <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null) { AppendFestivalRestrain(userID, info.FestivalID, 1); } else { var prizeList = info.Reward.FindAll(s => s.RefreshDate.Date == DateTime.Now.Date); if (fRest.RefreashDate.Date != DateTime.Now.Date && prizeList.Count > 0) { fRest.RefreashDate = DateTime.Now; fRest.IsReceive = false; } } } }
/// <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); }