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); }
public override void BuildPacket() { PushIntoStack(bossPlotID); PushIntoStack(_guild == null ? (short)0 : _guild.GuildBossInfo.BossLv); PushIntoStack(_guild == null ? 0 : _guild.ColdTime); PushIntoStack(_regNum); PushIntoStack(_guild == null ? (short)0 : _guild.CombatStatus.ToShort()); PushIntoStack((_inspirePercent * 100).ToInt()); PushIntoStack(_reLiveNum); PushIntoStack(_bossUserList.Count); foreach (BossUser bossUser in _bossUserList) { DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack(bossUser.NickName.ToNotNullString()); UserGeneral userGeneral = UserGeneral.GetMainGeneral(bossUser.UserId); dsItem.PushIntoStack(userGeneral == null ? string.Empty : userGeneral.HeadID.ToNotNullString()); dsItem.PushIntoStack(bossUser.IsRelive ? 0 : 1); dsItem.PushIntoStack(bossUser.CodeTime); dsItem.PushIntoStack(NoviceHelper.IsWingFestivalInfo(bossUser.UserId) ? (short)1 : (short)0); dsItem.PushIntoStack(0); PushIntoStack(dsItem); } PushIntoStack((_reliveInspirePercent * 100).ToInt()); }
/// <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); } } } }
public override bool TakeAction() { if (_chatType == ChatType.Guild && string.IsNullOrEmpty(ContextUser.MercenariesID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9203_ChaTypeNotGuildMember; return(false); } //查找背包中的聊天道具 var chatLeng = ConfigEnvSet.GetInt("Chat.ContentLeng"); int chatItemId = ConfigEnvSet.GetInt("UserItem.ChatItemID"); int charItemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, chatItemId); //判断是否有聊天道具 if (charItemNum <= 0) { ErrorCode = 3; ErrorInfo = LanguageManager.GetLang().St9203_ItemEmpty; return(false); } if (_content.IndexOf("<label") >= 0 || _content.IndexOf("<image") >= 0) { chatLeng += 150; } if (_content.Trim().Length == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9201_contentNotEmpty; return(false); } //LogHelper.WriteError(string.Format("contentLength={0};length={1};content={2}", _content.Length, chatLeng, _content)); if (_content.Length >= chatLeng) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9201_TheInputTextTooLong; return(false); } if (!TjxChatService.IsAllow(ContextUser, _chatType)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9203_ChatNotSend; return(false); } NoviceHelper.WingFestival(ContextUser.UserID, _content); NoviceHelper.WingZhongYuanFestival(ContextUser, _content); //使用聊天道具 UserItemHelper.UseUserItem(ContextUser.UserID, chatItemId, 1); var chatService = new TjxChatService(ContextUser); chatService.Send(_chatType, _content); return(true); }
public override bool TakeAction() { var noviceActivitiesArray = new ShareCacheStruct <NoviceActivities>().FindAll(); foreach (NoviceActivities novice in noviceActivitiesArray) { _noviceList = NoviceHelper.GetNoviceList(ContextUser.UserID, novice.ID); } return(true); }
public override bool TakeAction() { int expNum; if (NoviceHelper.DailyExpPrize(ContextUser, out expNum)) { ErrorInfo = string.Format(LanguageManager.GetLang().St1018_ExpObtainPrize, expNum); } return(true); }
public override bool TakeAction() { int giftGold = 0; int giftCoin = ConfigEnvSet.GetInt("Novice.LoginPrizeGameCoin"); if (NoviceHelper.LoginPrize(ContextUser, out giftGold)) { ErrorInfo = string.Format(LanguageManager.GetLang().St1014_JingshiPrize, giftGold, giftCoin); } return(true); }
/// <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); } } } }
public override void BuildPacket() { PushIntoStack(cityInfo == null ? string.Empty : cityInfo.CityName.ToNotNullString()); PushIntoStack(gameUserArray.Count); foreach (GameUser user in gameUserArray) { UserGeneral uGeneral = UserGeneral.GetMainGeneral(user.UserID); string HeadID = string.Empty; if (uGeneral != null) { CareerInfo careerInfo = new ShareCacheStruct <CareerInfo>().FindKey(uGeneral.CareerID); HeadID = user.Sex ? careerInfo.HeadID2 : careerInfo.HeadID; } UserGuild userGuild = new ShareCacheStruct <UserGuild>().FindKey(user.MercenariesID); string pictureID = string.Empty; //原因:排除月饼和双倍材料卡 List <UserProps> propsArray = new PersonalCacheStruct <UserProps>().FindAll(user.UserID, u => u.PropType == 3 && u.ItemID != 5200 && u.ItemID != 7003); if (propsArray.Count > 0 && propsArray[0].DoRefresh() > 0) { ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(propsArray[0].ItemID); if (itemInfo != null) { pictureID = itemInfo.PictrueID; } } else { pictureID = string.Empty; } DataStruct ds = new DataStruct(); ds.PushIntoStack(user.UserID.ToNotNullString()); ds.PushIntoStack(user.NickName.ToNotNullString()); ds.PushIntoStack(HeadID.ToNotNullString()); ds.PushIntoStack(user.MercenariesID.ToNotNullString()); ds.PushIntoStack(userGuild == null ? string.Empty : userGuild.GuildName.ToNotNullString()); ds.PushIntoStack((short)user.UserStatus); ds.PushIntoStack(user.PointX); ds.PushIntoStack(user.PointY); ds.PushIntoStack(pictureID.ToNotNullString()); ds.PushIntoStack(NoviceHelper.IsWingFestivalInfo(user.UserID) ? (short)1 : (short)0); ds.PushIntoStack(0); PushIntoStack(ds); } }
public override bool TakeAction() { if (NoviceHelper.IsFestivalOpen(festivalID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().ZhongYuanHuodong; return(false); } var package = UserItemPackage.Get(Uid); UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID)); if (userItem != null) { ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID); if (itemInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; //ErrorInfo = LanguageManager.GetLang().St1107_UserItemNotEnough; return(false); } if (userItem.ItemID == 7003 || userItem.ItemID == 5200) { //双倍材料掉落卡 if (!DoCaiLiaoYueBingItem(userItem, itemInfo)) { return(false); } } else { //其他类型的道具 if (!UseProps(ContextUser.UserID, itemInfo)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1608_CombatPowerNotEnough; return(false); } } PictureID = itemInfo.PictrueID; UserItemHelper.UseUserItem(ContextUser.UserID, userItem.ItemID, 1); } return(true); }
public override bool TakeAction() { if (ops == 1) { short onlineEnergy; if (NoviceHelper.OnlinePrize(ContextUser, out _takeNum, out _coldTime, out onlineEnergy)) { ErrorInfo = string.Format(LanguageManager.GetLang().St1013_JingliPrize, onlineEnergy); } } else if (ops == 2) { if (NoviceHelper.DailyEnergy(ContextUser.UserID)) { UserDailyRestrain dailyRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID); if (dailyRestrain != null) { short dailyEnergyNum = (short)ConfigEnvSet.GetInt("DailyEnergyNum"); if (dailyRestrain.Funtion15.Date != DateTime.Now) { dailyRestrain.Funtion15 = DateTime.Now; //dailyRestrain.Update(); ContextUser.SurplusEnergy = dailyEnergyNum; //ContextUser.Update(); ErrorInfo = string.Format(LanguageManager.GetLang().St1013_DailyJingliPrize, dailyEnergyNum); } } } } else if (ops == 3) { int festivalEnergy = NoviceHelper.AugustSecondWeekEnergy(ContextUser); ErrorInfo = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, LanguageManager.GetLang().St_AugustSecondWeek, string.Format(LanguageManager.GetLang().St_EnergyNum, festivalEnergy)); } return(true); }
/// <summary> /// 假日狂欢活动通关获得金币 /// </summary> /// <param name="userID"></param> /// <param name="plotID"></param> public static void GetHolidayFestivalReward(string userID, int plotID) { var chatService = new TjxChatService(); int festivalID = 0;// 1003; FestivalInfo festival = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID); if (festival != null) { GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID); PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(plotID); if (plotInfo != null) { TimePriod priod = festival.TimePriod; if (NoviceHelper.IsFestivalOpen(festivalID)) { DateTime priodStart = DateTime.Parse(DateTime.Now.ToString("d") + " " + priod.Start.ToString("T")); DateTime priodEnd = DateTime.Parse(DateTime.Now.ToString("d") + " " + priod.End.ToString("T")); if (priodStart <= DateTime.Now && DateTime.Now < priodEnd) { if (RandomUtils.IsHit(plotInfo.FestivalProbability)) { List <FestivalReward> rewardsArray = plotInfo.FestivalReward.ToList(); double[] probability = new double[rewardsArray.Count]; for (int i = 0; i < rewardsArray.Count; i++) { probability[i] = rewardsArray[i].Probability; } int index2 = RandomUtils.GetHitIndex(probability); int itemID = rewardsArray[index2].Item; UserItemHelper.AddUserItem(userID, itemID, 1); ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemID); if (userInfo != null && itemInfo != null) { string content = string.Empty; if (itemID == 5008) { content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName); chatService.SystemSendWhisper(userInfo, content); } else if (itemID == 5009) { content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName); chatService.SystemSendWhisper(userInfo, content); } else if (itemID == 5010) { content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName); chatService.SystemSendWhisper(userInfo, content); } else if (itemID == 5011) { content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGoinGift, userInfo.NickName); new TjxChatService().SystemSend(ChatType.World, content); } } } } } } } }
public static string HuntingLife(GameUser user, out string errStr) { #region errStr = string.Empty; int huntingID = UserLightLit(user.UserID); int huntingID2 = UserNextLight(user.UserID, huntingID); UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(user.UserID); var probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(errStr); } ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2); if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { if (probabilityInfo.Price > user.GameCoin) { errStr = LanguageManager.GetLang().St_GameCoinNotEnough; return(errStr); } } //暑期第三弹 if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(user)) { errStr = LanguageManager.GetLang().St1305_BeiBaoBackpackFull; return(errStr); } var lightCacheSet = new PersonalCacheStruct <UserLight>(); if (huntingID != 1001) { UserLight userLight1 = lightCacheSet.FindKey(user.UserID, huntingID); if (userLight1.IsLight == 2) { return(string.Empty); } if (userLight1.IsLight == 1) { userLight1.IsLight = 2; } } UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(user.UserID, huntingID2); if (RandomUtils.IsHit(probability1.Light)) { if (userLight != null) { userLight.IsLight = 1; if (userLight.HuntingID == 1005) { errStr = LanguageManager.GetLang().St1305_HuntingIDLight; } } else { userLight = new UserLight() { UserID = user.UserID, HuntingID = huntingID2, IsLight = 1 }; lightCacheSet.Add(userLight); } } if (userRestrain != null) { if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0); } else { userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue); } } else { user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0); } //每种品质的概率 double[] probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red }; int index2 = RandomUtils.GetHitIndex(probabilityArray2); CrystalQualityType qualityType = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString()); List <CrystalInfo> crystalArray2 = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= user.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); var crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID); if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray) { //wuzf修改 8-15 灰色放在临时背包不存DB CrystalHelper.AppendGrayCrystal(user, crystal.CrystalID); } else if (crystal != null) { var package = UserCrystalPackage.Get(user.UserID); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = crystal.CrystalID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 1, CreateDate = DateTime.Now }; package.SaveCrystal(userCrystal); UserLogHelper.AppenCtystalLog(user.UserID, 5, crystal.CrystalID, probabilityInfo.Price, 0, null, 1, 0); //高品质聊天通知); if (crystal.CrystalQuality >= CrystalQualityType.Yellow) { var cacheChat = new TjxChatService(); string content = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice, user.NickName, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName ); cacheChat.SystemSend(ChatType.World, content); } } } return(errStr); #endregion }
public override bool TakeAction() { //if (ContextUser.EnergyNum <= 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} //if (ContextUser.EnergyNum <= 0 && ContextUser.TempEnergyNum == 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} if (ContextUser.UserStatus == UserStatus.SaoDang) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4007_Saodanging; return(false); } if (ContextUser.UseMagicID == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic; return(false); } if (new GameDataCacheSet <UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty; return(false); } //if (ContextUser.TempEnergyNum == 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} ContextUser.UserStatus = UserStatus.Combat; try { //触发战斗 PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(PlotNpcID); //原因:碰npc时掉线,再请求战斗详情 if (npcInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } //原因:最后一个npc时,清空玩家保存副本 if (ContextUser.UserExtend != null && ContextUser.UserExtend.MercenarySeq > npcInfo.NpcSeqNo) { ContextUser.UserStatus = UserStatus.Normal; ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 1; ContextUser.UserExtend.IsBoss = false; return(true); }); //ErrorCode = LanguageManager.GetLang().ErrorCode; //ErrorInfo = LanguageManager.GetLang().St4011_NoMonster; //return false; } PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } var cacheSetUserPlot = new GameDataCacheSet <UserPlotPackage>(); var cacheSetItemInfo = new ShareCacheStruct <ItemBaseInfo>(); var cacheSet = new GameDataCacheSet <UserPlotCombat>(); var userPlotPack = cacheSetUserPlot.FindKey(ContextUser.UserID); var userPlot = userPlotPack != null?userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null; //PlotHelper.IsKill(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID) if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum) { if (plotInfo.PlotType == PlotType.Elite) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed; return(false); } else if (plotInfo.PlotType == PlotType.HeroPlot) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum; return(false); } } //if (userPlot != null && userPlot.ItemList != null) //{ // userPlot.UpdateNotify(obj => // { // userPlot.ItemList.Clear(); // return true; // }); //} if (npcInfo.NpcSeqNo == 1) { userPlot.ItemList.Clear(); ContextUser.IsItem = false; } userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); if (userPlotCombat != null && userPlotCombat.IsWin && ContextUser.UserExtend != null && PlotNpcID == ContextUser.UserExtend.PlotNpcID && !ContextUser.IsItem) { prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID); } else { ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID); if (plotCombater == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } if (userPlotCombat == null) { userPlotCombat = new UserPlotCombat() { UserID = ContextUser.UserID, PlotNpcID = PlotNpcID }; cacheSet.Add(userPlotCombat, GameEnvironment.CacheUserPeriod); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); } userPlotCombat.PlotID = npcInfo.PlotID; userPlotCombat.CombatDate = DateTime.Now; userPlotCombat.IsWin = plotCombater.Doing(); if (!userPlotCombat.IsWin) { userPlotCombat.OverNum += 1; } ContextUser.IsItem = npcInfo.NpcSeqNo == 1 ? false : ContextUser.IsItem; combatProcessList = (CombatProcessContainer)plotCombater.GetProcessResult(); userPlotCombat.GeneralNum = combatProcessList.AttackList.Count; userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList()); //userPlotCombat.CombatProcess = JsonUtils.Serialize(combatProcessList); int generalNum = combatProcessList.DefenseList.FindAll(s => s.LiveNum > 0).Count; if (userPlotCombat.IsWin) { if (ContextUser.UserExtend != null) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = npcInfo.PlotID; ContextUser.UserExtend.PlotNpcID = PlotNpcID; ContextUser.UserExtend.MercenarySeq = MathUtils.Addition(npcInfo.NpcSeqNo, (short)1); ContextUser.UserExtend.IsBoss = npcInfo.IsBoss; //是否最后一个副本npc return(true); }); } //玩家通过一个城市的所有副本时,增加聊天频道系统提示 if (userPlot.PlotStatus != PlotStatus.Completed && npcInfo.IsBoss) //玩家此副本胜利 { var city = new ConfigCacheSet <CityInfo>().FindKey(plotInfo.CityID); var nextPlot = new ConfigCacheSet <PlotInfo>().FindKey(plotInfo.AftPlotID); if (city != null && nextPlot != null && nextPlot.CityID != plotInfo.CityID) //此城市的最后一个副本 { string content = string.Format(LanguageManager.GetLang().St_systemprompts, ContextUser.NickName, city.CityName); new TjxChatService().SystemSend(ChatType.World, content); } } PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, generalNum, out _honourNum); if (npcInfo.NpcSeqNo == 1) { ContextUser.EnergyNum = MathUtils.Subtraction(ContextUser.EnergyNum, ContextUser.TempEnergyNum).ToShort(); //原因:刷晶石BUG ContextUser.TempEnergyNum = 0; } if (!ContextUser.IsItem) { prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID); } TaskHelper.KillPlotMonster(Uid, npcInfo.PlotID, PlotNpcID); //var stroyTaskList = new ConfigCacheSet<StoryTaskInfo>().FindAll(s => s.PlotID == plotInfo.AftPlotID); //foreach (var story in stroyTaskList) //{ // var usertask = new GameDataCacheSet<UserTask>().FindKey(ContextUser.UserID, story.PlotID); // if (usertask != null) // { PlotHelper.EnablePlot(Uid, plotInfo.AftPlotID); // } //} if (plotInfo.PlotType == PlotType.Elite) { EliteDailyRestrain(npcInfo); NoviceHelper.ElitePlotFestivalList(ContextUser); //通关精英副本获得奖励 } else if (plotInfo.PlotType == PlotType.Kalpa) { KalpaDailyRestrain(npcInfo); } else if (plotInfo.PlotType == PlotType.HeroPlot) { PlotHelper.EnableHeroPlot(ContextUser.UserID, plotInfo.PlotID); PlotHelper.HeroDailyRestrain(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID); } } else { ContextUser.GeneralAllCount = 0; ContextUser.GeneralKillCount = 0; } var restrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid); if (restrain != null) { var restrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PlotGoto); if (restrainSet != null) { GotoNum = MathUtils.Subtraction(restrainSet.MaxNum, restrain.Funtion14, 0); } } } //原因:最后一个npc时,清空玩家保存副本 if (ContextUser.UserExtend != null && ContextUser.UserExtend.IsBoss) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = npcInfo.IsBoss; return(true); }); } if (!ContextUser.IsItem) { foreach (var prize in prizeItems) { if (prize.Type == 0 && userPlot != null) { var itemInfo = cacheSetItemInfo.FindKey(prize.ItemID); UniversalInfo universalInfo = new UniversalInfo(); universalInfo.HeadID = itemInfo != null ? itemInfo.HeadID : string.Empty; universalInfo.ItemID = itemInfo != null ? itemInfo.ItemID : 0; universalInfo.ItemDesc = itemInfo != null ? itemInfo.ItemDesc : string.Empty; universalInfo.MaxHeadID = itemInfo != null ? itemInfo.MaxHeadID : string.Empty; universalInfo.Name = itemInfo != null ? itemInfo.ItemName : string.Empty; universalInfo.Num = prize.Num; if (userPlot.ItemList != null && userPlot.ItemList.Count > 0) { var item = userPlot.ItemList.Find(s => s.ItemID == prize.ItemID); if (item != null) { item.UpdateNotify(obj => { item.Num = MathUtils.Addition(item.Num, prize.Num); return(true); }); } else { userPlot.UpdateNotify(obj => { userPlot.ItemList.Add(universalInfo); return(true); }); } } else { userPlot.UpdateNotify(obj => { userPlot.ItemList.Add(universalInfo); return(true); }); } } ContextUser.IsItem = true; } } var a = userPlot.ItemList; } finally { ContextUser.UserStatus = UserStatus.Normal; } //日志 UserCombatLog log = new UserCombatLog(); log.CombatLogID = Guid.NewGuid().ToString(); log.UserID = userPlotCombat.UserID; log.CityID = ContextUser.CityID; log.PlotID = userPlotCombat.PlotID; log.NpcID = userPlotCombat.PlotNpcID; log.CombatType = CombatType.Plot; log.HostileUser = string.Empty; log.IsWin = userPlotCombat.IsWin; log.CombatProcess = JsonUtils.Serialize(combatProcessList); log.PrizeItem = prizeItems; log.CreateDate = DateTime.Now; var sender = DataSyncManager.GetDataSender(); sender.Send(log); UserHelper.GetGeneralLife(ContextUser.UserID); UserHelper.RegainGeneralLife(ContextUser.UserID); //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); // foreach (var userEmbattle in userEmbattleList) // { // _userTalPriority = MathUtils.Addition(_userTalPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID)); // } selfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0); //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0); return(true); }
public override bool TakeAction() { UserHelper.GetUserLightOpen(ContextUser.UserID); short opType = 0; int huntingID2 = 0; if (huntingID < 1005) { huntingID2 = MathUtils.Addition(huntingID, 1, int.MaxValue); } else { huntingID2 = 1001; //huntingID; } UserHelper.ChechDailyRestrain(ContextUser.UserID); if (!CrystalHelper.CheckAllowCrystall(ContextUser)) { ErrorCode = 1000; ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull; return(false); } else { if (!CrystalHelper.CheckAllowCrystall(ContextUser)) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull; return(false); } } ProbabilityInfo probabilityInfo = null; if (ops == 1) { #region opType = 1; UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID); probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(false); } ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2); if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { if (probabilityInfo.Price > ContextUser.GameCoin) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough; return(false); } } //暑期第三弹 if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(ContextUser)) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St1305_BeiBaoBackpackFull; return(false); } var lightCacheSet = new PersonalCacheStruct <UserLight>(); if (huntingID != 1001) { UserLight userLight1 = lightCacheSet.FindKey(ContextUser.UserID, huntingID); if (userLight1.IsLight == 2) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } if (userLight1.IsLight == 1) { userLight1.IsLight = 2; //userLight1.Update(); } } UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, huntingID2); if (RandomUtils.IsHit(probability1.Light)) { ErrorCode = ErrorCode; ErrorInfo = probability1.HuntingName; if (userLight != null) { userLight.IsLight = 1; //userLight.Update(); } else { userLight = new UserLight() { UserID = ContextUser.UserID, HuntingID = huntingID2, IsLight = 1 }; lightCacheSet.Add(userLight); } } if (userRestrain != null) { if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0); //ContextUser.Update(); } else { userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue); //userRestrain.Update(); } } else { ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0); //ContextUser.Update(); } lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID); #endregion } else if (ops == 2) { #region opType = 2; if (ContextUser.VipLv < 5) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_VipNotEnough; return(false); } probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(false); } if (ContextUser.GoldNum < probabilityInfo.Price) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } UserLight uLightInfo = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, probabilityInfo.GoldHunting); if (uLightInfo != null && uLightInfo.IsLight == 1) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1305_HuntingIDLight; return(false); } else if (uLightInfo != null && (uLightInfo.IsLight == 2 || uLightInfo.IsLight == 0)) { uLightInfo.IsLight = 1; } else { uLightInfo = new UserLight() { UserID = ContextUser.UserID, HuntingID = probabilityInfo.GoldHunting, IsLight = 1 }; new PersonalCacheStruct <UserLight>().Add(uLightInfo); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue); lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID); #endregion } //每种品质的概率 double[] probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red }; int index2 = RandomUtils.GetHitIndex(probabilityArray2); CrystalQualityType qualityType = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString()); List <CrystalInfo> crystalArray2 = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID); if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray) { //wuzf修改 8-15 灰色放在临时背包不存DB CrystalHelper.AppendGrayCrystal(ContextUser, crystal.CrystalID); } else if (crystal != null) { var package = UserCrystalPackage.Get(Uid); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = crystal.CrystalID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 1, CreateDate = DateTime.Now }; package.SaveCrystal(userCrystal); UserLogHelper.AppenCtystalLog(ContextUser.UserID, opType, crystal.CrystalID, probabilityInfo.Price, probabilityInfo.Price, null, 1, 0); //高品质聊天通知); if (crystal.CrystalQuality >= CrystalQualityType.Yellow) { var cacheChat = new TjxChatService(); string content = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice, ContextUser.NickName, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName ); cacheChat.SystemSend(ChatType.World, content); } } } //日常任务-猎命 TaskHelper.TriggerDailyTask(Uid, 4009); return(true); }
public override bool TakeAction() { UserFunction userFunction = new PersonalCacheStruct <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Xiulian); if (userFunction != null) { UserHelper.XiuLianGianExperience(ContextUser.UserID); //修炼完成后更改修炼状态 int inerDate = (int)(DateTime.Now - ContextUser.OnlineDate).TotalSeconds; if (inerDate > 300 && ContextUser.UserStatus != UserStatus.XiuLian) { int totalTime = 0; GeneralPracticeInfo generalpractice = new ShareCacheStruct <GeneralPracticeInfo>().FindKey(ContextUser.UserLv); if (VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.XiuLianYanChangErShiSiXiaoShi)) { totalTime = ConfigEnvSet.GetInt("User.XiuLianDate"); } else { if (generalpractice != null) { totalTime = (generalpractice.MaxHour * 60 * 60); } } if (inerDate > 300 && ContextUser.UserStatus != UserStatus.XiuLian && ContextUser.UserStatus != UserStatus.FightCombat) { ContextUser.UserStatus = UserStatus.XiuLian; //ContextUser.Update(); List <UserQueue> userQueueArray = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.XiuLian); if (userQueueArray.Count > 0) { UserQueue userQueue = userQueueArray[0]; userQueue.TotalColdTime = totalTime; userQueue.ColdTime = totalTime; userQueue.Timing = DateTime.Now; userQueue.IsSuspend = false; userQueue.StrengNum = 0; //userQueue.Update(); } _statusList.Add(MessageState.XiuLian); } } } UserDailyRestrain dailyRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID); if (new TjxChatService(ContextUser).HasMessage(ContextUser.ChatVesion)) { _statusList.Add(MessageState.Chat); } if (NoviceHelper.CheckOnlinePrize(Uid)) { _statusList.Add(MessageState.TakeOnline); } if (NoviceHelper.CheckLoginPrize(Uid)) { _statusList.Add(MessageState.TakeLogin); } if (new TjxBroadcastService(ContextUser).HasMessage()) { _statusList.Add(MessageState.Broadcast); } if (NoviceHelper.CheckDailyExpPrize(Uid)) { _statusList.Add(MessageState.TakeDailyExp); } if (RankingHelper.IsGainSportsReward(ContextUser.UserID)) { _statusList.Add(MessageState.JingJiChangReward); } UserFunction countryFunction = new PersonalCacheStruct <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Country); if (countryFunction != null && dailyRestrain != null && dailyRestrain.Funtion8 < VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.LingQuFengLu)) { _statusList.Add(MessageState.LingQuFengLv); } if (NoviceHelper.DailyEnergy(ContextUser.UserID)) { _statusList.Add(MessageState.SurplusEnergy); } if (new GameActiveCenter(Uid).HasActive()) { _statusList.Add(MessageState.Huodong); } if (NoviceHelper.IsAugustSecondWeekEnergy(ContextUser)) { _statusList.Add(MessageState.FestivalEnergy); } if (NoviceHelper.IsWingFestivalInfo(ContextUser.UserID)) { _statusList.Add(MessageState.Wing); } if (GuildFightBroadcast(ContextUser.UserID, stakecount, ContextUser.MercenariesID)) { _statusList.Add(MessageState.GuildFight); } else { stakecount = 0; } var userPrizeList = new ShareCacheStruct <UserTakePrize>().FindAll(m => !m.IsTasked && m.UserID == Uid.ToInt()); if (userPrizeList.Count > 0) { _statusList.Add(MessageState.TaskPrize); } return(true); }
public override bool TakeAction() { short currMaxLv = ConfigEnvSet.GetInt("User.CurrMaxLv").ToShort(); //NoviceHelper.CheckFestival(ContextUser); NoviceHelper.GetFunctionEnum(Uid); //默认开启金币,精力大作战功能 if (!string.IsNullOrEmpty(ContextUser.MercenariesID)) { UserHelper.ChecheDailyContribution(ContextUser.MercenariesID, ContextUser.UserID); } PaymentService.Trigger(ContextUser); if (ContextUser.UserLv > currMaxLv) { genlv = currMaxLv; } else { genlv = ContextUser.UserLv; } var cacheSetGeneralEscalate = new ConfigCacheSet <GeneralEscalateInfo>(); GeneralEscalateHelper.AddUserLv(ContextUser, 0); _honourNum = ContextUser.HonourNum; int lv = ContextUser.UserLv; lv = lv < 0 ? 1 : lv + 1; var generalEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv); if (generalEscalate != null) { _nextHonourNum = generalEscalate.UpExperience; } guildID = ContextUser.MercenariesID; var userGeneralList = new GameDataCacheSet <UserGeneral>().FindAll(ContextUser.UserID); if (userGeneralList.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } userGeneralInfo = userGeneralList[0]; //UserGeneral.GetMainGeneral(ContextUser.UserID); if (userGeneralInfo != null) { //wuzf 去掉刷新血量,其它改变血量接口有触发刷新 //userGeneralInfo.RefreshMaxLife(); generalID = userGeneralInfo.GeneralID; //careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(userGeneralInfo.CareerID); headID = userGeneralInfo.HeadID; //ContextUser.Sex ? careerInfo.HeadID2 : careerInfo.HeadID; escalateInfo = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(genlv); lifeNum = userGeneralInfo.LifeNum; careerID = userGeneralInfo.CareerID; } lifeMaxNum = UserHelper.GetMaxLife(ContextUser.UserID, generalID); maxEnergyNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); sex = ContextUser.Sex ? 1 : 0; //道具图标 _blessingList = UserHelper.BlessingInfoList(ContextUser); //变身卡图标 List <UserProps> userPropsList = new GameDataCacheSet <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 3 && u.ItemID != 5200 && u.ItemID != 7003); if (userPropsList.Count > 0) { UserProps props = userPropsList[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { pictureID = itemInfo.PictrueID; pictureTime = pTime; } } //兼容客户端上已版本血量图标 List <UserProps> userPropsList2 = new GameDataCacheSet <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1); if (userPropsList2.Count > 0) { UserProps props = userPropsList2[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { _itemLiveNum = props.SurplusNum; _itemLiveMaxNum = itemInfo.EffectNum; } } //加量,领土战不能加血wuzf) if (ContextUser.UserStatus != UserStatus.CountryCombat) { UserHelper.GetGeneralLife(ContextUser.UserID); } //精力恢复 List <UserQueue> energyQueueArray = new GameDataCacheSet <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EnergyHuiFu); if (energyQueueArray.Count > 0) { UserQueue energyQueue = energyQueueArray[0]; short energyMaxNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); int restorationDate = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationDate"); //半小时 int restorationNum = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationNum"); //恢复5点 if (energyQueue.Timing > DateTime.Now) { energyQueue.Timing = DateTime.Now; } //原因:玩家满精力时,精力恢复累加 int timeCount = (int)(DateTime.Now - energyQueue.Timing).TotalSeconds / restorationDate; if (timeCount > 0) { short energyNum = (short)(timeCount * restorationNum); if (ContextUser.EnergyNum < energyMaxNum) { ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, energyNum, energyMaxNum); } energyQueue.Timing = DateTime.Now; } else { if (energyMaxNum > ContextUser.EnergyNum) { rstore = (int)(energyQueue.Timing.AddSeconds(restorationDate) - DateTime.Now).TotalSeconds; totalRstore = (energyQueue.Timing.AddSeconds((energyMaxNum - ContextUser.EnergyNum) * restorationDate) - DateTime.Now).TotalSeconds.ToInt(); } } } else { UserQueue queue = new UserQueue() { QueueID = Guid.NewGuid().ToString(), UserID = ContextUser.UserID, QueueType = QueueType.EnergyHuiFu, QueueName = QueueType.EnergyHuiFu.ToString(), Timing = DateTime.Now, ColdTime = 0, TotalColdTime = 0, IsSuspend = false, StrengNum = 0 }; new GameDataCacheSet <UserQueue>().Add(queue, GameEnvironment.CacheUserPeriod); } VipLvInfo lvInfo = new ConfigCacheSet <VipLvInfo>().FindKey(MathUtils.Addition(ContextUser.VipLv, 1, int.MaxValue)); if (lvInfo != null) { demandGold = MathUtils.Subtraction(lvInfo.PayGold, ContextUser.PayGold, 0); demandGold = MathUtils.Subtraction(demandGold, ContextUser.ExtGold, 0); } UserHelper.GetGameUserCombat(ContextUser.UserID); if ((int)(DateTime.Now - ContextUser.DailyLoginTime).TotalSeconds <= 5 && ContextUser.UserLv > 10) { isHelper = 1; } FestivalHelper.DoFestival(ContextUser); if (ContextUser.UserExtend != null) { if ((plotstatucID > 0 || ContextUser.TempEnergyNum == 0) && !ContextUser.UserExtend.IsBoss) { ContextUser.TempEnergyNum = 1; } if ((plotstatucID == 0 && ContextUser.TempEnergyNum == 0) || ContextUser.UserExtend.IsBoss) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = false; return(true); }); } plotstatucID = ContextUser.UserExtend.PlotStatusID; mercenarySeq = ContextUser.UserExtend.MercenarySeq; cardUserID = ContextUser.UserExtend.CardUserID; } //公会晨练结束,退出公会晨练 int activeID = 11; GameActive active = new ShareCacheStruct <GameActive>().FindKey(activeID); if (active != null) { DateTime stratTime = active.BeginTime; DateTime endTime = active.BeginTime.AddMinutes(active.Minutes); if (ContextUser.UserLocation == Location.GuildExercise && (DateTime.Now < stratTime || DateTime.Now > endTime)) { ContextUser.UserLocation = Location.Guid; } } DateTime nextDate; FightStage stage = GuildFightCombat.GetStage(out nextDate); //公会战结束后 if (stage == FightStage.Apply && ContextUser.UserStatus == UserStatus.FightCombat) { ContextUser.UserStatus = UserStatus.Normal; } battleNum = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true).Count; totalBattle = EmbattleHelper.CurrEmbattle(ContextUser.UserID, false).Count; var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); foreach (var userEmbattle in userEmbattleList) { _talPriority = MathUtils.Addition(_talPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID)); } functionList = new GameDataCacheSet <UserFunction>().FindAll(ContextUser.UserID); // 精灵祝福 if (ContextUser != null) { if (MathUtils.SqlMinDate == ContextUser.WizardDate) // 玩家第一次进入 { ContextUser.WizardDate = DateTime.Now; ContextUser.WizardNum = 1; } else { double diffHours = (DateTime.Now - ContextUser.WizardDate).TotalHours; if (diffHours >= 1) { ContextUser.WizardNum = MathUtils.Addition(ContextUser.WizardNum, Convert.ToInt32(diffHours), 3); ContextUser.WizardDate = DateTime.Now; } } } // 未读信件的数量 TjxMailService tjxMailService = new TjxMailService(ContextUser); tjxMailService.GetMail(out unReadCount); return(true); }
//protected override bool ValidateElement() //{ // return UserHelper.GetKeyWordSubstitution(UserName); //} protected override bool CreateUserRole(out IUser user) { user = null; int MaxLength = ConfigEnvSet.GetInt("User.MaxLength"); int length = System.Text.Encoding.Default.GetByteCount(UserName); if (UserHelper.GetKeyWordSubstitution(UserName)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RegistNameKeyWord; return(false); } if (GameUser.IsNickName(UserName)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_Rename; return(false); } if (length <= 0 || length > MaxLength) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = string.Format(LanguageManager.GetLang().St1005_KingNameTooLong, MaxLength); return(false); } Regex re = new Regex(@"^[\u4e00-\u9fa5\w]+$"); if (!re.IsMatch(UserName)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RegistNameExceptional; return(false); } if (!Pid.ToLower().StartsWith("z")) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_PassportError; return(false); } GeneralInfo general = new ConfigCacheSet <GeneralInfo>().FindKey(generalID); if (general == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } CareerInfo careerInfo = new ConfigCacheSet <CareerInfo>().FindKey(general.CareerID); if (careerInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_Professional; return(false); } GameUser userEntity = new GameDataCacheSet <GameUser>().FindKey(Uid); if (userEntity != null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RoleExist; return(false); } bool userSex = Sex == 0 ? false : true; if (new GameDataCacheSet <GameUser>().FindKey(Uid) == null) { userEntity = CreateGameUser(userSex); user = new SessionUser(userEntity); NoviceHelper.RetailLoginDaysReceive(userEntity); //渠道登录奖励 CreateGeneral(careerInfo); CreateMagic(userEntity); //每日限制次数 CreateDailyRestrain(); //开启默认功能 EnableFunction(); //SendGifItem(); UserPrayHelper.AddUserPray(Uid.ToInt(), PrayType.SanTianQiDao); UserPackHelper.AddUserPack(Uid); UserLoginLog userLoginLog = new UserLoginLog(); userLoginLog.UserId = Uid; userLoginLog.SessionID = Sid; userLoginLog.MobileType = MobileType; userLoginLog.ScreenX = ScreenX; userLoginLog.ScreenY = ScreenY; userLoginLog.RetailId = RetailID; userLoginLog.AddTime = DateTime.Now; userLoginLog.State = LoginStatus.Logined; userLoginLog.DeviceID = DeviceID; userLoginLog.Ip = this.GetRealIP(); userLoginLog.Pid = userEntity.Pid; userLoginLog.UserLv = userEntity.UserLv; var sender = DataSyncManager.GetDataSender(); sender.Send(userLoginLog); BackPackHelper.AddBack(userEntity); UserHelper.OpenMagic(Uid, 1); //封测注册发放礼包 UserItemHelper.AddUserItem(Uid, 1704, 1, ItemStatus.BeiBao); } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RoleExist; return(false); } PlotHelper.EnablePlot(Uid, ConfigEnvSet.GetInt("UserPlot.OpenLockPlotID")); return(true); }
private static void TriggerSportCombat(GameUser user, GameUser toUser, int sportNum, ref string sportsPrizeString, UserMail userMail) { CombatProcessContainer combatProcessList = null; int rewardGoin = 0; int rewardObtion = 0; //荣誉值 int experence = 0; //经验 int winNum = 0; //原因:gameuser加了连胜字段 winNum = user.VictoryNum; int rankIndex; int torankIndex; Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey); if (!ranking.TryGetRankNo(m => m.UserID == user.UserID, out rankIndex) || !ranking.TryGetRankNo(m => m.UserID == toUser.UserID, out torankIndex)) { return; } UserRank userRank = ranking.Find(s => s.UserID == user.UserID); UserRank toUserRank = ranking.Find(s => s.UserID == toUser.UserID); if (userRank == null || toUserRank == null) { return; } //修改wuzf,两个地方调用Doing()方法 ISingleCombat sportCombat = CombatFactory.TriggerTournament(user, toUser); if (sportCombat == null) { return; } bool isWin = sportCombat.Doing(); if (isWin) { winNum = MathUtils.Addition(winNum, 1, int.MaxValue); userRank.VictoryNum = winNum; toUserRank.VictoryNum = 0; toUser.VictoryNum = 0; new GameDataCacheSet <GameUser>().UpdateSelf(toUser.PersonalId); rewardGoin = (user.UserLv * 40); //GetRewardGameCoin(user, user.UserLv); experence = (user.UserLv * 10); rewardObtion = 10; AddFoe(user, toUser); } else { winNum = 0; userRank.VictoryNum = 0; rewardGoin = (user.UserLv * 20); if (!rewardGoin.IsValid()) { rewardGoin = 0; } experence = (user.UserLv * 5); rewardObtion = 5; } //公会贡献 UserHelper.Contribution(user.UserID, rewardObtion); if (!string.IsNullOrEmpty(user.MercenariesID)) { GuildMemberLog.AddLog(user.MercenariesID, new MemberLog { UserID = user.UserID, IdolID = 0, LogType = 1, GainObtion = rewardObtion, Experience = rewardObtion, GainAura = 0, InsertDate = DateTime.Now, }); } user.VictoryNum = winNum; new GameDataCacheSet <GameUser>().UpdateSelf(user.PersonalId); user.ExpNum = MathUtils.Addition(user.ExpNum, rewardObtion, int.MaxValue); user.GameCoin = MathUtils.Addition(user.GameCoin, rewardGoin, int.MaxValue); GeneralHelper.UserGeneralExp(user.UserID, 0, experence); int _rankTopId = 0; int _ranktoTopID = 0; if (isWin && rankIndex > torankIndex) { _rankTopId = toUserRank.RankId; _ranktoTopID = userRank.RankId; } else { _rankTopId = userRank.RankId; _ranktoTopID = toUserRank.RankId; } combatProcessList = (CombatProcessContainer)sportCombat.GetProcessResult(); user.SportsCombatQueue.Enqueue(new SportsCombat() { ToUser = toUser.UserID, ToUserName = toUser.NickName, TopID = _rankTopId, IsWin = isWin, RewardGoin = rewardGoin, RewardObtian = rewardObtion, SportsNum = sportNum, WinNum = winNum, CombatDate = DateTime.Now, CombatProcess = combatProcessList, IsSelf = true, RankStatus = GetRankStatus(isWin, userRank, toUserRank) }); UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(toUser.UserID) ?? new UserDailyRestrain(); toUser.SportsCombatQueue.Enqueue(new SportsCombat() { ToUser = user.UserID, ToUserName = user.NickName, TopID = _ranktoTopID, IsWin = !isWin, RewardGoin = 0, RewardObtian = 0, SportsNum = dailyRestrain.Funtion9, WinNum = toUserRank.VictoryNum, CombatDate = DateTime.Now, CombatProcess = combatProcessList, IsSelf = false, RankStatus = GetRankStatus(!isWin, toUserRank, userRank) }); //日志 UserCombatLog log = new UserCombatLog() { CombatLogID = Guid.NewGuid().ToString(), UserID = user.UserID, CityID = 0, PlotID = 0, NpcID = 0, CombatType = CombatType.User, HostileUser = toUser.UserID, IsWin = isWin, CombatProcess = JsonUtils.Serialize(combatProcessList), CreateDate = DateTime.Now }; var sender = DataSyncManager.GetDataSender(); sender.Send(log); string prizeContent = string.Empty; MysteryHelper.IsTriggerMyStery(user, MysteryType.Jingjichang, out prizeContent); MysteryInfo mysteryInfo = new ConfigCacheSet <MysteryInfo>().FindKey(MysteryType.Jingjichang); if (!string.IsNullOrEmpty(prizeContent) && mysteryInfo != null) { var prompt = string.Empty; var broadcast = string.Empty; if (isWin) { prompt = mysteryInfo.WinPrompt; broadcast = mysteryInfo.WinBroadcast; } else { prompt = mysteryInfo.Prompt; broadcast = mysteryInfo.Broadcast; } sportsPrizeString = string.Format(prompt, toUser.NickName, prizeContent); string broadContent = string.Format(broadcast, toUser.NickName, prizeContent); var broadcastService = new TjxBroadcastService(null); var msg = broadcastService.Create(NoticeType.System, broadContent); broadcastService.Send(msg); } //sportsPrizeString = SportsPrizeHelper.DoPrize(user.UserID, isWin, toUser.NickName); //var userMail = new UserMail(Guid.NewGuid()); var mailText = string.Format(LanguageManager.GetLang().SportsRankLetterForWin, user.NickName); if (isWin) { if (rankIndex > torankIndex) { //SportsRankPrize(rankIndex, user, torankIndex); //SportsRankPrize(torankIndex, toUser, rankIndex); ranking.TryMove(rankIndex, torankIndex); //user.RankID = torankIndex; //user.RankDate = DateTime.Now; //toUser.RankID = rankIndex; //toUser.RankDate = DateTime.Now; new GameDataCacheSet <GameUser>().UpdateSelf(user.PersonalId); new GameDataCacheSet <GameUser>().UpdateSelf(toUser.PersonalId); mailText = string.Format(LanguageManager.GetLang().SportsRankLetterForFailure, user.NickName, rankIndex); } else { mailText = string.Format(LanguageManager.GetLang().SportsRankLetterForFailureRank, user.NickName, rankIndex); } UserHelper.SprostSystemChat(userRank, toUserRank); NoviceHelper.SportCombatFestival(user, winNum, userRank.VictoryNum); } userMail.Content = mailText; var userid = toUser.UserID.ToInt(); userMail.ToUserID = userid; userMail.UserId = userid; userMail.MailType = (int)MailType.Fight; userMail.ToUserName = toUser.NickName; userMail.FromUserName = LanguageManager.GetLang().St_SystemMailTitle; userMail.FromUserId = LanguageManager.GetLang().SystemUserId; userMail.SendDate = DateTime.Now; userMail.Title = string.Empty; userMail.CounterattackUserID = user.UserID.ToInt(); userMail.CombatProcess = JsonUtils.Serialize(combatProcessList); userMail.IsWin = isWin; }