/// <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 GameDataCacheSet<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> 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; } } }
/// <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; } } } }
/// <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); }
/// <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); } else { if (fRest.RefreashDate.Date != DateTime.Now.Date) { fRest.RestrainNum = 0; fRest.RefreashDate = DateTime.Now; } fRest.RestrainNum = MathUtils.Addition(fRest.RestrainNum, 1); } } }
/// <summary> /// 八月第二周活动 /// </summary> /// <param name="user"></param> public static int AugustSecondWeekEnergy(GameUser user) { int energyNum = 0; if (IsAugustSecondWeekEnergy(user)) { int festivalID = 0;// 1013; FestivalInfo festival = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID); if (festival != null) { short userLv = 0; if (user.UserLv >= 40) { userLv = 40; } FestivalRestrain restrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID, festivalID); PrizeInfo prizeInfo = new List<PrizeInfo>(festival.Reward).Find(m => m.UserLv == userLv); if (prizeInfo != null) { energyNum = prizeInfo.Num; user.EnergyNum = MathUtils.Addition(user.EnergyNum, (short)prizeInfo.Num, short.MaxValue); //user.Update(); if (restrain != null) { restrain.RestrainNum = user.UserLv; restrain.RefreashDate = DateTime.Now; //restrain.Update(); } else { var cacheSet = new PersonalCacheStruct<FestivalRestrain>(); restrain = new FestivalRestrain() { UserID = user.UserID, FestivalID = festivalID, RestrainNum = user.UserLv, RefreashDate = DateTime.Now, }; cacheSet.Add(restrain); } } } } return energyNum; }
/// <summary> /// 八月第二周活动 /// </summary> /// <param name="user"></param> public static void AugustSecondWeek(GameUser user) { int festivalID = 0;// 1014; int itemID = 0; var chatService = new TjxChatService(); FestivalInfo festival = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID); if (festival != null) { if (IsFestivalOpen(festivalID)) { string systemContent = string.Empty; FestivalRestrain restrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID, festivalID); List<PrizeInfo> prizeInfosArray = festival.Reward.ToList(); foreach (PrizeInfo reward in prizeInfosArray) { if (DateTime.Now.Date == reward.RefreshDate.Date) { if (reward.Type == RewardType.Item && UserHelper.IsBeiBaoFull(user)) break; if (reward.Type == RewardType.CrystalId && CrystalHelper.IsCrystalNumFull(user)) break; if (reward.Type == RewardType.CrystalId) { itemID = reward.ItemID; } else { itemID = reward.ItemID; } if (restrain != null && restrain.RefreashDate.Date != DateTime.Now.Date) { if (restrain.RefreashDate.Date != DateTime.Now.Date) { restrain.RestrainNum = 1; restrain.RefreashDate = DateTime.Now; //restrain.Update(); } systemContent = ActivitiesAward.GameUserUniversalNocite(user.UserID, reward.Type, itemID, reward.Num, LanguageManager.GetLang().St_AugustSecondWeek); break; } else if (restrain == null) { var cacheSet = new PersonalCacheStruct<FestivalRestrain>(); restrain = new FestivalRestrain() { UserID = user.UserID, FestivalID = 1014, RestrainNum = 1, RefreashDate = DateTime.Now, }; cacheSet.Add(restrain); systemContent = ActivitiesAward.GameUserUniversalNocite(user.UserID, reward.Type, itemID, reward.Num, LanguageManager.GetLang().St_AugustSecondWeek); break; } } } if (!string.IsNullOrEmpty(systemContent)) { chatService.SystemSendWhisper(user, systemContent); } } } }
/// <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(); }
/// <summary> /// 渠道登录领好礼类型活动 /// </summary> /// <param name="user"></param> public static void RetailLoginDaysReceive(GameUser user) { var chatService = new TjxChatService(); var festivalInfosArray = new ShareCacheStruct<FestivalInfo>().FindAll(m => m.FestivalType == FestivalType.RetailLogin); foreach (FestivalInfo info in festivalInfosArray) { bool isChange = false; if (IsFestivalOpen(info.FestivalID)) { FestivalRestrain restrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID, info.FestivalID); var rewardsArray = info.Reward; foreach (PrizeInfo reward in rewardsArray) { if (reward.RetailID == user.RetailID && restrain == null) { ActivitiesAward.GameUserRewardNocite(user.UserID, reward.Type, reward.ItemID, reward.Num, reward.CrystalType); isChange = true; } } if (isChange && info.TaskConfig.Count > 0) { foreach (TaskConfigInfo configInfo in info.TaskConfig) { chatService.SystemSendWhisper(user, configInfo.Desc); if (restrain == null) { restrain = new FestivalRestrain() { UserID = user.UserID, FestivalID = info.FestivalID, RefreashDate = DateTime.Now, RestrainNum = 1, }; new PersonalCacheStruct<FestivalRestrain>().Add(restrain); } } } } } }
/// <summary> /// 登录领好礼类型活动 /// </summary> /// <param name="user"></param> public static void LoginDaysReceive(GameUser user) { var festivalInfosArray = new ShareCacheStruct<FestivalInfo>().FindAll(m => m.FestivalType == FestivalType.LoginReceive); foreach (FestivalInfo info in festivalInfosArray) { if (IsFestivalOpen(info.FestivalID)) { var cacheSet = new PersonalCacheStruct<FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(user.UserID, info.FestivalID); if (fRest == null || fRest.RefreashDate < info.StartDate || (fRest.RefreashDate.Date != DateTime.Now.Date && fRest.RefreashDate >= info.StartDate && fRest.RefreashDate <= info.EndDate)) { List<PrizeInfo> prizeList = PrizeHelper.GetPrizeInfo(info.Reward).ToList(); foreach (PrizeInfo prize in prizeList) { if (prize.RefreshDate.Date == DateTime.Now.Date) { 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 = DateTime.Now; fRest.RestrainNum = 1; fRest.UserID = user.UserID; cacheSet.Add(fRest); } else { fRest.RestrainNum = 1; fRest.RefreashDate = DateTime.Now; } } } } }
/// <summary> /// 普通副本类型活动(获得遗失的月饼配方) /// </summary> /// <param name="user"></param> public static void NormalCountReceive(GameUser user) { int dailyNum = 0; var chatService = new TjxChatService(); var festivalInfosArray = new ShareCacheStruct<FestivalInfo>().FindAll(m => m.FestivalType == FestivalType.NormalCount); foreach (FestivalInfo info in festivalInfosArray) { if (IsFestivalOpen(info.FestivalID)) { FestivalRestrainNum(user.UserID, info.FestivalID); FestivalRestrain festivalRestrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID, info.FestivalID); if (festivalRestrain != null && festivalRestrain.RefreashDate.Date == DateTime.Now.Date) { dailyNum = festivalRestrain.RestrainNum; } if (info.RestrainNum > dailyNum && info.TaskConfig != null) { List<TaskConfigInfo> configInfos = info.TaskConfig.ToList(); foreach (TaskConfigInfo configInfo in configInfos) { if (RandomUtils.IsHit(configInfo.probability)) { UserItemHelper.AddUserItem(user.UserID, configInfo.item, configInfo.Num); if (info.FestivalExtend != null) { chatService.SystemSend(ChatType.World, string.Format(info.FestivalExtend.Desc, user.NickName)); } if (festivalRestrain != null) { festivalRestrain.RestrainNum = MathUtils.Addition(festivalRestrain.RestrainNum, 1); //festivalRestrain.Update(); } else { var cacheSet = new PersonalCacheStruct<FestivalRestrain>(); festivalRestrain = new FestivalRestrain() { FestivalID = info.FestivalID, UserID = user.UserID, RestrainNum = 1, RefreashDate = DateTime.Now }; cacheSet.Add(festivalRestrain); } } } } } } }
/// <summary> /// 竞技场连胜活动 /// </summary> public static void SportVictoryNum(GameUser user, int festivalID, int victoryNum) { if (IsFestivalOpen(festivalID)) { var chatService = new TjxChatService(); FestivalStop(user.UserID, festivalID); FestivalRestrain festivalRestrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID, festivalID); int restrainNm = 0; if (festivalRestrain != null) { restrainNm = festivalRestrain.RestrainNum; } FestivalInfo festivalInfo = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID); if (festivalInfo != null && festivalInfo.Reward.Count > 0) { List<PrizeInfo> prizeInfosList = new List<PrizeInfo>(festivalInfo.Reward); List<PrizeInfo> prizeInfosArray = prizeInfosList.FindAll(m => m.WinNum <= victoryNum && m.WinNum > restrainNm); if (prizeInfosArray.Count > 0) { foreach (PrizeInfo info in prizeInfosArray) { chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().SportVictoryReward, user.NickName, info.WinNum, SportVictoryReward(user, info))); } if (festivalRestrain == null) { var cacheSet = new PersonalCacheStruct<FestivalRestrain>(); festivalRestrain = new FestivalRestrain() { UserID = user.UserID, FestivalID = festivalID, RefreashDate = DateTime.Now, RestrainNum = victoryNum }; cacheSet.Add(festivalRestrain); } else { festivalRestrain.RestrainNum = victoryNum; festivalRestrain.RefreashDate = DateTime.Now; //festivalRestrain.Update(); } } } } }
/// <summary> /// 中元节变身活动功能 /// </summary> /// <param name="userid"></param> /// <param name="chatContent"></param> public static void WingZhongYuanFestival(GameUser user, string chatContent) { int festivalID = 0;// 1019; FestivalInfo festival = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID); if (festival != null && festival.FestivalExtend != null) { if (chatContent.IndexOf(festival.FestivalExtend.KeyWord) != -1) { FestivalRestrain restrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID); if (restrain == null) { List<PrizeInfo> prizeInfosArray = festival.Reward.ToList(); double[] probability = new double[prizeInfosArray.Count]; for (int i = 0; i < prizeInfosArray.Count; i++) { probability[i] = (double)prizeInfosArray[i].Probability; } int index2 = RandomUtils.GetHitIndex(probability); PrizeInfo prizeInfo = prizeInfosArray[index2]; if (prizeInfo != null) { var cacheSet = new PersonalCacheStruct<UserProps>(); UserProps props = cacheSet.FindKey(user.UserID, prizeInfo.ItemID); if (props != null && !IsFestivalOpen(festivalID)) { cacheSet.Delete(props); } else if (props == null && IsFestivalOpen(festivalID)) { props = new UserProps(user.UserID, prizeInfo.ItemID) { ChangeTime = festival.StartDate, SurplusNum = 0 }; cacheSet.Add(props); restrain = new FestivalRestrain() { UserID = user.UserID, FestivalID = festivalID, RefreashDate = DateTime.Now, RestrainNum = 1 }; new PersonalCacheStruct<FestivalRestrain>().Add(restrain); } } } } } }
/// <summary> /// 触发七夕翅膀活动功能 /// </summary> /// <param name="userid"></param> /// <param name="chatContent"></param> public static void WingFestival(string userid, string chatContent) { int festivalID = 0;// 1017; FestivalInfo festival = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID); if (festival != null) { if (festival.FestivalExtend != null) { if (chatContent.IndexOf(festival.FestivalExtend.KeyWord) != -1) { FestivalRestrain restrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(userid); if (restrain == null) { var cacheSet = new PersonalCacheStruct<FestivalRestrain>(); restrain = new FestivalRestrain() { UserID = userid, FestivalID = festivalID, RefreashDate = DateTime.Now, RestrainNum = 1 }; cacheSet.Add(restrain); } } } } }
/// <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(); } } }
private static void CheckFestivalRestrain(string userid, int festivalID) { var cacheSet = new PersonalCacheStruct<FestivalRestrain>(); FestivalRestrain restrain = cacheSet.FindKey(userid, festivalID); if (restrain != null) { if (restrain.RefreashDate.Date != DateTime.Now.Date) { if (restrain.RefreashDate.Date != DateTime.Now.Date) { restrain.RefreashDate = DateTime.Now; restrain.RestrainNum = 0; //restrain.Update(); } } } else { restrain = new FestivalRestrain() { UserID = userid, FestivalID = festivalID, RestrainNum = 0, RefreashDate = DateTime.Now }; cacheSet.Add(restrain); } }
/// <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, GameEnvironment.CacheUserPeriod); } } } }
/// <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); } } } }