public override bool TakeAction() { int needDiamond = ConfigEnvSet.GetInt("System.ChangeNicknameNeedDiamond"); if (GetBasis.DiamondNum < needDiamond) { return(true); } var nickNameCheck = new NickNameCheck(); var KeyWordCheck = new KeyWordCheck(); string msg; if (nickNameCheck.VerifyRange(newName, out msg) || KeyWordCheck.VerifyKeyword(newName, out msg) || nickNameCheck.IsExistNickName(newName, out msg)) { ErrorCode = Language.Instance.ErrorCode; ErrorInfo = msg; return(false); } UserHelper.ConsumeDiamond(Current.UserId, needDiamond); GetBasis.NickName = newName; // 这里刷新排行榜数据 var combat = UserHelper.FindRankUser(Current.UserId, RankType.Combat); combat.NickName = newName; var level = UserHelper.FindRankUser(Current.UserId, RankType.Level); level.NickName = newName; var fightvalue = UserHelper.FindRankUser(Current.UserId, RankType.FightValue); fightvalue.NickName = newName; var combo = UserHelper.FindRankUser(Current.UserId, RankType.Combo); combo.NickName = newName; receipt = true; return(true); }
protected override bool CreateUserRole(out IUser user) { user = null; UserBasisCache basis = UserHelper.FindUserBasis(UserId); if (basis == null) { var nickNameCheck = new NickNameCheck(); var KeyWordCheck = new KeyWordCheck(); string msg; if (nickNameCheck.VerifyRange(UserName, out msg) || KeyWordCheck.VerifyKeyword(UserName, out msg) || nickNameCheck.IsExistNickName(UserName, out msg)) { ErrorCode = Language.Instance.ErrorCode; ErrorInfo = msg; return(false); } basis = CreateRole(UserId, Sid, ServerID, Pid, RetailID, UserName, profession, HeadID); if (basis != null) { /// 邀请处理 if (!string.IsNullOrEmpty(unid)) { var selflist = Util.FindUserCenterUser(Pid, RetailID, ServerID); var inviterlist = Util.FindUserCenterUser(unid, RetailID, ServerID); if (inviterlist.Count > 0 && inviterlist[0].UserID != 0 && Pid != unid) { if (selflist.Count > 0 && string.IsNullOrEmpty(selflist[0].Unid)) { inviterUserId = inviterlist[0].UserID; selflist[0].Unid = unid; } } } } else { return(false); } nickNameCheck.OnCreateAfter(basis); } else { return(false); } UserLoginLog userLoginLog = new UserLoginLog(); userLoginLog.UserId = UserId.ToString(); userLoginLog.SessionID = Sid; userLoginLog.MobileType = MobileType; userLoginLog.ScreenX = ScreenX; userLoginLog.ScreenY = ScreenY; userLoginLog.RetailId = RetailID; userLoginLog.AddTime = DateTime.Now; userLoginLog.State = LoginStatus.Logined; userLoginLog.DeviceID = DeviceID; userLoginLog.Ip = GetRealIP(); userLoginLog.Pid = basis.Pid; userLoginLog.UserLv = basis.UserLv; var sender = DataSyncManager.GetDataSender(); sender.Send(new[] { userLoginLog }); user = new SessionUser(basis); // 记录删档测试登录老用户 GameRunStatus gameRunStatus = ConfigUtils.GetSetting("Game.RunStatus").ToEnum <GameRunStatus>(); if (gameRunStatus == GameRunStatus.DeleteFileTest) { OldUserLog record = new OldUserLog() { UserID = basis.UserID, OpenID = basis.Pid, NickName = basis.NickName, AvatarUrl = basis.AvatarUrl, CreateDate = DateTime.Now, }; //var oldUserSet = new ShareCacheStruct<OldUserRecord>(); //oldUserSet.AddOrUpdate(record); sender.Send(new[] { record }); MailData mail = new MailData() { ID = Guid.NewGuid().ToString(), Title = "《勇者之怒》删档测试通知", Sender = "系统", Date = DateTime.Now, Context = "尊敬的玩家,您好,欢迎您进入我们的游戏,目前游戏正在删档封测阶段,如果您在游戏中遇到任何问题,请及时联系qq 2602611792处理。\n" + " 本次测试时间为7月11日~7月18日,测试结束后,我们将清空所有玩家数据,请玩家牢记角色ID以及昵称,及时联系平台客服兑换奖励,没有获奖的玩家也可以在游戏正式上线时" + "使用测试时的账号登录游戏可以享受充值3倍钻石优惠以及领取老玩家大礼包一份,千万不要错过哟!", }; UserHelper.AddNewMail(basis.UserID, mail, false); } else if (gameRunStatus == GameRunStatus.OfficialOperation) { if (new MemoryCacheStruct <OldUserCache>().Find(t => (t.OpenID == basis.Pid)) != null) {// 是删档测试老用户发放奖励 //MailData mail = new MailData() //{ // ID = Guid.NewGuid().ToString(), // Title = "老用户回归奖励", // Sender = "系统", // Date = DateTime.Now, // Context = "感谢您再次登录勇者之怒,这是您的回归奖励!", //}; //UserHelper.AddNewMail(basis.UserID, mail, false); } } return(true); }
private PostParameter verifyDeliver(Dictionary <string, string> parms) { PostParameter param = new PostParameter(); int ResultCode = 0; string ResultString = "Successfully"; ResultStringBone bone = new ResultStringBone(); try { while (true) { parms.TryGetValue("ID", out _OperateName); if (_OperateName == "LevelRankingData") { parms.TryGetValue("UserID", out _value); int UserId = _value.ToInt(); parms.TryGetValue("UserName", out _value); string UserName = _value; var user = new ShareCacheStruct <UserCenterUser>().FindKey(UserId); if (user == null) { user = new ShareCacheStruct <UserCenterUser>().Find(t => t.NickName == UserName); if (user == null) { bone.AddStrBone("没有找到该用户"); break; } UserId = user.UserID; } var basis = UserHelper.FindUserBasis(UserId); if (basis == null) { bone.AddStrBone("没有找到该用户"); break; } var pay = UserHelper.FindUserPay(UserId); var attribute = UserHelper.FindUserAttribute(UserId); var friend = UserHelper.FindUserFriends(UserId); param.AddParam("UserID", basis.UserID.ToString()); param.AddParam("UserName", basis.NickName); param.AddParam("UserLv", basis.UserLv.ToString()); param.AddParam("VipLv", basis.VipLv.ToString()); param.AddParam("PayAmount", pay.PayMoney.ToString()); param.AddParam("RetailID", user.RetailID); param.AddParam("CreateDate", Util.FormatDate(basis.CreateDate)); param.AddParam("LastLoginDate", Util.FormatDate(basis.LoginDate)); param.AddParam("LoginNum", user.LoginNum.ToString()); param.AddParam("FightValue", attribute.FightValue.ToString()); param.AddParam("CombatRankID", basis.CombatRankID.ToString()); param.AddParam("GuildName", "暂无公会"); param.AddParam("FriendNum", friend.FriendsList.Count.ToString()); } if (_OperateName == "Query") { parms.TryGetValue("UserID", out _value); int UserId = _value.ToInt(); parms.TryGetValue("UserName", out _value); string UserName = _value; var user = new ShareCacheStruct <UserCenterUser>().FindKey(UserId); if (user == null) { user = new ShareCacheStruct <UserCenterUser>().Find(t => t.NickName == UserName); if (user == null) { bone.AddStrBone("没有找到该用户"); break; } UserId = user.UserID; } var basis = UserHelper.FindUserBasis(UserId); if (basis == null) { bone.AddStrBone("没有找到该用户"); break; } var pay = UserHelper.FindUserPay(UserId); var attribute = UserHelper.FindUserAttribute(UserId); var friend = UserHelper.FindUserFriends(UserId); param.AddParam("UserID", basis.UserID.ToString()); param.AddParam("UserName", basis.NickName); param.AddParam("UserLv", basis.UserLv.ToString()); param.AddParam("VipLv", basis.VipLv.ToString()); param.AddParam("PayAmount", pay.PayMoney.ToString()); param.AddParam("RetailID", user.RetailID); param.AddParam("CreateDate", Util.FormatDate(basis.CreateDate)); param.AddParam("LastLoginDate", Util.FormatDate(basis.LoginDate)); param.AddParam("LoginNum", user.LoginNum.ToString()); param.AddParam("FightValue", attribute.FightValue.ToString()); param.AddParam("CombatRankID", basis.CombatRankID.ToString()); param.AddParam("GuildName", "暂无公会"); param.AddParam("FriendNum", friend.FriendsList.Count.ToString()); param.AddParam("OpenID", user.OpenID); } else if (_OperateName == "Reset") { bool isResetEquip, isResetPackage, isResetSoul, isResetPay, isResetEventAward, isResetSkill, isResetAchievement, isResetTask, isResetCombat, isResetAttribute; parms.TryGetValue("UserID", out _value); int UserId = _value.ToInt(); parms.TryGetValue("IsResetEquip", out _value); isResetEquip = _value.ToBool(); parms.TryGetValue("IsResetPackage", out _value); isResetPackage = _value.ToBool(); parms.TryGetValue("IsResetSoul", out _value); isResetSoul = _value.ToBool(); parms.TryGetValue("IsResetPay", out _value); isResetPay = _value.ToBool(); parms.TryGetValue("IsResetEventAward", out _value); isResetEventAward = _value.ToBool(); parms.TryGetValue("IsResetSkill", out _value); isResetSkill = _value.ToBool(); parms.TryGetValue("IsResetAchievement", out _value); isResetAchievement = _value.ToBool(); parms.TryGetValue("IsResetTask", out _value); isResetTask = _value.ToBool(); parms.TryGetValue("isResetCombat", out _value); isResetCombat = _value.ToBool(); parms.TryGetValue("isResetAttribute", out _value); isResetAttribute = _value.ToBool(); var user = new ShareCacheStruct <UserCenterUser>().FindKey(UserId); if (user == null) { bone.AddStrBone("没有找到该用户"); break; } if (isResetEquip) { var equips = UserHelper.FindUserEquips(UserId); equips.ResetCache(); UserHelper.RefreshUserFightValue(UserId); } if (isResetPackage) { var package = UserHelper.FindUserPackage(UserId); package.ResetCache(); } if (isResetSoul) { var soul = UserHelper.FindUserSoul(UserId); soul.ResetCache(); UserHelper.RefreshUserFightValue(UserId); } if (isResetPay) { var pay = UserHelper.FindUserPay(UserId); pay.ResetCache(); } if (isResetEventAward) { var eventaward = UserHelper.FindUserEventAward(UserId); eventaward.ResetCache(); } if (isResetSkill) { var basis = UserHelper.FindUserBasis(UserId); var skill = UserHelper.FindUserSkill(UserId); skill.ResetCache(basis.Profession); } if (isResetAchievement) { var achievement = UserHelper.FindUserAchievement(UserId); achievement.ResetCache(); } if (isResetTask) { var task = UserHelper.FindUserTask(UserId); task.ResetCache(); } if (isResetCombat) { var combat = UserHelper.FindUserCombat(UserId); combat.ResetCache(); } if (isResetAttribute) { UserHelper.RefreshUserFightValue(UserId); } } else if (_OperateName == "Set") { string UserName; int UserLv, GoldNum, DiamondNum, AddItemID, AddItemNum, PayID, CombatCoinNum; int ElfID, ElfLevel, SkillID, SkillLevel, NoviceGuide, VitNum, SetDiamondNum; EquipID SetEquipID; int EquipLevel; int LevelUpLevel; parms.TryGetValue("UserID", out _value); int UserId = _value.ToInt(); parms.TryGetValue("UserName", out UserName); parms.TryGetValue("UserLv", out _value); UserLv = _value.ToInt(); parms.TryGetValue("GoldNum", out _value); GoldNum = _value.ToInt(); parms.TryGetValue("DiamondNum", out _value); DiamondNum = _value.ToInt(); parms.TryGetValue("AddItemID", out _value); AddItemID = _value.ToInt(); parms.TryGetValue("AddItemNum", out _value); AddItemNum = _value.ToInt(); parms.TryGetValue("PayID", out _value); PayID = _value.ToInt(); parms.TryGetValue("CombatCoinNum", out _value); CombatCoinNum = _value.ToInt(); parms.TryGetValue("ElfID", out _value); ElfID = _value.ToInt(); parms.TryGetValue("ElfLevel", out _value); ElfLevel = _value.ToInt(); parms.TryGetValue("SkillID", out _value); SkillID = _value.ToInt(); parms.TryGetValue("SkillLevel", out _value); SkillLevel = _value.ToInt(); parms.TryGetValue("EquipID", out _value); SetEquipID = _value.ToEnum <EquipID>(); parms.TryGetValue("EquipLevel", out _value); EquipLevel = _value.ToInt(); parms.TryGetValue("LevelUp", out _value); LevelUpLevel = _value.ToInt(); parms.TryGetValue("NoviceGuide", out _value); NoviceGuide = _value.ToInt(); parms.TryGetValue("VitNum", out _value); VitNum = _value.ToInt(); parms.TryGetValue("SetDiamondNum", out _value); SetDiamondNum = _value.ToInt(); var user = new ShareCacheStruct <UserCenterUser>().FindKey(UserId); if (user == null) { bone.AddStrBone("没有找到该用户"); break; } var basis = UserHelper.FindUserBasis(UserId); if (UserName != string.Empty) { var nickNameCheck = new NickNameCheck(); var KeyWordCheck = new KeyWordCheck(); string msg; if (nickNameCheck.VerifyRange(UserName, out msg) || KeyWordCheck.VerifyKeyword(UserName, out msg) || nickNameCheck.IsExistNickName(UserName, out msg)) { bone.AddStrBone(msg); } else { basis.NickName = UserName; user.NickName = UserName; } } if (UserLv != 0) { var list = new ShareCacheStruct <Config_RoleInitial>().FindAll(); if (UserLv <= list.Count) { basis.UserLv = UserLv; } else { bone.AddStrBone("输入等级超过最高级别"); } } if (GoldNum > 0) { GoldNum = Math.Min(GoldNum, 100000000); UserHelper.RewardsGold(UserId, GoldNum); } if (DiamondNum > 0) { DiamondNum = Math.Min(DiamondNum, 1000000); UserHelper.RewardsDiamond(UserId, DiamondNum, UpdateCoinOperate.NormalReward); } if (AddItemID > 0 && AddItemNum > 0) { var itemcfg = new ShareCacheStruct <Config_Item>().FindKey(AddItemID); if (itemcfg != null) { UserHelper.RewardsItem(UserId, AddItemID, AddItemNum); } else { bone.AddStrBone("无此物品"); } } if (PayID > 0) { var paycfg = new ShareCacheStruct <Config_Pay>().FindKey(PayID); if (paycfg != null) { if (!UserHelper.OnWebPay(UserId, PayID)) { bone.AddStrBone("发货失败"); } } else { bone.AddStrBone("充值ID错误"); } } if (CombatCoinNum > 0) { CombatCoinNum = Math.Min(CombatCoinNum, 1000000); UserHelper.RewardsCombatCoin(UserId, CombatCoinNum); } if (ElfID > 0 && ElfLevel >= 0) { var elfcfg = new ShareCacheStruct <Config_Elves>().Find(t => (t.ElvesID == ElfID && t.ElvesGrade == ElfLevel)); if (elfcfg == null) { bone.AddStrBone("精灵ID或等级错误"); } else { var elf = UserHelper.FindUserElf(UserId); var elfdata = elf.FindElf(ElfID); if (elfdata != null) { elfdata.Lv = ElfLevel; } else { UserHelper.RewardsElf(UserId, ElfID); elfdata = elf.FindElf(ElfID); elfdata.Lv = ElfLevel; } } } if (SkillID > 0 && SkillLevel >= 0) { var skilllevelcfg = new ShareCacheStruct <Config_SkillGrade>().Find(t => (t.SkillId == SkillID && t.SkillGrade == SkillLevel)); if (skilllevelcfg == null) { bone.AddStrBone("技能ID或等级错误"); } else { var skill = UserHelper.FindUserSkill(UserId); var skilldata = skill.FindSkill(SkillID); if (skilldata != null) { skilldata.Lv = SkillLevel; } else { if (skill.AddSkill(SkillID)) { skilldata = skill.FindSkill(SkillID); skilldata.Lv = SkillLevel; } } } } if (EquipLevel > 0) { var equip = UserHelper.FindUserEquips(UserId); var equipData = equip.FindEquipData(SetEquipID); if (equipData != null) { equipData.Lv = EquipLevel; } } if (LevelUpLevel > 0) { int startLevel = basis.UserLv; for (int i = 0; i < LevelUpLevel; ++i) { UserHelper.UserLevelUpCheck(UserId, startLevel + i); } } if (NoviceGuide > 0) { var task = UserHelper.FindUserTask(UserId); task.PlotId = NoviceGuide; } if (VitNum > 0) { UserHelper.RewardsVit(UserId, VitNum); } if (SetDiamondNum > 0) { int temp = basis.DiamondNum - SetDiamondNum; if (temp > 0) { UserHelper.ConsumeDiamond(UserId, temp); } else { UserHelper.RewardsDiamond(UserId, Math.Abs(temp), UpdateCoinOperate.NormalReward); } } } else if (_OperateName == "NewMail") { string MailTitle, MailContent; int AddItem1ID, AddItem1Num, AddItem2ID, AddItem2Num, AddItem3ID, AddItem3Num, AddItem4ID, AddItem4Num; CoinType AppendCoinType; string AppendCoinNum = "0"; parms.TryGetValue("UserID", out _value); int UserId = _value.ToInt(); parms.TryGetValue("MailTitle", out MailTitle); parms.TryGetValue("MailContent", out MailContent); parms.TryGetValue("AppendCoinType", out _value); AppendCoinType = _value.ToEnum <CoinType>(); parms.TryGetValue("AppendCoinNum", out AppendCoinNum); parms.TryGetValue("AddItem1ID", out _value); AddItem1ID = _value.ToInt(); parms.TryGetValue("AddItem1Num", out _value); AddItem1Num = _value.ToInt(); parms.TryGetValue("AddItem2ID", out _value); AddItem2ID = _value.ToInt(); parms.TryGetValue("AddItem2Num", out _value); AddItem2Num = _value.ToInt(); parms.TryGetValue("AddItem3ID", out _value); AddItem3ID = _value.ToInt(); parms.TryGetValue("AddItem3Num", out _value); AddItem3Num = _value.ToInt(); parms.TryGetValue("AddItem4ID", out _value); AddItem4ID = _value.ToInt(); parms.TryGetValue("AddItem4Num", out _value); AddItem4Num = _value.ToInt(); var user = new ShareCacheStruct <UserCenterUser>().FindKey(UserId); if (user == null) { bone.AddStrBone("没有找到该用户"); break; } var mailbox = UserHelper.FindUserMailBox(UserId); MailData mail = new MailData() { ID = Guid.NewGuid().ToString(), Title = MailTitle, Sender = "系统", Date = DateTime.Now, Context = MailContent, ApppendCoinType = (CoinType)AppendCoinType, ApppendCoinNum = string.IsNullOrEmpty(AppendCoinNum) ? "0" : AppendCoinNum, }; if (AddItem1ID > 0 && AddItem1Num > 0) { ItemData item = new ItemData() { ID = AddItem1ID, Num = AddItem1Num, }; mail.AppendItem.Add(item); } if (AddItem2ID > 0 && AddItem2Num > 0) { ItemData item = new ItemData() { ID = AddItem2ID, Num = AddItem2Num, }; mail.AppendItem.Add(item); } if (AddItem3ID > 0 && AddItem3Num > 0) { ItemData item = new ItemData() { ID = AddItem3ID, Num = AddItem3Num, }; mail.AppendItem.Add(item); } if (AddItem4ID > 0 && AddItem4Num > 0) { ItemData item = new ItemData() { ID = AddItem4ID, Num = AddItem4Num, }; mail.AppendItem.Add(item); } bool IsSucceed = true; foreach (var v in mail.AppendItem) { var itemcfg = new ShareCacheStruct <Config_Item>().FindKey(v.ID); if (itemcfg == null) { bone.AddStrBone("邮件附加道具错误"); IsSucceed = false; break; } } if (IsSucceed) { UserHelper.AddNewMail(UserId, mail); } } else if (_OperateName == "NewNotice") { string Content; NoticeMode Mode; parms.TryGetValue("Mode", out _value); Mode = (NoticeMode)_value.ToInt(); parms.TryGetValue("Content", out Content); if (!string.IsNullOrEmpty(Content)) { GlobalRemoteService.SendNotice(Mode, Content); } } else { bone.AddStrBone("该功能暂未实现"); } break; } } catch (Exception e) { ResultString = "Url参数格式错误"; TraceLog.WriteError(string.Format("{0} {1}", ResultString, e)); } if (!bone.bonestr.IsEmpty()) { ResultString = bone.bonestr; ResultCode = 1; } param.AddParam("OperateName", _OperateName); param.AddParam("ResultCode", ResultCode.ToString()); param.AddParam("ResultString", ResultString); return(param); }