From b558768c0efae21280691eddf49eece9b7726829 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 22 Dec 2023 10:58:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E5=B1=80=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/api_record.go | 32 ++++ modules/entertainment/model.go | 13 ++ modules/entertainment/modelrecord.go | 5 +- modules/entertainment/room.go | 2 +- pb/entertain_msg.pb.go | 215 +++++++++++++++++++++------ 5 files changed, 216 insertions(+), 51 deletions(-) create mode 100644 modules/entertainment/api_record.go diff --git a/modules/entertainment/api_record.go b/modules/entertainment/api_record.go new file mode 100644 index 000000000..a2e41f1b3 --- /dev/null +++ b/modules/entertainment/api_record.go @@ -0,0 +1,32 @@ +package entertainment + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" +) + +// 参数校验 +func (this *apiComp) RecordCheck(session comm.IUserSession, req *pb.EntertainRecordReq) (errdata *pb.ErrorData) { + + return +} + +// 记录获取 +func (this *apiComp) Record(session comm.IUserSession, req *pb.EntertainRecordReq) (errdata *pb.ErrorData) { + var ( + records []*pb.DBXxlRecord + err error + ) + + if errdata = this.RecordCheck(session, req); errdata != nil { + return + } + + if records, err = this.module.modelRecode.getXxlRecord(session.GetUserId()); err != nil { + return + } + session.SendMsg(string(this.module.GetType()), "record", &pb.EntertainRecordResp{ + Record: records, + }) + return +} diff --git a/modules/entertainment/model.go b/modules/entertainment/model.go index ba306eb0e..de967d964 100644 --- a/modules/entertainment/model.go +++ b/modules/entertainment/model.go @@ -64,6 +64,19 @@ func (this *modelComp) getEntertainmList(uid string) (result *pb.DBXXLData, err for _, v := range this.module.configure.GetInitGameConsumeSkill() { result.Skill[v] = 1 } + if user, e := this.module.ModuleUser.GetUser(uid); e == nil { + // 查询一次 写基本信息 + result.Uinfo = &pb.BaseUserInfo{ + Uid: uid, + Sid: user.Sid, + Name: user.Name, + Gender: user.Gender, + Skin: user.CurSkin, + Aframe: user.Curaframe, + Title: user.Curtitle, + Lv: user.Lv, + } + } err = this.Add(uid, result) } return result, err diff --git a/modules/entertainment/modelrecord.go b/modules/entertainment/modelrecord.go index 670fd998f..13deeb1f7 100644 --- a/modules/entertainment/modelrecord.go +++ b/modules/entertainment/modelrecord.go @@ -50,8 +50,9 @@ func (this *modelRecode) getXxlRecord(uid string) (results []*pb.DBXxlRecord, er cursor *mongo.Cursor ) results = make([]*pb.DBXxlRecord, 0) - - if cursor, err = this.DBModel.DB.Find(comm.TableEntertainRecode, bson.M{"uid": uid}, options.Find().SetSort(bson.M{"ctime": -1}), options.Find().SetLimit(int64(comm.MaxRankList))); err != nil { + if cursor, err = this.DBModel.DB.Find(comm.TableEntertainRecode, bson.M{"$or": []bson.M{{"p1": uid}, + {"p2": uid}}}, options.Find().SetSort(bson.M{"ctime": -1}), + options.Find().SetLimit(int64(comm.MaxRankList))); err != nil { this.module.Errorln(err) return } else { diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 7bef6d598..b16643983 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -623,7 +623,7 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { P1: this.player1.Userinfo.Uid, P2: this.player2.Userinfo.Uid, Uinfo1: this.player1.Userinfo, - Uinfo2: this.player1.Userinfo, + Uinfo2: this.player2.Userinfo, P1Score: this.player1.Score, P2Score: this.player2.Score, Win: winner.Userinfo.Uid, diff --git a/pb/entertain_msg.pb.go b/pb/entertain_msg.pb.go index bcb1fa522..d72444ad1 100644 --- a/pb/entertain_msg.pb.go +++ b/pb/entertain_msg.pb.go @@ -2544,6 +2544,92 @@ func (x *EntertainTaskRewardResp) GetAward() []*UserAtno { return nil } +// 战斗对局 +type EntertainRecordReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *EntertainRecordReq) Reset() { + *x = EntertainRecordReq{} + if protoimpl.UnsafeEnabled { + mi := &file_entertain_entertain_msg_proto_msgTypes[46] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EntertainRecordReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EntertainRecordReq) ProtoMessage() {} + +func (x *EntertainRecordReq) ProtoReflect() protoreflect.Message { + mi := &file_entertain_entertain_msg_proto_msgTypes[46] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EntertainRecordReq.ProtoReflect.Descriptor instead. +func (*EntertainRecordReq) Descriptor() ([]byte, []int) { + return file_entertain_entertain_msg_proto_rawDescGZIP(), []int{46} +} + +type EntertainRecordResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Record []*DBXxlRecord `protobuf:"bytes,1,rep,name=record,proto3" json:"record"` +} + +func (x *EntertainRecordResp) Reset() { + *x = EntertainRecordResp{} + if protoimpl.UnsafeEnabled { + mi := &file_entertain_entertain_msg_proto_msgTypes[47] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EntertainRecordResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EntertainRecordResp) ProtoMessage() {} + +func (x *EntertainRecordResp) ProtoReflect() protoreflect.Message { + mi := &file_entertain_entertain_msg_proto_msgTypes[47] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EntertainRecordResp.ProtoReflect.Descriptor instead. +func (*EntertainRecordResp) Descriptor() ([]byte, []int) { + return file_entertain_entertain_msg_proto_rawDescGZIP(), []int{47} +} + +func (x *EntertainRecordResp) GetRecord() []*DBXxlRecord { + if x != nil { + return x.Record + } + return nil +} + var File_entertain_entertain_msg_proto protoreflect.FileDescriptor var file_entertain_entertain_msg_proto_rawDesc = []byte{ @@ -2786,8 +2872,13 @@ var file_entertain_entertain_msg_proto_rawDesc = []byte{ 0x72, 0x6f, 0x67, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x74, 0x61, 0x73, 0x6b, 0x70, 0x72, 0x6f, 0x67, 0x65, 0x73, 0x73, 0x12, 0x1f, 0x0a, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, - 0x74, 0x6e, 0x6f, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6e, 0x6f, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x45, 0x6e, + 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, + 0x22, 0x3b, 0x0a, 0x13, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, + 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x58, 0x78, 0x6c, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2802,7 +2893,7 @@ func file_entertain_entertain_msg_proto_rawDescGZIP() []byte { return file_entertain_entertain_msg_proto_rawDescData } -var file_entertain_entertain_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 48) +var file_entertain_entertain_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 50) var file_entertain_entertain_msg_proto_goTypes = []interface{}{ (*EntertainMatchReq)(nil), // 0: EntertainMatchReq (*EntertainMatchResp)(nil), // 1: EntertainMatchResp @@ -2850,52 +2941,56 @@ var file_entertain_entertain_msg_proto_goTypes = []interface{}{ (*EntertainRankResp)(nil), // 43: EntertainRankResp (*EntertainTaskRewardReq)(nil), // 44: EntertainTaskRewardReq (*EntertainTaskRewardResp)(nil), // 45: EntertainTaskRewardResp - nil, // 46: EntertainChangePush.CardEntry - nil, // 47: EntertainChangePush.SkillEntry - (*PlayerData)(nil), // 48: PlayerData - (*MapData)(nil), // 49: MapData - (*UserAtno)(nil), // 50: UserAtno - (*BoxData)(nil), // 51: BoxData - (*DBXXLData)(nil), // 52: DBXXLData - (*XxlPlayer)(nil), // 53: XxlPlayer + (*EntertainRecordReq)(nil), // 46: EntertainRecordReq + (*EntertainRecordResp)(nil), // 47: EntertainRecordResp + nil, // 48: EntertainChangePush.CardEntry + nil, // 49: EntertainChangePush.SkillEntry + (*PlayerData)(nil), // 50: PlayerData + (*MapData)(nil), // 51: MapData + (*UserAtno)(nil), // 52: UserAtno + (*BoxData)(nil), // 53: BoxData + (*DBXXLData)(nil), // 54: DBXXLData + (*XxlPlayer)(nil), // 55: XxlPlayer + (*DBXxlRecord)(nil), // 56: DBXxlRecord } var file_entertain_entertain_msg_proto_depIdxs = []int32{ - 48, // 0: EntertainStartGamePush.user1:type_name -> PlayerData - 48, // 1: EntertainStartGamePush.user2:type_name -> PlayerData - 49, // 2: EntertainStartGamePush.mpadata:type_name -> MapData - 49, // 3: EntertainOperatorRstPush.mpadata:type_name -> MapData - 48, // 4: EntertainOperatorRstPush.user1:type_name -> PlayerData - 48, // 5: EntertainOperatorRstPush.user2:type_name -> PlayerData - 48, // 6: EntertainGameOverPush.user1:type_name -> PlayerData - 48, // 7: EntertainGameOverPush.user2:type_name -> PlayerData - 49, // 8: EntertainGameOverPush.mpadata:type_name -> MapData - 50, // 9: EntertainGameOverPush.reward:type_name -> UserAtno - 51, // 10: EntertainGameOverPush.box:type_name -> BoxData - 48, // 11: EntertainEnterRoomPush.user1:type_name -> PlayerData - 48, // 12: EntertainEnterRoomPush.user2:type_name -> PlayerData - 49, // 13: EntertainReconnectResp.mpadata:type_name -> MapData - 48, // 14: EntertainReconnectResp.user1:type_name -> PlayerData - 48, // 15: EntertainReconnectResp.user2:type_name -> PlayerData - 49, // 16: EntertainRefreshPlatResp.mpadata:type_name -> MapData - 49, // 17: EntertainRefreshPush.mpadata:type_name -> MapData - 52, // 18: EntertainGetListResp.data:type_name -> DBXXLData - 52, // 19: EntertainRewardResp.data:type_name -> DBXXLData - 50, // 20: EntertainRewardResp.reward:type_name -> UserAtno - 46, // 21: EntertainChangePush.card:type_name -> EntertainChangePush.CardEntry - 47, // 22: EntertainChangePush.skill:type_name -> EntertainChangePush.SkillEntry - 48, // 23: EntertainJoinCreateRoomPush.user1:type_name -> PlayerData - 48, // 24: EntertainJoinCreateRoomPush.user2:type_name -> PlayerData - 51, // 25: EntertainBoxRewardResp.box:type_name -> BoxData - 50, // 26: EntertainBoxRewardResp.reward:type_name -> UserAtno - 52, // 27: EntertainReceiveResp.info:type_name -> DBXXLData - 50, // 28: EntertainReceiveResp.award:type_name -> UserAtno - 53, // 29: EntertainRankResp.players:type_name -> XxlPlayer - 50, // 30: EntertainTaskRewardResp.award:type_name -> UserAtno - 31, // [31:31] is the sub-list for method output_type - 31, // [31:31] is the sub-list for method input_type - 31, // [31:31] is the sub-list for extension type_name - 31, // [31:31] is the sub-list for extension extendee - 0, // [0:31] is the sub-list for field type_name + 50, // 0: EntertainStartGamePush.user1:type_name -> PlayerData + 50, // 1: EntertainStartGamePush.user2:type_name -> PlayerData + 51, // 2: EntertainStartGamePush.mpadata:type_name -> MapData + 51, // 3: EntertainOperatorRstPush.mpadata:type_name -> MapData + 50, // 4: EntertainOperatorRstPush.user1:type_name -> PlayerData + 50, // 5: EntertainOperatorRstPush.user2:type_name -> PlayerData + 50, // 6: EntertainGameOverPush.user1:type_name -> PlayerData + 50, // 7: EntertainGameOverPush.user2:type_name -> PlayerData + 51, // 8: EntertainGameOverPush.mpadata:type_name -> MapData + 52, // 9: EntertainGameOverPush.reward:type_name -> UserAtno + 53, // 10: EntertainGameOverPush.box:type_name -> BoxData + 50, // 11: EntertainEnterRoomPush.user1:type_name -> PlayerData + 50, // 12: EntertainEnterRoomPush.user2:type_name -> PlayerData + 51, // 13: EntertainReconnectResp.mpadata:type_name -> MapData + 50, // 14: EntertainReconnectResp.user1:type_name -> PlayerData + 50, // 15: EntertainReconnectResp.user2:type_name -> PlayerData + 51, // 16: EntertainRefreshPlatResp.mpadata:type_name -> MapData + 51, // 17: EntertainRefreshPush.mpadata:type_name -> MapData + 54, // 18: EntertainGetListResp.data:type_name -> DBXXLData + 54, // 19: EntertainRewardResp.data:type_name -> DBXXLData + 52, // 20: EntertainRewardResp.reward:type_name -> UserAtno + 48, // 21: EntertainChangePush.card:type_name -> EntertainChangePush.CardEntry + 49, // 22: EntertainChangePush.skill:type_name -> EntertainChangePush.SkillEntry + 50, // 23: EntertainJoinCreateRoomPush.user1:type_name -> PlayerData + 50, // 24: EntertainJoinCreateRoomPush.user2:type_name -> PlayerData + 53, // 25: EntertainBoxRewardResp.box:type_name -> BoxData + 52, // 26: EntertainBoxRewardResp.reward:type_name -> UserAtno + 54, // 27: EntertainReceiveResp.info:type_name -> DBXXLData + 52, // 28: EntertainReceiveResp.award:type_name -> UserAtno + 55, // 29: EntertainRankResp.players:type_name -> XxlPlayer + 52, // 30: EntertainTaskRewardResp.award:type_name -> UserAtno + 56, // 31: EntertainRecordResp.record:type_name -> DBXxlRecord + 32, // [32:32] is the sub-list for method output_type + 32, // [32:32] is the sub-list for method input_type + 32, // [32:32] is the sub-list for extension type_name + 32, // [32:32] is the sub-list for extension extendee + 0, // [0:32] is the sub-list for field type_name } func init() { file_entertain_entertain_msg_proto_init() } @@ -3458,6 +3553,30 @@ func file_entertain_entertain_msg_proto_init() { return nil } } + file_entertain_entertain_msg_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EntertainRecordReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_entertain_entertain_msg_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EntertainRecordResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -3465,7 +3584,7 @@ func file_entertain_entertain_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_entertain_entertain_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 48, + NumMessages: 50, NumExtensions: 0, NumServices: 0, },