protected override async void Run(Session session, C2G_GetUserInfo_Req message, Action <G2C_GetUserInfo_Ack> reply) { G2C_GetUserInfo_Ack response = new G2C_GetUserInfo_Ack(); try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; reply(response); return; } //查询用户信息 DBProxyComponent dbProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); UserInfo userInfo = await dbProxyComponent.Query <UserInfo>(message.UserID, false); response.NickName = userInfo.NickName; response.Wins = userInfo.Wins; response.Loses = userInfo.Loses; response.Money = userInfo.Money; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_GetUserInfo_Req message, Action <G2C_GetUserInfo_Back> reply) { G2C_GetUserInfo_Back response = new G2C_GetUserInfo_Back(); try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; //Log.Debug("登陆错误"); reply(response); return; } //查询用户信息 //需要给Gate服务器添加数据库代理组件 DBProxyComponent dbProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); UserInfo userInfo = await dbProxyComponent.Query <UserInfo>(message.UserID); //Log.Debug("玩家信息:" + JsonHelper.ToJson(userInfo)); response.NickName = userInfo.UserName; response.Money = userInfo.Money; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_JoinRoom message, Action <G2C_JoinRoom> reply) { G2C_JoinRoom response = new G2C_JoinRoom(); try { //验证合法性 if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; reply(response); return; } //获取房间信息 Room room = Game.Scene.GetComponent <RoomComponent>().Get(message.RoomId); if (room == null) { Log.Info($"房间不存在:{message.RoomId}"); response.Error = ErrorCode.ERR_NotFoundRoom; reply(response); return; } if (room.IsCanAddPlayer()) { Log.Info($"房间已经满人:{message.RoomId}"); response.Error = ErrorCode.ERR_RoomIsFull; reply(response); return; } //设置用户的房间ID User user = session.GetUser(); user.RoomID = room.RoomId; //返回参数设置 response.Room = new RoomInfo { PlayerCount = room.roomConfig.PlayerCount, GameCount = room.roomConfig.GameCount, GameScore = room.roomConfig.GameScore }; response.RoomId = room.RoomId; response.ChairID = room.GetNullChair(); reply(response); Log.Info("成功申请加入房间!!!"); //向游戏服务器发送玩家进入请求 ActorMessageSender actorProxy = Game.Scene.GetComponent <ActorMessageSenderComponent>().Get(room.Id); actorProxy.Send(new Actor_PlayerEnterRoom_Ntt() { PlayerID = user.Id, UserID = user.UserID, SessionID = session.Id, }); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, A1001_GetUserInfo_C2G message, Action <A1001_GetUserInfo_G2C> reply) { A1001_GetUserInfo_G2C response = new A1001_GetUserInfo_G2C(); try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_UserNotOnline; reply(response); return; } //获取玩家对象 User user = session.GetComponent <SessionUserComponent>().User; DBProxyComponent dbProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); UserInfo userInfo = await dbProxyComponent.Query <UserInfo>(user.UserID); response.UserName = userInfo.UserName; response.UserLevel = userInfo.UserLevel; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_ReturnLobby_Ntt message) { //验证Session if (!GateHelper.SignSession(session)) { return; } User user = session.GetComponent <SessionUserComponent>().User; //StartConfigComponent config = Game.Scene.GetComponent<StartConfigComponent>(); ActorMessageSenderComponent actorProxyComponent = Game.Scene.GetComponent <ActorMessageSenderComponent>(); //正在匹配中发送玩家退出匹配请求 //if (user.IsMatching) //{ // IPEndPoint matchIPEndPoint = config.MatchConfig.GetComponent<InnerConfig>().IPEndPoint; // Session matchSession = Game.Scene.GetComponent<NetInnerComponent>().Get(matchIPEndPoint); // await matchSession.Call(new G2M_PlayerExitMatch_Req() { UserID = user.UserID }); // user.IsMatching = false; //} //正在游戏中发送玩家退出房间请求 if (user.ActorID != 0) { ActorMessageSender actorProxy = actorProxyComponent.Get(user.ActorID); await actorProxy.Call(new Actor_PlayerExitRoom_Req() { UserID = user.UserID }); user.ActorID = 0; } }
protected override async ETTask Run(Session session, C2G_GetUserInfoInRoom_Req request, G2C_GetUserInfoInRoom_Back response, Action reply) { try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; //Log.Debug("登陆错误"); reply(); return; } //查询用户信息 //需要给Gate服务器添加数据库代理组件 DBProxyComponent dbProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); UserInfo userInfo = await dbProxyComponent.Query <UserInfo>(request.UserID); //Log.Debug("玩家信息:" + JsonHelper.ToJson(userInfo)); response.UserName = userInfo.UserName; reply(); await ETTask.CompletedTask; } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async ETTask Run(Session session, A1001_SetUserInfo_REQ request, A1001_SetUserInfo_ACK response, Action reply) { try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_UserNotOnline; reply(); return; } //获取玩家对象 User user = session.GetComponent <SessionUserComponent>().User; DBProxyComponent dbProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); UserInfo userInfo = await dbProxyComponent.Query <UserInfo>(user.UserID); response.Userinfo.Username = userInfo.UserName; response.Userinfo.Money = userInfo.Money; response.Userinfo.Level = userInfo.Level; reply(); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async ETTask Run(Session session, GetCharacter_C2G request, CharacterMessage_G2C response, Action reply) { try { // 验证Session if (!GateHelper.SignSession(session)) { response.Error = MMOErrorCode.ERR_UserNotOnline; reply(); return; } // 获取用户对象 User user = session.GetComponent <SessionUserComponent>().User; DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); List <Component> characters = await dbProxy.Query2 <Character>($"{{UserId:{request.UserId},CharaId:{request.CharaId}}}"); Character character = characters[0] as Character; response.Character = GateHelper.CharacterInfoByData(character); reply(); await ETTask.CompletedTask; } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_StartMatch_Req message, Action <G2C_StartMatch_Ack> reply) { G2C_StartMatch_Ack response = new G2C_StartMatch_Ack(); try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; reply(response); return; } User user = session.GetComponent <SessionUserComponent>().User; //验证玩家是否符合进入房间要求,默认为100底分局 RoomConfig roomConfig = RoomHelper.GetConfig(RoomLevel.Lv100); UserInfo userInfo = await Game.Scene.GetComponent <DBProxyComponent>().Query <UserInfo>(user.UserID, false); if (userInfo.Money < roomConfig.MinThreshold) { response.Error = ErrorCode.ERR_UserMoneyLessError; reply(response); return; } //这里先发送响应,让客户端收到后切换房间界面,否则可能会出现重连消息在切换到房间界面之前发送导致重连异常 reply(response); //向匹配服务器发送匹配请求 StartConfigComponent config = Game.Scene.GetComponent <StartConfigComponent>(); IPEndPoint matchIPEndPoint = config.MatchConfig.GetComponent <InnerConfig>().IPEndPoint; Session matchSession = Game.Scene.GetComponent <NetInnerComponent>().Get(matchIPEndPoint); M2G_PlayerEnterMatch_Ack m2G_PlayerEnterMatch_Ack = await matchSession.Call(new G2M_PlayerEnterMatch_Req() { PlayerID = user.InstanceId, UserID = user.UserID, SessionID = session.InstanceId, }) as M2G_PlayerEnterMatch_Ack; user.IsMatching = true; } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_StartMatch_Landlords_Req message, Action <G2C_StartMatch_Landlords_Back> reply) { G2C_StartMatch_Landlords_Back response = new G2C_StartMatch_Landlords_Back(); try { Log.Debug("玩家开始匹配"); //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; reply(response); return; } User user = session.GetComponent <SessionUserComponent>().User; //验证玩家是否符合进入房间要求,默认为100底分局 RoomConfig roomConfig = GateHelper.GetLandlordsConfig(RoomLevel.Lv100); UserInfo userInfo = await Game.Scene.GetComponent <DBProxyComponent>().Query <UserInfo>(user.UserID); if (userInfo.Money < roomConfig.MinThreshold) { response.Error = ErrorCode.ERR_UserMoneyLessError; reply(response); return; } reply(response); //获取斗地主专用Map服务器的Session //通知Map服务器创建新的Gamer Session LandlordsSession = GateHelper.GetLandlordsSession(); LandlordsSession.Send(new G2M_EnterMatch_Landords() { UserID = user.UserID, ActorIDofUser = user.InstanceId, ActorIDofClient = user.SelfGateSessionID }); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async ETTask Run(Session session, C2G_StartMatch_Req request, G2C_StartMatch_Back response, Action reply) { try { Log.Debug("玩家开始匹配"); //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; reply(); return; } //获取Gate服务器上绑定的User对象 User user = session.GetComponent <SessionUserComponent>().User; //验证玩家是否符合进入房间要求,默认为100底分局 RoomConfig roomConfig = GateHelper.GetLandlordsConfig(RoomLevel.Lv100); //获取User对象的UserInfo(用户信息)数据 UserInfo userInfo = await Game.Scene.GetComponent <DBProxyComponent>().Query <UserInfo>(user.UserID); //判断此对象的金币是否符合准备要求 if (userInfo.Douzi < roomConfig.MinThreshold) { response.Error = ErrorCode.ERR_UserMoneyLessError; reply(); return; } reply(); //获取斗地主Map服务器的Session //通知Map服务器创建地图上的Gamer,发送请求匹配通知 Session mapSession = GateHelper.GetMapSession(); mapSession.Send(new EnterMatchs_G2M() { UserID = user.UserID, GActorID = user.InstanceId, CActorID = user.GateSessionID }); await ETTask.CompletedTask; } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async ETTask Run(Session session, C2G_ReadyLand_Ntt message) { //验证Session if (!GateHelper.SignSession(session)) { return; } User user = session.GetComponent <SessionUserComponent>().User; StartConfigComponent config = Game.Scene.GetComponent <StartConfigComponent>(); ActorMessageSenderComponent actorProxyComponent = Game.Scene.GetComponent <ActorMessageSenderComponent>(); //通知Map服务器玩家准备游戏 if (user.ActorID != 0) { ActorMessageSender actorProxy = actorProxyComponent.Get(user.ActorID); actorProxy.Send(new Actor_GamerReady_Landlords()); user.ActorID = 0; } await ETTask.CompletedTask; }
protected override void Run(Session session, C2G_ReturnLobby_Ntt message) { //验证Session if (!GateHelper.SignSession(session)) { return; } User user = session.GetComponent <SessionUserComponent>().User; StartConfigComponent config = Game.Scene.GetComponent <StartConfigComponent>(); ActorMessageSenderComponent actorProxyComponent = Game.Scene.GetComponent <ActorMessageSenderComponent>(); //通知Map服务器玩家离开房间 if (user.ActorIDforClient != 0) { ActorMessageSender actorProxy = actorProxyComponent.Get(user.ActorIDforClient); actorProxy.Send(new Actor_PlayerExitRoom()); user.ActorIDforClient = 0; } }
protected override void Run(Session session, A1002_StartRobotMatch5V5_C2G message) { User user = session.GetComponent <SessionUserComponent>().User; //验证Session if (!GateHelper.SignSession(session)) { return; } //向随机Map服务器发送创建房间请求 Session gateSession = GateHelper.GetRandomMapSession(); B1001_CreateRobotMatch5V5_G2M create5V5 = new B1001_CreateRobotMatch5V5_G2M() { UserID = user.UserID, //用于标记玩家 ActorIDofUser = user.InstanceId, //用于给Gate发送消息 ActorIDofClient = user.SelfGateSessionID //用于给客户端发消息 }; gateSession.Send(create5V5); }
protected override async ETTask Run(Session session, A1002_SetUserInfo_C2G request, A1002_SetUserInfo_G2C response, Action reply) { try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_UserNotOnline; reply(); return; } DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); //获取User对象 User user = session.GetComponent <SessionUserComponent>().User; //查询获得用户信息数据对象 UserInfo userInfo = await dbProxy.Query <UserInfo>(user.UserID); userInfo.Phone = request.Phone; userInfo.Email = request.Email; userInfo.Sex = request.Sex; await dbProxy.Save(userInfo); response.Phone = userInfo.Phone; response.Email = userInfo.Email; response.Sex = userInfo.Sex; response.Title = userInfo.Title; reply(); await ETTask.CompletedTask; } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async ETTask Run(Session session, CreateNewCharacter_C2G request, CharacterMessage_G2C response, Action reply) { try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = MMOErrorCode.ERR_UserNotOnline; reply(); return; } // 限制最多可创建多少角色处理 int max = request.Max; if (max == 0) { max = 100; } if (request.Index > max) { response.Error = MMOErrorCode.ERR_CannotCreateMoreCharacter; reply(); return; } DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); //获取玩家对象 User user = session.GetComponent <SessionUserComponent>().User; //获取玩家所在大区编号 UserInfo userInfo = await dbProxy.Query <UserInfo>(user.UserId); int GateAppId = RealmHelper.GetGateAppIdFromUserId(userInfo.Id); userInfo.LastPlay = request.Index; //检查角色名是否可用 //会得到全部大区的同名角色 需遍历排除 List <ComponentWithId> result = await dbProxy.Query <Character>($"{{Name:'{request.Name}'}}"); foreach (var a in result) { if (RealmHelper.GetGateAppIdFromUserId(((Character)a).UserId) == GateAppId) { //出现同名角色 response.Error = MMOErrorCode.ERR_CreateNewCharacter; reply(); return; } } //新建角色数据 Character character = ComponentFactory.Create <Character, string, long>(request.Name, userInfo.Id); character.Race = request.Race; character.Class = request.Class; character.Name = request.Name; character.Level = 1; character.Map = 1001; character.Region = 03; character.X = request.X; character.Y = request.Y; character.Z = request.Z; character.Money = 0; character.Mail = 0; character.Index = request.Index; //构建同样的返回数据,减少前端再查询一次此角色数据 response.Character = GateHelper.CharacterInfoByData(character, false); //新角色默认装备 List <Component> equipInfo = await dbProxy.Query2 <GlobalInfo>($"{{Type:'{request.Class}Equip'}}"); foreach (GlobalInfo row in equipInfo) { character.Equipments = row.Equipments; response.Character.Equipments = To.RepeatedField <EquipInfo>(row.Equipments); } //存储数据 await dbProxy.Save(character); await dbProxy.Save(userInfo); reply(); await ETTask.CompletedTask; } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_CreateRoom message, Action <G2C_CreateRoom> reply) { G2C_CreateRoom response = new G2C_CreateRoom(); try { //验证合法性 if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; reply(response); return; } DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); User user = session.GetUser(); UserInfo userInfo = await dbProxy.Query <UserInfo>(user.UserID, false); if (userInfo.Money < message.Room.GameScore) { response.Error = ErrorCode.ERR_UserMoneyLessError; reply(response); return; } //创建房间 Room room = await RoomFactory.Create(message.Room.PlayerCount, message.Room.GameCount, message.Room.GameScore, session); //创建房间玩家对象 Gamer gamer = GamerFactory.Create(user.Id, user.UserID, room.RoomId, (ushort)room.Count); await gamer.AddComponent <MailBoxComponent>().AddLocation(); gamer.AddComponent <UnitGateComponent, long>(session.Id); //房间添加玩家 room.Add(gamer); //网关服务器和玩家对应 user.ActorID = gamer.Id; //返回房间信息给玩家 response.RoomId = room.RoomId; response.Room = message.Room; response.ChairID = (ushort)(room.Count - 1); Log.Info($"创建房间成功:--- {userInfo.NickName} ,房号:{room.RoomId}"); //返回给客户端 reply(response); //存储该用户房间的创建次数 RoomHistory roomInfo = await dbProxy.Query <RoomHistory>(user.UserID, false); if (roomInfo == null) { RoomHistory roomHistory = ComponentFactory.CreateWithId <RoomHistory>(userInfo.Id); roomHistory.CreateCount = 1; roomHistory.NickName = userInfo.NickName; await dbProxy.Save(roomHistory, false); } else { roomInfo.CreateCount += 1; await dbProxy.Save(roomInfo, false); } //连接游戏服务器 //StartConfigComponent config = Game.Scene.GetComponent<StartConfigComponent>(); //IPEndPoint GameIPEndPoint= config.GameConfig.GetComponent<InnerConfig>().IPEndPoint; //Session GameSession = Game.Scene.GetComponent<NetInnerComponent>().Get(GameIPEndPoint); //GS2G_EnterRoom gs2g_EnterRoom =await GameSession.Call(new G2GS_EnterRoom() //{ // PlayerId = user.Id, // UserID = user.UserID, // GateSessionId = session.Id //}) as GS2G_EnterRoom; } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, A0008_GetUserInfo_C2G message, Action <A0008_GetUserInfo_G2C> reply) { A0008_GetUserInfo_G2C response = new A0008_GetUserInfo_G2C(); try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_UserNotOnline; reply(response); return; } //获取玩家对象 User user = session.GetComponent <SessionUserComponent>().User; DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); UserInfo userInfo = await dbProxy.Query <UserInfo>(user.UserID); if (userInfo.CharacterID1 != 0) { Character character = await dbProxy.Query <Character>(userInfo.CharacterID1); response.Characters.Add(new CharacterInfo() { Name = character.Name, Level = character.Level, Career = character.Career, Pet = character.Pet, Skeleton = character.Skeleton, Weapon = character.Weapon, Region = character.Region, X = character.X, Y = character.Y, Z = character.Z, Head = character.Head, Chest = character.Chest, Hand = character.Hand, Feet = character.Feet, Money = character.Money, Mail = character.Mail }); } else { response.Characters.Add(new CharacterInfo()); } if (userInfo.CharacterID2 != 0) { Character character = await dbProxy.Query <Character>(userInfo.CharacterID2); response.Characters.Add(new CharacterInfo() { Name = character.Name, Level = character.Level, Career = character.Career, Pet = character.Pet, Skeleton = character.Skeleton, Weapon = character.Weapon, Region = character.Region, X = character.X, Y = character.Y, Z = character.Z, Head = character.Head, Chest = character.Chest, Hand = character.Hand, Feet = character.Feet, Money = character.Money, Mail = character.Mail }); } else { response.Characters.Add(new CharacterInfo()); } if (userInfo.CharacterID3 != 0) { Character character = await dbProxy.Query <Character>(userInfo.CharacterID3); response.Characters.Add(new CharacterInfo() { Name = character.Name, Level = character.Level, Career = character.Career, Pet = character.Pet, Skeleton = character.Skeleton, Weapon = character.Weapon, Region = character.Region, X = character.X, Y = character.Y, Z = character.Z, Head = character.Head, Chest = character.Chest, Hand = character.Hand, Feet = character.Feet, Money = character.Money, Mail = character.Mail }); } else { response.Characters.Add(new CharacterInfo()); } //设置上次游戏角色 response.LastPlay = userInfo.LastPlay; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, A0009_CreateNewCharacter_C2G message, Action <A0009_CreateNewCharacter_G2C> reply) { A0009_CreateNewCharacter_G2C response = new A0009_CreateNewCharacter_G2C(); try { //验证Session if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_UserNotOnline; reply(response); return; } //获取玩家对象 User user = session.GetComponent <SessionUserComponent>().User; //获取玩家所在大区编号 DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); UserInfo userInfo = await dbProxy.Query <UserInfo>(user.UserID); int GateAppId = RealmHelper.GetGateAppIdFromUserId(userInfo.Id); //检查角色名是否可用 //会得到全部大区的同名角色 需遍历排除 List <ComponentWithId> result = await dbProxy.Query <Character>($"{{Name:'{message.Name}'}}"); foreach (var a in result) { if (RealmHelper.GetGateAppIdFromUserId(((Character)a).UserID) == GateAppId) { //出现同名角色 response.Error = ErrorCode.ERR_CreateNewCharacter; reply(response); return; } } //检查玩家是否有资格创建新角色 bool canCreate = false; int characterSeat = message.Seat; //玩家请求创建的角色位置 switch (characterSeat) { case 1: if (userInfo.CharacterID1 == 0) { canCreate = true; } break; case 2: if (userInfo.CharacterID2 == 0) { canCreate = true; } break; case 3: if (userInfo.CharacterID3 == 0) { canCreate = true; } break; default: break; } //判定为无法创建角色时返回错误消息 if (!canCreate) { //理应不该出现这个错误 //当玩家位置满时 点击创建角色按钮应有提示 无法进入创建角色界面 Log.Error("玩家当前位置已有角色"); response.Error = ErrorCode.ERR_CreateNewCharacter; reply(response); return; } //新建角色数据 角色可以通过UserID来识别区号 可以不使用CreateWithId方法 Character character = ComponentFactory.CreateWithId <Character, long>(RealmHelper.GenerateId(), userInfo.Id); character.Name = message.Name; character.Level = 1; character.Career = message.Career; character.Pet = PetType.NonePet; character.Skeleton = message.Skeleton; switch (character.Career) //初始装备是绑定职业的 { case CareerType.Warror: character.Weapon = WeaponType.Sword; character.Head = HeadType.Head1; character.Chest = ChestType.Chest1; character.Hand = HandType.Hand1; character.Feet = FeetType.Feet1; break; case CareerType.Mage: character.Weapon = WeaponType.Wand; character.Head = HeadType.Head2; character.Chest = ChestType.Chest2; character.Hand = HandType.Hand2; character.Feet = FeetType.Feet2; break; } character.Region = RegionType.Village; //初始地图为村庄 character.X = 1; //设置初始坐标 character.Y = 2; character.Z = 3; character.Money = 10; character.Mail = 0; //存储数据 switch (characterSeat) { case 1: userInfo.CharacterID1 = character.Id; userInfo.LastPlay = 1; break; case 2: userInfo.CharacterID2 = character.Id; userInfo.LastPlay = 2; break; case 3: userInfo.CharacterID3 = character.Id; userInfo.LastPlay = 3; break; default: throw new Exception($"创建新角色错误:{userInfo.Id}"); } await dbProxy.Save(character); await dbProxy.Save(userInfo); Log.Debug($"新增一个角色{character.Id}"); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }