private static void LoadData(GameActive gameActive) { if ((gameActive.CombatStatus == CombatStatus.Wait || gameActive.CombatStatus == CombatStatus.Combat) && !gameActive.LoadSuccess) { if (!string.IsNullOrEmpty(gameActive.Broadcast)) { var broadcastService = new TjxBroadcastService(null); var msg = broadcastService.Create(NoticeType.Game, gameActive.Broadcast); if (gameActive.ActiveId == 11) { int invertal = (int)new TimeSpan(0, 0, gameActive.WaitMinutes, 0).TotalSeconds / 5; string startTime = DateTime.Now.ToString("HH:mm:ss"); string endTime = DateTime.Now.AddMinutes(gameActive.WaitMinutes).ToString("HH:mm:ss"); broadcastService.SendTimer(msg, startTime, endTime, true, invertal);//秒 } else { broadcastService.Send(msg); } } gameActive.LoadSuccess = true; if (gameActive.ActiveType == FunctionEnum.Booszhang) { BossCombat.InitBoss(gameActive); } else if (gameActive.ActiveType == FunctionEnum.Lintuzhang) { CountryCombat.Init(gameActive); } else if (gameActive.ActiveType == FunctionEnum.Multiplot) { PlotTeamCombat.Init(gameActive); } else if (gameActive.ActiveType == FunctionEnum.MorePlotCoin) { PlotTeamCombat.Init(gameActive); } else if (gameActive.ActiveType == FunctionEnum.MorePlotEnergy) { PlotTeamCombat.Init(gameActive); } } }
public void SendNotice(GameNotice notice, bool isRemove) { try { var cacheSet = new ShareCacheStruct <GameNotice>(); GameNotice gameNotice = cacheSet.FindKey(notice.NoticeID); if (isRemove) { if (gameNotice != null) { cacheSet.Delete(gameNotice); } } else { if (gameNotice == null) { gameNotice = new GameNotice(); gameNotice.NoticeID = Guid.NewGuid().ToString(); cacheSet.Add(gameNotice); gameNotice = cacheSet.FindKey(gameNotice.NoticeID); } gameNotice.Title = notice.Title; gameNotice.Content = notice.Content; gameNotice.ExpiryDate = notice.ExpiryDate; gameNotice.IsTop = notice.IsTop; gameNotice.IsBroadcast = notice.IsBroadcast; gameNotice.Creater = notice.Creater; gameNotice.CreateDate = notice.CreateDate; gameNotice.NoticeType = notice.NoticeType; if (gameNotice.IsBroadcast) { var broadcastService = new TjxBroadcastService(null); var msg = broadcastService.Create(NoticeType.System, gameNotice.Content); broadcastService.Send(msg); } } } catch (Exception ex) { new BaseLog().SaveLog("保存公告出错:", ex); throw; } }
public override bool TakeAction() { //List<UserQueue> queueArray = new PersonalCacheStruct<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TianXianStrong); //if (queueArray.Count > 0) //{ // int codeDate = queueArray[0].DoRefresh(); // if (codeDate > 0) // { // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St11002_Colding; // return false; // } //} UserExpedition userExpedition = new PersonalCacheStruct <UserExpedition>().FindKey(ContextUser.UserID); if (userExpedition != null && userExpedition.ExpeditionNum >= 10 && userExpedition.InsertDate.Date == DateTime.Now.Date) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St11002_ExpeditionFull; return(false); } if (userExpedition != null && userExpedition.DoRefresh() > 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St11002_Colding; return(false); } int sumGold = MathUtils.Addition((GetExpCodeTime(ContextUser.UserID) / 60), 1); if (isRemove == 1) { if (ContextUser.GoldNum < sumGold) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } codeTime = 0; ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, sumGold); } else if (isRemove == 2) { codeTime = GetExpCodeTime(ContextUser.UserID); //if (queueArray.Count > 0) //{ // queueArray[0].ColdTime = codeTime; // queueArray[0].TotalColdTime = codeTime; // queueArray[0].Timing = DateTime.Now; // //queueArray[0].Update(); //} //else //{ // UserQueue queue = new UserQueue() // { // QueueID = Guid.NewGuid().ToString(), // QueueType = QueueType.TianXianStrong, // QueueName = QueueType.TianXianStrong.ToString(), // UserID = ContextUser.UserID, // ColdTime = codeTime, // IsSuspend = false, // TotalColdTime = codeTime, // Timing = DateTime.Now, // }; // new PersonalCacheStruct<UserQueue>().Add(queue, ContextUser.UserID.ToInt()); //} } if (userExpedition == null) { userExpedition = new UserExpedition() { UserID = ContextUser.UserID, }; new PersonalCacheStruct <UserExpedition>().Add(userExpedition, ContextUser.UserID.ToInt()); } if (DateTime.Now.Date == userExpedition.InsertDate.Date) { userExpedition.ExpeditionNum = MathUtils.Addition(userExpedition.ExpeditionNum, 1, int.MaxValue); } else { userExpedition.ExpeditionNum = 1; } userExpedition.CodeTime = codeTime; userExpedition.InsertDate = DateTime.Now; ExpeditionInfo expInfo = new ShareCacheStruct <ExpeditionInfo>().FindKey(questionID); if (expInfo != null) { if (answerID == 1) { rewardShowArray = expInfo.RewardNum1.ToList(); } else if (answerID == 2) { rewardShowArray = expInfo.RewardNum2.ToList(); } GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID); foreach (RewardShow show in rewardShowArray) { if (show.RewardType == RewardType.Obtion) { if (member != null) { GuildMemberLog.AddLog(member.GuildID, new MemberLog() { UserID = ContextUser.UserID, LogType = 1, IdolID = 0, GainObtion = show.RewardNum, GainAura = 0, Experience = show.RewardNum, InsertDate = DateTime.Now }); UserHelper.Contribution(ContextUser.UserID, show.RewardNum); } ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, show.RewardNum, int.MaxValue); } else if (show.RewardType == RewardType.GameGoin) { ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, (show.RewardNum * ContextUser.UserLv), int.MaxValue); } else if (show.RewardType == RewardType.ExpNum) { ContextUser.ExpNum = MathUtils.Addition(ContextUser.ExpNum, show.RewardNum, int.MaxValue); } else if (show.RewardType == RewardType.Experience) { UserHelper.UserGeneralExp(ContextUser.UserID, (show.RewardNum * ContextUser.UserLv)); } else if (show.RewardType == RewardType.EnergyNum) { ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, (short)show.RewardNum, short.MaxValue); } else if (show.RewardType == RewardType.Gold) { ContextUser.GiftGold = MathUtils.Addition(ContextUser.GiftGold, show.RewardNum, int.MaxValue); } } string prizeContent = string.Empty; MysteryHelper.IsTriggerMyStery(ContextUser, MysteryType.Meiritanxian, out prizeContent); MysteryInfo mysteryInfo = new ShareCacheStruct <MysteryInfo>().FindKey(MysteryType.Meiritanxian); if (!string.IsNullOrEmpty(prizeContent) && mysteryInfo != null) { string prompt = string.Format(mysteryInfo.Prompt, prizeContent); string broadContent = string.Format(mysteryInfo.Broadcast, ContextUser.NickName, prizeContent); var broadcastService = new TjxBroadcastService(null); var msg = broadcastService.Create(NoticeType.System, broadContent); broadcastService.Send(msg); ErrorCode = 1; ErrorInfo = prompt; } } 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; }