/// <summary> /// 捐献数量,贡献声望 /// </summary> /// <param name="guild"></param> /// <param name="member"></param> /// <param name="wholeNum"></param> private void GetAddDonate(UserGuild guild, GuildMember member, int wholeNum) { guild.CurrDonateNum = MathUtils.Addition(guild.CurrDonateNum, wholeNum); //guild.Update(); if (donateType == 1) { ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, totalDonateNum); member.DonateCoin = MathUtils.Addition(member.DonateCoin, totalDonateNum); } else if (donateType == 2) { ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, totalDonateNum); member.DonateGold = MathUtils.Addition(member.DonateGold, totalDonateNum); } ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, wholeNum); //ContextUser.Update(); member.Contribution = MathUtils.Addition(member.Contribution, wholeNum); member.TotalContribution = MathUtils.Addition(member.TotalContribution, wholeNum); //member.Update(); UserHelper.UserGuildUpLv(member.GuildID, wholeNum); //公会添加经验,升级 GuildMemberLog.AddLog(member.GuildID, new MemberLog { UserID = ContextUser.UserID, IdolID = 0, LogType = 1, GainObtion = wholeNum, Experience = wholeNum, GainAura = 0, InsertDate = DateTime.Now }); }
/// <summary> /// 公会贡献 /// </summary> public static void Contribution(string userID, int experience) { var memberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.UserID == userID); if (memberArray.Count > 0) { GuildMember member = memberArray[0]; if (DateTime.Now.Date == member.RefreshDate.Date) { member.Contribution = MathUtils.Addition(member.Contribution, experience, int.MaxValue); } else { member.Contribution = experience; } member.TotalContribution = MathUtils.Addition(member.TotalContribution, experience, int.MaxValue); //member.Update(); UserGuild userGuild = new ShareCacheStruct <UserGuild>().FindKey(member.GuildID); if (userGuild != null) { GuildLvInfo lvInfo = new ConfigCacheSet <GuildLvInfo>().FindKey(MathUtils.Addition(userGuild.GuildLv, 1, int.MaxValue)); userGuild.CurrExperience = MathUtils.Addition(userGuild.CurrExperience, experience, int.MaxValue); if (lvInfo != null) { if (userGuild.CurrExperience >= lvInfo.UpExperience) { userGuild.CurrExperience = MathUtils.Subtraction(userGuild.CurrExperience, lvInfo.UpExperience, 0); userGuild.GuildLv = (short)MathUtils.Addition(userGuild.GuildLv, 1, int.MaxValue); } } //userGuild.Update(); } GuildMemberLog.AddLog(member.GuildID, new MemberLog { UserID = userID, IdolID = 0, LogType = 1, GainObtion = experience, Experience = experience, GainAura = 0, InsertDate = DateTime.Now }); } }
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); }
public override bool TakeAction() { UserHelper.ChecheDailyContribution(ContextUser.MercenariesID, ContextUser.UserID); chaoShengNum = ConfigEnvSet.GetInt("GuildMember.QiXingZhaoSheng"); var guidCacheSet = new ShareCacheStruct <GuildMember>(); GuildMember member = guidCacheSet.FindKey(ContextUser.MercenariesID, ContextUser.UserID); if (member != null) { List <GuildMember> gmemberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.GuildID == member.GuildID && m.IsDevil == 1); foreach (GuildMember guildMember in gmemberArray) { if (guildMember.DevilDate.Date != DateTime.Now.Date) { guildMember.IsDevil = 2; guildMember.DevilNum = 0; } } memberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.GuildID == member.GuildID && m.IsDevil == 1 && (DateTime.Now.Date == m.DevilDate.Date)); foreach (GuildMember guildMember in memberArray) { currNum = MathUtils.Addition(currNum, guildMember.CurrNum, int.MaxValue); if (guildMember.UserID == ContextUser.UserID) { isPilgrimage = 1; } } int totalNum = MathUtils.Addition(memberArray.Count, currNum, int.MaxValue); if (totalNum >= 7) { isSuccess = 1; foreach (GuildMember guildMember in memberArray) { guildMember.IsDevil = 2; if (guildMember.DevilNum <= 1) { GameUser gameUser = UserCacheGlobal.CheckLoadUser(guildMember.UserID); if (gameUser != null) { gameUser.ObtainNum = MathUtils.Addition(gameUser.ObtainNum, chaoShengNum, int.MaxValue); UserHelper.Contribution(guildMember.UserID, chaoShengNum); GuildMemberLog.AddLog(member.GuildID, new MemberLog() { UserID = guildMember.UserID, IdolID = 0, LogType = 1, GainObtion = chaoShengNum, Experience = chaoShengNum, GainAura = 0, InsertDate = DateTime.Now, }); } else { return(false); } } guildMember.CurrNum = 0; } } else { isSuccess = 2; } } return(true); }
public override bool TakeAction() { if (string.IsNullOrEmpty(ContextUser.MercenariesID)) { return(false); } if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.GuildMemberShangSuHeXiang) && idolID == 2) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion; return(false); } if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.GuildMemberShangTianMuXiang) && idolID == 3) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion; return(false); } GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID); if (member != null) { GuildIdolInfo idolInfo = new ShareCacheStruct <GuildIdolInfo>().FindKey(idolID); var memberLog = new ShareCacheStruct <GuildMemberLog>().FindKey(ContextUser.MercenariesID) ?? new GuildMemberLog(); List <MemberLog> guildLogArray = memberLog.GetLog(u => u.UserID == ContextUser.UserID && DateTime.Now.Date == u.InsertDate.Date); UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID); if (guildLogArray.Count > 0 && userRestrain.Funtion6 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.BangPaiShangXiang) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6012_HasIncenseToday; return(false); } if (idolInfo.UseExpNum != 0 && ContextUser.ExpNum <= idolInfo.UseExpNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_ExpNumNotEnough; return(false); } else if (idolInfo.UseGold != 0 && ContextUser.GoldNum < idolInfo.UseGold) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } //UserGuild userGuild = new ShareCacheStruct<UserGuild>().FindKey(guildID); userRestrain.Funtion6 = MathUtils.Addition(userRestrain.Funtion6, 1, int.MaxValue); //userRestrain.Update(); UpIdolLv(ContextUser.MercenariesID, idolInfo.GainAura); ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, idolInfo.UseGold, int.MaxValue); ContextUser.ExpNum = MathUtils.Subtraction(ContextUser.ExpNum, idolInfo.UseExpNum, 0); ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, idolInfo.GainObtion, int.MaxValue); //ContextUser.Update(); UserHelper.UserGuildUpLv(ContextUser.MercenariesID, idolInfo.GainObtion); if (DateTime.Now.Date == member.IncenseDate.Date) { member.GainBlessing = idolInfo.GainBlessing; member.IncenseNum = MathUtils.Addition(member.IncenseNum, 1, int.MaxValue); member.Contribution = MathUtils.Addition(member.Contribution, idolInfo.GainObtion, int.MaxValue); } else { member.IncenseNum = 1; member.GainBlessing = idolInfo.GainBlessing; member.Contribution = idolInfo.GainObtion; } member.TotalContribution = MathUtils.Addition(member.TotalContribution, idolInfo.GainObtion, int.MaxValue); member.IncenseDate = DateTime.Now; //member.Update(); GuildMemberLog.AddLog(member.GuildID, new MemberLog() { UserID = ContextUser.UserID, IdolID = idolID, LogType = 2, GainObtion = idolInfo.GainObtion, Experience = idolInfo.GainObtion, GainAura = idolInfo.GainAura, InsertDate = DateTime.Now, }); } 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; }