public static void UserShengJiTaRank() { Ranking<UserRank> rankList = RankingFactory.Get<UserRank>(ShengJiTaRanking.RankingKey); if (rankList != null) { if (DateTime.Now.Hour == 0) { foreach (UserRank userRank in rankList) { GameUser usergame = new PersonalCacheStruct<GameUser>().FindKey(userRank.UserID); if (usergame != null && userRank.ScoreStar>0) { // 信件通知玩家 “您在XX-XX的“勇闯圣吉塔”活动中名列XX榜第N,排名奖励M金币已经发送到您的账号中,请及时查收!” TjxMailService mailService = new TjxMailService(usergame); var mail = new UserMail(Guid.NewGuid()); mail.UserId = userRank.UserID.ToInt(); mail.MailType = (int)MailType.System; mail.ToUserID = userRank.UserID.ToInt(); mail.FromUserName = LanguageManager.GetLang().St_SystemMailTitle; mail.Title = LanguageManager.GetLang().St_SystemMailTitle; mail.SendDate = DateTime.Now; IGameLanguage gameLanguage = LanguageManager.GetLang(); SJTRankRewarInfo SJTRankRewar = new ShareCacheStruct<SJTRankRewarInfo>().FindKey(userRank.SJTRankId, userRank.SJTRankType.ToInt()); if (SJTRankRewar != null ) { if (usergame.UserLv >= 10 && usergame.UserLv < 30) { usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold; mail.Content = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaQintTong, userRank.SJTRankId, SJTRankRewar.GiftGold); } if (usergame.UserLv >= 30 && usergame.UserLv < 54) { usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold; mail.Content = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaBaiYin, userRank.SJTRankId, SJTRankRewar.GiftGold); } if (usergame.UserLv >= 55) { usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold; mail.Content = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaHuangJin, userRank.SJTRankId, SJTRankRewar.GiftGold); } mailService.Send(mail); } } } } } }
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 void Process(JsonParameter[] paramList) { JsonParameterList parameters = JsonParameter.Convert(paramList); string op = parameters["op"]; string[] UserList = Convert.ToString(parameters["UserID"]).Split(new char[] { ',' }); string itemPackage = Convert.ToString(parameters["Item"]); string crystalList = Convert.ToString(parameters["Crystal"]); string sparePackage = Convert.ToString(parameters["SparePackage"]); string enchantPackage = Convert.ToString(parameters["EnchantPackage"]); int obtainNum = 0; if (parameters["ObtainNum"].Length > 0) { obtainNum = Convert.ToInt32(parameters["ObtainNum"]); } short energyNum = 0; if (parameters["EnergyNum"].Length > 0) { energyNum = Convert.ToInt16(parameters["EnergyNum"]); } int gameCoin = 0; if (parameters["GameCoin"].Length > 0) { gameCoin = Convert.ToInt32(parameters["GameCoin"]); } int gold = 0; if (parameters["Gold"].Length > 0) { gold = Convert.ToInt32(parameters["Gold"]); } int expNum = 0; if (parameters["ExpNum"].Length > 0) { expNum = Convert.ToInt32(parameters["ExpNum"]); } int vipLv = 0; if (parameters["VipLv"].Length > 0) { vipLv = Convert.ToInt32(parameters["VipLv"]); } int gainBlessing = 0; if (parameters["GainBlessing"].Length > 0) { gainBlessing = Convert.ToInt32(parameters["GainBlessing"]); } int honourNum = 0; if (parameters["HonourNum"].Length > 0) { honourNum = Convert.ToInt32(parameters["HonourNum"]); } string mailContent = Convert.ToString(parameters["MailContent"]); int opUserID = Convert.ToInt32(parameters["OpUserID"]); //var cacheSetUserItem = new GameDataCacheSet<UserItemPackage>(); var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>(); var itemArray = itemPackage.Split(','); foreach (string str in UserList) { try { int userID = str.Trim().ToInt(); var user = new GameDataCacheSet<GameUser>().FindKey(str); if(user!=null) { user.GiftGold = MathUtils.Addition(user.GiftGold, gold); user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum); user.EnergyNum = MathUtils.Addition(user.EnergyNum, energyNum); user.GameCoin = MathUtils.Addition(user.GameCoin, gameCoin); user.ExpNum = MathUtils.Addition(user.ExpNum, expNum); user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum); } foreach (var item in itemArray) { if(item.Split('=').Length==2) { var itemInfo = cacheSetItemInfo.FindKey(item.Split('=')[0]); if(itemInfo!=null) { UserItemHelper.AddUserItem(str, item.Split('=')[0].ToInt(), item.Split('=')[1].ToInt()); } } } Guid newGuid = Guid.NewGuid(); UserTakePrize userPrizeLog = new UserTakePrize { ID = newGuid.ToString(), UserID = userID, ObtainNum = obtainNum, EnergyNum = energyNum, GameCoin = gameCoin, Gold = gold, ExpNum = expNum, VipLv = vipLv, GainBlessing = gainBlessing, ItemPackage = itemPackage, CrystalPackage = crystalList, SparePackage = sparePackage, EnchantPackage = enchantPackage, MailContent = mailContent, IsTasked = false, TaskDate = MathUtils.SqlMinDate, OpUserID = opUserID, CreateDate = DateTime.Now, HonourNum = honourNum, Items = itemPackage, }; var cacheSet = new ShareCacheStruct<UserTakePrize>(); cacheSet.Add(userPrizeLog, GameEnvironment.CacheGlobalPeriod); cacheSet.Update(); PutCrystal(crystalList.Split(','), str); // 发送系统信件 UserMail userMail = new UserMail(newGuid); userMail.UserId = userID; userMail.MailType = (int)MailType.System; userMail.Title = LanguageManager.GetLang().St_SystemMailTitle; userMail.Content = mailContent; userMail.SendDate = DateTime.Now; TjxMailService mailService=new TjxMailService(user); mailService.Send(userMail); } catch (Exception ex) { new BaseLog().SaveLog(ex); } } }
public override bool TakeAction() { var cacheSet = new ShareCacheStruct<UserFriends>(); if (_friendId != "" && _friendId != ContextUser.UserID) { //找到本玩家的数据 List<UserFriends> friendArray = cacheSet.FindAll(m => m.UserID == ContextUser.UserID); int friendNum = ConfigEnvSet.GetInt("UserFriends.MaxFriendNum"); //添加的好友上限 if (friendArray.Count >= friendNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_TheMaximumReachedAFriend; return false; } //查看是否在user库中有该玩家 GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId); if (userInfo == null) { UserCacheGlobal.LoadOffline(_friendId); userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId); } if (userInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_NotFriendsUserID; return false; } //在好友表中查找本玩家 和添加好友的关系 var userFriend = cacheSet.FindKey(ContextUser.UserID, _friendId); var userFriend1 = cacheSet.FindKey(_friendId, ContextUser.UserID); //同意 if (_ops == 1) { //有信息表 没信息表 if (userFriend == null) { //创建新的数据 并且添加成关注类型 var friends = new UserFriends { UserID = ContextUser.UserID, FriendID = _friendId, FriendType = FriendType.Friend }; cacheSet.Add(friends); //todo test friends.ChatTime = DateTime.Now; }else { //玩家原来就有数据 //判断两个玩家的关系 if (userFriend.FriendType == FriendType.Friend) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasAFriendIn; return false; } userFriend.FriendType = FriendType.Friend; } //判断对方是否有和本玩家的数据 如果没有创建 有改状态 if (userFriend1 == null) { var friends2 = new UserFriends { UserID = _friendId, FriendID = ContextUser.UserID, FriendType = FriendType.Friend, }; cacheSet.Add(friends2); //todo test friends2.ChatTime = DateTime.Now; } else { userFriend1.FriendType = FriendType.Friend; } //加为好友成功后发送一条邮件 try { Guid newGuid = Guid.NewGuid(); UserMail userMail = new UserMail(newGuid); userMail.UserId = Int32.Parse(_friendId); userMail.MailType = (int)MailType.Friends; userMail.Title = LanguageManager.GetLang().St_AskFirendMailTitle; userMail.Content = string.Format(LanguageManager.GetLang().St_FirendNotice, ContextUser.NickName); userMail.SendDate = DateTime.Now; userMail.FromUserId = Int32.Parse(ContextUser.UserID); userMail.FromUserName = ContextUser.NickName; TjxMailService mailService = new TjxMailService(ContextUser); mailService.Send(userMail); var noticeMail = mailService.ReadMail(ContextUser.UserID, _mailId); noticeMail.ReplyStatus = 1; } catch (Exception) { } }else { //不同意 TjxMailService mailService = new TjxMailService(ContextUser); var noticeMail = mailService.ReadMail(ContextUser.UserID, _mailId); noticeMail.ReplyStatus = 1; } } return true; }
public override bool TakeAction() { var cacheSet = new ShareCacheStruct<UserFriends>(); _isSuccess = 1; if (_friendId != "") { //找到本玩家的数据 List<UserFriends> friendArray = cacheSet.FindAll(m => m.UserID == ContextUser.UserID); int friendNum = ConfigEnvSet.GetInt("UserFriends.MaxFriendNum"); //添加的好友上限 if (friendArray.Count >= friendNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_TheMaximumReachedAFriend; return false; } //查看是否在user库中有该玩家 GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId); if (userInfo == null) { UserCacheGlobal.LoadOffline(_friendId); userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId); } if (userInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_NotFriendsUserID; return false; } //在好友表中查找本玩家 和添加好友的关系 var userFriend = cacheSet.FindKey(ContextUser.UserID, _friendId); var userFriend1 = cacheSet.FindKey(_friendId, ContextUser.UserID); if (userFriend == null) { //创建新的数据 并且添加成关注类型 var friends = new UserFriends { UserID = ContextUser.UserID, FriendID = _friendId, FriendType = FriendType.Attention }; cacheSet.Add(friends, GameEnvironment.CacheGlobalPeriod); //todo test friends.ChatTime = DateTime.Now; } //如果玩家数据不为空 else { //判断两个玩家的关系 if (userFriend.FriendType == FriendType.Friend) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasAFriendIn; return false; } ////如果已经发送请求就不在继续发 //if (userFriend.FriendType == FriendType.Attention) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_FirendNoticeTip; // return false; //} //加好友都是变为关注 从仇敌那里也能转换为关注 if (userFriend.FriendType != FriendType.Friend) { userFriend.FriendType = FriendType.Attention; } } //判断对方是否有和本玩家的数据 如果没有创建 有改状态 if (userFriend1 == null) { var friends2 = new UserFriends { UserID = _friendId, FriendID = ContextUser.UserID, FriendType = FriendType.Fans, }; cacheSet.Add(friends2, GameEnvironment.CacheGlobalPeriod); //todo test friends2.ChatTime = DateTime.Now; } // 发送系统信件 try { Guid newGuid = Guid.NewGuid(); UserMail userMail = new UserMail(newGuid); userMail.UserId = Int32.Parse(_friendId); userMail.MailType = (int)MailType.Friends; userMail.Title = LanguageManager.GetLang().St_AskFirendMailTitle; userMail.Content = string.Format(LanguageManager.GetLang().St_AskFirendTip, ContextUser.NickName); userMail.SendDate = DateTime.Now; userMail.IsReply = true; userMail.ReplyStatus = 0; userMail.FromUserId = Int32.Parse(ContextUser.UserID); userMail.FromUserName = ContextUser.NickName; TjxMailService mailService = new TjxMailService(ContextUser); mailService.Send(userMail); } catch (Exception) { } } //上传的好友名字不为空 else if (_friendName != null) { List<UserFriends> friendArray = cacheSet.FindAll(m => m.UserID == ContextUser.UserID); int friendNum = ConfigEnvSet.GetInt("UserFriends.MaxFriendNum"); if (friendArray.Count >= friendNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_TheMaximumReachedAFriend; return false; } GameUser friend = null; new GameDataCacheSet<GameUser>().Foreach((personalId, key, user) => { if (user.NickName == _friendName) { friend = user; return false; } return true; }); if (friend != null) { GameUser gameUser = new GameDataCacheSet<GameUser>().FindKey(friend.UserID); UserFriends userFriend = cacheSet.FindKey(ContextUser.UserID, _friendId); if (userFriend != null) { if (userFriend.FriendType == FriendType.Fans) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasTheFansIn; return false; } else if (userFriend.FriendType == FriendType.Blacklist) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasTheBlacklist; return false; } else { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasAFriendIn; return false; } } UserFriends friends = new UserFriends() { UserID = ContextUser.UserID, FriendID = gameUser.UserID, FriendType = FriendType.Attention }; cacheSet.Add(friends, GameEnvironment.CacheGlobalPeriod); UserFriends friends2 = new UserFriends() { UserID = gameUser.UserID, FriendID = ContextUser.UserID, FriendType = FriendType.Fans, }; cacheSet.Add(friends2, GameEnvironment.CacheGlobalPeriod); } else { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St9103_DoesNotExistTheUser; return false; } } return true; }