protected override object this[string index] { get { #region switch (index) { case "AgainstID": return(AgainstID); case "Round": return(Round); case "Win": return(Win); case "FastID": return(FastID); case "CombatProcessContainer": return(CombatProcessContainer); default: throw new ArgumentException(string.Format("ServerCombatDetail index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "AgainstID": this._AgainstID = value.ToNotNullString(); break; case "Round": this._Round = value.ToInt(); break; case "Win": this._Win = value.ToBool(); break; case "FastID": this._FastID = value.ToInt(); break; case "CombatProcessContainer": this._CombatProcessContainer = value as CombatProcessContainer; break; default: throw new ArgumentException(string.Format("ServerCombatDetail index[{0}] isn't exist.", index)); } #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() { int sportsIndex; if (int.TryParse(userSportsID, out sportsIndex)) { var tempList = ContextUser.GetSportsCombat(); if (tempList.Count > 0 && sportsIndex < tempList.Count) { sportsIndex = MathUtils.Addition(sportsIndex, 1); _uSportsCombat = tempList[tempList.Count - sportsIndex] ?? new SportsCombat(); _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer(); _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0); if (_combatProcessList.DefenseList.Count > 0) { _npcTalPriority = CombatHelper.TotalPriorityNum(_combatProcessList.DefenseList[0].UserID, 0); } } } else if (!string.IsNullOrEmpty(toUserID)) { UserHelper.ChechDailyRestrain(ContextUser.UserID); if (ContextUser.UserID == toUserID) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } if (GetChallGeNum(ContextUser.UserID) <= 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St5107_ChallGeNumFull; return false; } toGameUser = UserCacheGlobal.LoadOffline(toUserID); if (ContextUser.UseMagicID == 0 || toGameUser == null || toGameUser.UseMagicID == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic; return false; } RankingHelper.SportSRewardGain(toUserID, toGameUser.RankID); //被挑战者的竞技排名 //todo 竞技场冷却时间清除 //var userQueueCache = new GameDataCacheSet<UserQueue>(); //var queueArray = userQueueCache.FindAll(Uid, m => m.QueueType == QueueType.JingJiTiaoZhan); //if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St5107_Colding; // return false; //} //if (queueArray.Count > 0) //{ // var userQueue = queueArray[0]; // userQueue.ColdTime = codeTime; // userQueue.TotalColdTime = codeTime; // userQueue.Timing = DateTime.Now; //} //else //{ // UserQueue queue = new UserQueue() // { // QueueID = Guid.NewGuid().ToString(), // QueueType = QueueType.JingJiTiaoZhan, // QueueName = QueueType.JingJiTiaoZhan.ToString(), // UserID = ContextUser.UserID, // ColdTime = codeTime, // IsSuspend = false, // TotalColdTime = codeTime, // Timing = DateTime.Now // }; // userQueueCache.Add(queue, GameEnvironment.CacheUserPeriod); // //queue.Append(); //} //次数限制修改 int sportNum = 0; UserDailyRestrain dailyRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(ContextUser.UserID); if (dailyRestrain != null) { sportNum = MathUtils.Addition(dailyRestrain.Funtion9, 1, int.MaxValue); dailyRestrain.Funtion9 = sportNum; //dailyRestrain.Update(); } else { sportNum = 1; } TriggerSportCombat(ContextUser, toGameUser, sportNum, ref sportsPrizeStr,userMail); var tempList = ContextUser.GetSportsCombat(); if (tempList.Count > 0) { _uSportsCombat = tempList[tempList.Count - 1] ?? new SportsCombat(); _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer(); } //日常任务-竞技 TaskHelper.TriggerDailyTask(Uid, 4006); _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0); _npcTalPriority = CombatHelper.TotalPriorityNum(toUserID, 0); } else { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } userMail.GameCoin = _uSportsCombat.RewardGoin; userMail.Obtion = _uSportsCombat.RewardObtian; var tjxMailService = new TjxMailService(toGameUser); tjxMailService.Send(userMail); _selfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0); _defSelfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(toUserID, 1); _selfAbilityEffectList.AddRange(_defSelfAbilityEffectList); return true; }
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 PersonalCacheStruct<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 ShareCacheStruct<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 ShareCacheStruct<PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return false; } var cacheSetUserPlot = new PersonalCacheStruct<UserPlotPackage>(); var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>(); var cacheSet = new PersonalCacheStruct<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); 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 ShareCacheStruct<CityInfo>().FindKey(plotInfo.CityID); var nextPlot = new ShareCacheStruct<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 ShareCacheStruct<StoryTaskInfo>().FindAll(s => s.PlotID == plotInfo.AftPlotID); //foreach (var story in stroyTaskList) //{ // var usertask = new PersonalCacheStruct<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 PersonalCacheStruct<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("N"); 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() { if (_userId.Equals(Uid)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptError; return false; } if (new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid) != null) { var userRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid); int maxNum = new ShareCacheStruct<DailyRestrainSet>().FindKey(RestrainType.PetIntercept).MaxNum; if (userRestrain.UserExtend != null && userRestrain.UserExtend.PetIntercept >= maxNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptTimesOut; return false; } } var petRunPool = new ShareCacheStruct<PetRunPool>().FindKey(_userId); if (petRunPool == null || !petRunPool.IsRunning) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptFaild; return false; } if (!string.IsNullOrEmpty(petRunPool.FriendID) && petRunPool.FriendID.Equals(Uid)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetFriendError; return false; } if (!string.IsNullOrEmpty(petRunPool.InterceptUser)) { string[] InterceptUserList = petRunPool.InterceptUser.Split(','); foreach (string intercept in InterceptUserList) { if (intercept == ContextUser.UserID) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptFull; return false; } } petRunPool.InterceptUser = petRunPool.InterceptUser + ContextUser.UserID + ","; } else { petRunPool.InterceptUser = ContextUser.UserID + ","; } //petRunPool.Update(); var chatService = new TjxChatService(); string toUserId = petRunPool.UserID; if (!string.IsNullOrEmpty(petRunPool.FriendID)) { toUserId = petRunPool.FriendID; } GameUser toGameUser = UserCacheGlobal.LoadOffline(toUserId); ISingleCombat combatProxy = CombatFactory.TriggerTournament(ContextUser, toGameUser); isWin = combatProxy.Doing(); combatProcessList = (CombatProcessContainer)combatProxy.GetProcessResult(); if (isWin) { _interceptGameCoin = petRunPool.InterceptGameCoin; _interceptObtainNum = petRunPool.InterceptObtainNum; petRunPool.GameCoin = MathUtils.Subtraction(petRunPool.GameCoin, _interceptGameCoin, 0); petRunPool.ObtainNum = MathUtils.Subtraction(petRunPool.ObtainNum, _interceptObtainNum, 0); //petRunPool.Update(); ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, _interceptGameCoin); ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, _interceptObtainNum); //ContextUser.Update(); var user = UserCacheGlobal.LoadOffline(petRunPool.UserID) ?? new GameUser(); chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().Chat_PetWasBlocked, (new ConfigCacheSet<PetInfo>().FindKey(petRunPool.PetID) ?? new PetInfo()).PetName, ContextUser.NickName, _interceptGameCoin, _interceptObtainNum )); chatService.SystemSendWhisper(ContextUser, string.Format(LanguageManager.GetLang().Chat_PetInterceptSucess, ContextUser.NickName, user.NickName, (new ConfigCacheSet<PetInfo>().FindKey(petRunPool.PetID) ?? new PetInfo()).PetName, _interceptGameCoin, _interceptObtainNum)); } //日志 UserCombatLog log = new UserCombatLog(); log.CombatLogID = Guid.NewGuid().ToString(); log.UserID = Uid; log.CityID = ContextUser.CityID; log.PlotID = 0; log.NpcID = 0; log.CombatType = CombatType.PetRun; log.HostileUser = toUserId; log.IsWin = isWin; log.CombatProcess = JsonUtils.Serialize(combatProcessList); log.PrizeItem = new CacheList<PrizeItemInfo>(); log.CreateDate = DateTime.Now; var sender = DataSyncManager.GetDataSender(); sender.Send(log); if (new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid) != null) { var restrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid); restrain.UserExtend.UpdateNotify(obj => { restrain.UserExtend.PetIntercept = MathUtils.Addition(restrain.UserExtend.PetIntercept, 1); return true; }); //restrain.Update(); } return true; }
public override bool TakeAction() { var cacheEnvSet = new ConfigCacheSet<ConfigEnvSet>(); var envset = cacheEnvSet.FindKey("CombatMaxBout"); if (envset != null) { } PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID); if (npcInfo == null) { return false; } PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { return false; } //判断是否有下一关 int nextLayerNum = MathUtils.Addition(ContextUser.UserExtend.LayerNum, 1); int nextHurdleNum = MathUtils.Addition(ContextUser.UserExtend.HurdleNum, 1); if ((UserHelper.IsLastLayer(plotInfo) || !IsGotoNextLayer(nextLayerNum))) { if (UserHelper.IsKill(ContextUser, npcInfo.PlotID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnableLayerNum; return false; } } if (ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood; return false; } //原因:灵件背包满时未提示 if (ops != 1 && UserHelper.IsSpareGridNum(ContextUser, 0)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St_User_SpareBeiBaoMsg; return false; } if (ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull; 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; } //PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID); if (IsPlotOut(npcInfo)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnable; return false; } UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血 //触发战斗 ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID); if (plotCombater == null) { return false; } var cacheSet = new GameDataCacheSet<UserPlotCombat>(); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); if (userPlotCombat == null) { userPlotCombat = new UserPlotCombat() { UserID = ContextUser.UserID, PlotNpcID = PlotNpcID }; cacheSet.Add(userPlotCombat); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); } userPlotCombat.PlotID = npcInfo.PlotID; userPlotCombat.CombatDate = DateTime.Now; userPlotCombat.IsWin = plotCombater.Doing(); if (!userPlotCombat.IsWin) { userPlotCombat.OverNum += 1; } combatProcessList = (CombatProcessContainer)plotCombater.GetProcessResult(); userPlotCombat.GeneralNum = combatProcessList.AttackList.Count; userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList()); if (userPlotCombat.IsWin) { int honourNum = 0; PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, 0, out honourNum); prizeItems = PlotHelper.GetKalpaPlotMonsterItems(Uid, npcInfo.PlotID, npcInfo.PlotNpcID); universalArray = GetUniversalList().ToArray(); if (plotInfo.PlotType == PlotType.Kalpa) { KalpaDailyRestrain(npcInfo); if (ContextUser.UserExtend == null) { ContextUser.UserExtend = new GameUserExtend(); } PlotInfo[] plotInfoList = new ConfigCacheSet<PlotInfo>().FindAll(m => m.LayerNum == ContextUser.UserExtend.LayerNum && m.PlotSeqNo == nextHurdleNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { int layerNum = ContextUser.UserExtend.LayerNum; int hurdleNum = ContextUser.UserExtend.HurdleNum; if (CheckHurdleNum(ContextUser.UserID, layerNum, hurdleNum)) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.HurdleNum = nextHurdleNum; return true; }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } else if (IsGotoNextLayer(nextLayerNum)) { //判断是否能到下一层 plotInfoList = new ConfigCacheSet<PlotInfo>().FindAll(m => m.LayerNum == nextLayerNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.LayerNum = nextLayerNum; ContextUser.UserExtend.HurdleNum = 1; return true; }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } } } //日志 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.Kalpa; 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); return true; }
public override bool TakeAction() { var cacheEnvSet = new ConfigCacheSet <ConfigEnvSet>(); var envset = cacheEnvSet.FindKey("CombatMaxBout"); if (envset != null) { } PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(PlotNpcID); if (npcInfo == null) { return(false); } PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { return(false); } //判断是否有下一关 int nextLayerNum = MathUtils.Addition(ContextUser.UserExtend.LayerNum, 1); int nextHurdleNum = MathUtils.Addition(ContextUser.UserExtend.HurdleNum, 1); if ((UserHelper.IsLastLayer(plotInfo) || !IsGotoNextLayer(nextLayerNum))) { if (UserHelper.IsKill(ContextUser, npcInfo.PlotID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnableLayerNum; return(false); } } if (ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood; return(false); } //原因:灵件背包满时未提示 if (ops != 1 && UserHelper.IsSpareGridNum(ContextUser, 0)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St_User_SpareBeiBaoMsg; return(false); } if (ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull; 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); } //PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID); if (IsPlotOut(npcInfo)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnable; return(false); } UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血 //触发战斗 ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID); if (plotCombater == null) { return(false); } var cacheSet = new GameDataCacheSet <UserPlotCombat>(); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); 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; } combatProcessList = (CombatProcessContainer)plotCombater.GetProcessResult(); userPlotCombat.GeneralNum = combatProcessList.AttackList.Count; userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList()); if (userPlotCombat.IsWin) { int honourNum = 0; PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, 0, out honourNum); prizeItems = PlotHelper.GetKalpaPlotMonsterItems(Uid, npcInfo.PlotID, npcInfo.PlotNpcID); universalArray = GetUniversalList().ToArray(); if (plotInfo.PlotType == PlotType.Kalpa) { KalpaDailyRestrain(npcInfo); if (ContextUser.UserExtend == null) { ContextUser.UserExtend = new GameUserExtend(); } PlotInfo[] plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == ContextUser.UserExtend.LayerNum && m.PlotSeqNo == nextHurdleNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { int layerNum = ContextUser.UserExtend.LayerNum; int hurdleNum = ContextUser.UserExtend.HurdleNum; if (CheckHurdleNum(ContextUser.UserID, layerNum, hurdleNum)) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.HurdleNum = nextHurdleNum; return(true); }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } else if (IsGotoNextLayer(nextLayerNum)) { //判断是否能到下一层 plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == nextLayerNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.LayerNum = nextLayerNum; ContextUser.UserExtend.HurdleNum = 1; return(true); }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } } } //日志 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.Kalpa; 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); return(true); }
public override bool TakeAction() { if (_userId.Equals(Uid)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptError; return(false); } if (new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid) != null) { var userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid); int maxNum = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PetIntercept).MaxNum; if (userRestrain.UserExtend != null && userRestrain.UserExtend.PetIntercept >= maxNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptTimesOut; return(false); } } var petRunPool = new ShareCacheStruct <PetRunPool>().FindKey(_userId); if (petRunPool == null || !petRunPool.IsRunning) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptFaild; return(false); } if (!string.IsNullOrEmpty(petRunPool.FriendID) && petRunPool.FriendID.Equals(Uid)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetFriendError; return(false); } if (!string.IsNullOrEmpty(petRunPool.InterceptUser)) { string[] InterceptUserList = petRunPool.InterceptUser.Split(','); foreach (string intercept in InterceptUserList) { if (intercept == ContextUser.UserID) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptFull; return(false); } } petRunPool.InterceptUser = petRunPool.InterceptUser + ContextUser.UserID + ","; } else { petRunPool.InterceptUser = ContextUser.UserID + ","; } //petRunPool.Update(); var chatService = new TjxChatService(); string toUserId = petRunPool.UserID; if (!string.IsNullOrEmpty(petRunPool.FriendID)) { toUserId = petRunPool.FriendID; } GameUser toGameUser = UserCacheGlobal.LoadOffline(toUserId); ISingleCombat combatProxy = CombatFactory.TriggerTournament(ContextUser, toGameUser); isWin = combatProxy.Doing(); combatProcessList = (CombatProcessContainer)combatProxy.GetProcessResult(); if (isWin) { _interceptGameCoin = petRunPool.InterceptGameCoin; _interceptObtainNum = petRunPool.InterceptObtainNum; petRunPool.GameCoin = MathUtils.Subtraction(petRunPool.GameCoin, _interceptGameCoin, 0); petRunPool.ObtainNum = MathUtils.Subtraction(petRunPool.ObtainNum, _interceptObtainNum, 0); //petRunPool.Update(); ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, _interceptGameCoin); ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, _interceptObtainNum); //ContextUser.Update(); var user = UserCacheGlobal.LoadOffline(petRunPool.UserID) ?? new GameUser(); chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().Chat_PetWasBlocked, (new ConfigCacheSet <PetInfo>().FindKey(petRunPool.PetID) ?? new PetInfo()).PetName, ContextUser.NickName, _interceptGameCoin, _interceptObtainNum )); chatService.SystemSendWhisper(ContextUser, string.Format(LanguageManager.GetLang().Chat_PetInterceptSucess, ContextUser.NickName, user.NickName, (new ConfigCacheSet <PetInfo>().FindKey(petRunPool.PetID) ?? new PetInfo()).PetName, _interceptGameCoin, _interceptObtainNum)); } //日志 UserCombatLog log = new UserCombatLog(); log.CombatLogID = Guid.NewGuid().ToString(); log.UserID = Uid; log.CityID = ContextUser.CityID; log.PlotID = 0; log.NpcID = 0; log.CombatType = CombatType.PetRun; log.HostileUser = toUserId; log.IsWin = isWin; log.CombatProcess = JsonUtils.Serialize(combatProcessList); log.PrizeItem = new CacheList <PrizeItemInfo>(); log.CreateDate = DateTime.Now; var sender = DataSyncManager.GetDataSender(); sender.Send(log); if (new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid) != null) { var restrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid); restrain.UserExtend.UpdateNotify(obj => { restrain.UserExtend.PetIntercept = MathUtils.Addition(restrain.UserExtend.PetIntercept, 1); return(true); }); //restrain.Update(); } 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; }
public override bool TakeAction() { int sportsIndex; if (int.TryParse(userSportsID, out sportsIndex)) { var tempList = ContextUser.GetSportsCombat(); if (tempList.Count > 0 && sportsIndex < tempList.Count) { sportsIndex = MathUtils.Addition(sportsIndex, 1); _uSportsCombat = tempList[tempList.Count - sportsIndex] ?? new SportsCombat(); _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer(); _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0); if (_combatProcessList.DefenseList.Count > 0) { _npcTalPriority = CombatHelper.TotalPriorityNum(_combatProcessList.DefenseList[0].UserID, 0); } } } else if (!string.IsNullOrEmpty(toUserID)) { UserHelper.ChechDailyRestrain(ContextUser.UserID); if (ContextUser.UserID == toUserID) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } if (GetChallGeNum(ContextUser.UserID) <= 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St5107_ChallGeNumFull; return(false); } toGameUser = UserCacheGlobal.LoadOffline(toUserID); if (ContextUser.UseMagicID == 0 || toGameUser == null || toGameUser.UseMagicID == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic; return(false); } RankingHelper.SportSRewardGain(toUserID, toGameUser.RankID); //被挑战者的竞技排名 //todo 竞技场冷却时间清除 //var userQueueCache = new GameDataCacheSet<UserQueue>(); //var queueArray = userQueueCache.FindAll(Uid, m => m.QueueType == QueueType.JingJiTiaoZhan); //if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St5107_Colding; // return false; //} //if (queueArray.Count > 0) //{ // var userQueue = queueArray[0]; // userQueue.ColdTime = codeTime; // userQueue.TotalColdTime = codeTime; // userQueue.Timing = DateTime.Now; //} //else //{ // UserQueue queue = new UserQueue() // { // QueueID = Guid.NewGuid().ToString(), // QueueType = QueueType.JingJiTiaoZhan, // QueueName = QueueType.JingJiTiaoZhan.ToString(), // UserID = ContextUser.UserID, // ColdTime = codeTime, // IsSuspend = false, // TotalColdTime = codeTime, // Timing = DateTime.Now // }; // userQueueCache.Add(queue); // //queue.Append(); //} //次数限制修改 int sportNum = 0; UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID); if (dailyRestrain != null) { sportNum = MathUtils.Addition(dailyRestrain.Funtion9, 1, int.MaxValue); dailyRestrain.Funtion9 = sportNum; //dailyRestrain.Update(); } else { sportNum = 1; } TriggerSportCombat(ContextUser, toGameUser, sportNum, ref sportsPrizeStr, userMail); var tempList = ContextUser.GetSportsCombat(); if (tempList.Count > 0) { _uSportsCombat = tempList[tempList.Count - 1] ?? new SportsCombat(); _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer(); } //日常任务-竞技 TaskHelper.TriggerDailyTask(Uid, 4006); _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0); _npcTalPriority = CombatHelper.TotalPriorityNum(toUserID, 0); } else { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } userMail.GameCoin = _uSportsCombat.RewardGoin; userMail.Obtion = _uSportsCombat.RewardObtian; var tjxMailService = new TjxMailService(toGameUser); tjxMailService.Send(userMail); _selfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0); _defSelfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(toUserID, 1); _selfAbilityEffectList.AddRange(_defSelfAbilityEffectList); return(true); }