From 526e32e7086b2206b5ba59c36348112111632b42 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 6 Sep 2022 17:00:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 + modules/battle/module.go | 26 ++--------- modules/moonfantasy/api_receive.go | 11 ++++- pb/battle_msg.pb.go | 75 +++++++++++++++++++++++++----- pb/moonfantasy_msg.pb.go | 47 ++++++++++--------- 5 files changed, 104 insertions(+), 57 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 60d646a29..8e6c71edc 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -137,5 +137,7 @@ type ( CreatePveBattle(session IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) ///创建pvb战斗 CreatePvbBattle(session IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) + //校验战报 + CheckBattleReport(session IUserSession, report *pb.BattleReport) (code pb.ErrorCode, iswin bool) } ) diff --git a/modules/battle/module.go b/modules/battle/module.go index 69aa0ba9a..464a9f425 100644 --- a/modules/battle/module.go +++ b/modules/battle/module.go @@ -58,15 +58,6 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE if record, code = this.modelBattle.createpve(session, pb.BattleType_pve, req); code != pb.ErrorCode_Success { return } - // this.pushbattle(session, &pb.BattleStartPush{ - // Id: record.Id, - // Btype: record.Btype, - // Ptype: record.Ptype, - // RedCompId: record.RedCompId, - // Redflist: record.Redflist, - // BlueCompId: record.BlueCompId, - // Buleflist: record.Buleflist, - // }) return } @@ -75,19 +66,10 @@ func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVE if record, code = this.modelBattle.createpve(session, pb.BattleType_pvb, req); code != pb.ErrorCode_Success { return } - // this.pushbattle(session, &pb.BattleStartPush{ - // Id: record.Id, - // Btype: record.Btype, - // Ptype: record.Ptype, - // RedCompId: record.RedCompId, - // Redflist: record.Redflist, - // BlueCompId: record.BlueCompId, - // Buleflist: record.Buleflist, - // }) return } -//推送战斗开始数据 -// func (this *Battle) pushbattle(session comm.IUserSession, resp *pb.BattleStartPush) { -// session.SendMsg(string(this.GetType()), "start", resp) -// } +//校验战报是否成功 +func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.BattleReport) (code pb.ErrorCode, iswin bool) { + return pb.ErrorCode_Success, true +} diff --git a/modules/moonfantasy/api_receive.go b/modules/moonfantasy/api_receive.go index ae0f9edf7..93ad23a3b 100644 --- a/modules/moonfantasy/api_receive.go +++ b/modules/moonfantasy/api_receive.go @@ -16,11 +16,12 @@ func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.Moonfantasy return } -///询问怪物是否可以挑战 +///领取战斗奖励 func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyReceiveReq) (code pb.ErrorCode, data proto.Message) { var ( boss *cfg.GameDreamlandBoosData award []*cfg.Gameatn = make([]*cfg.Gameatn, 0) + iswin bool err error ) @@ -29,9 +30,15 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei } if boss, err = this.module.configure.GetMonsterById(req.Monster); err != nil { code = pb.ErrorCode_ConfigNoFound + return + } + if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success { + return + } + if iswin { + code = pb.ErrorCode_MoonfantasyBattleNoWin return } - this.module.configure.GetDropReward(boss.Prize, award) this.module.DispenseRes(session, award, true) session.SendMsg(string(this.module.GetType()), "receive", &pb.MoonfantasyReceiveResp{Issucc: true}) diff --git a/pb/battle_msg.pb.go b/pb/battle_msg.pb.go index 023d4b38d..6764177b3 100644 --- a/pb/battle_msg.pb.go +++ b/pb/battle_msg.pb.go @@ -188,6 +188,45 @@ func (x *BattleInfo) GetBuleflist() []*DBBattleFormt { return nil } +//战报数据 +type BattleReport struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *BattleReport) Reset() { + *x = BattleReport{} + if protoimpl.UnsafeEnabled { + mi := &file_battle_battle_msg_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BattleReport) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BattleReport) ProtoMessage() {} + +func (x *BattleReport) ProtoReflect() protoreflect.Message { + mi := &file_battle_battle_msg_proto_msgTypes[2] + 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 BattleReport.ProtoReflect.Descriptor instead. +func (*BattleReport) Descriptor() ([]byte, []int) { + return file_battle_battle_msg_proto_rawDescGZIP(), []int{2} +} + var File_battle_battle_msg_proto protoreflect.FileDescriptor var file_battle_battle_msg_proto_rawDesc = []byte{ @@ -217,7 +256,8 @@ var file_battle_battle_msg_proto_rawDesc = []byte{ 0x09, 0x52, 0x0a, 0x62, 0x6c, 0x75, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x09, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x74, - 0x52, 0x09, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6c, 0x69, 0x73, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x52, 0x09, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x42, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -233,20 +273,21 @@ func file_battle_battle_msg_proto_rawDescGZIP() []byte { return file_battle_battle_msg_proto_rawDescData } -var file_battle_battle_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_battle_battle_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_battle_battle_msg_proto_goTypes = []interface{}{ (*BattlePVEReq)(nil), // 0: BattlePVEReq (*BattleInfo)(nil), // 1: BattleInfo - (PlayType)(0), // 2: PlayType - (BattleType)(0), // 3: BattleType - (*DBBattleFormt)(nil), // 4: DBBattleFormt + (*BattleReport)(nil), // 2: BattleReport + (PlayType)(0), // 3: PlayType + (BattleType)(0), // 4: BattleType + (*DBBattleFormt)(nil), // 5: DBBattleFormt } var file_battle_battle_msg_proto_depIdxs = []int32{ - 2, // 0: BattlePVEReq.ptype:type_name -> PlayType - 3, // 1: BattleInfo.btype:type_name -> BattleType - 2, // 2: BattleInfo.ptype:type_name -> PlayType - 4, // 3: BattleInfo.redflist:type_name -> DBBattleFormt - 4, // 4: BattleInfo.buleflist:type_name -> DBBattleFormt + 3, // 0: BattlePVEReq.ptype:type_name -> PlayType + 4, // 1: BattleInfo.btype:type_name -> BattleType + 3, // 2: BattleInfo.ptype:type_name -> PlayType + 5, // 3: BattleInfo.redflist:type_name -> DBBattleFormt + 5, // 4: BattleInfo.buleflist:type_name -> DBBattleFormt 5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name @@ -285,6 +326,18 @@ func file_battle_battle_msg_proto_init() { return nil } } + file_battle_battle_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BattleReport); 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{ @@ -292,7 +345,7 @@ func file_battle_battle_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_battle_battle_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/moonfantasy_msg.pb.go b/pb/moonfantasy_msg.pb.go index 7e21b20df..04265dbcb 100644 --- a/pb/moonfantasy_msg.pb.go +++ b/pb/moonfantasy_msg.pb.go @@ -392,9 +392,9 @@ type MoonfantasyReceiveReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Bid string `protobuf:"bytes,2,opt,name=bid,proto3" json:"bid"` //战斗id 后续需要这个id来领取奖励 - Monster string `protobuf:"bytes,3,opt,name=monster,proto3" json:"monster"` //怪物id - Iswin bool `protobuf:"varint,4,opt,name=iswin,proto3" json:"iswin"` //是否胜利 + Bid string `protobuf:"bytes,2,opt,name=bid,proto3" json:"bid"` //战斗id 后续需要这个id来领取奖励 + Monster string `protobuf:"bytes,3,opt,name=monster,proto3" json:"monster"` //怪物id + Report *BattleReport `protobuf:"bytes,4,opt,name=report,proto3" json:"report"` //战报 } func (x *MoonfantasyReceiveReq) Reset() { @@ -443,11 +443,11 @@ func (x *MoonfantasyReceiveReq) GetMonster() string { return "" } -func (x *MoonfantasyReceiveReq) GetIswin() bool { +func (x *MoonfantasyReceiveReq) GetReport() *BattleReport { if x != nil { - return x.Iswin + return x.Report } - return false + return nil } ///领取战斗奖励 @@ -538,17 +538,18 @@ var file_moonfantasy_moonfantasy_msg_proto_rawDesc = []byte{ 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x59, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, + 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x6a, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x62, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, - 0x69, 0x73, 0x77, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, 0x73, 0x77, - 0x69, 0x6e, 0x22, 0x30, 0x0a, 0x16, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, - 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, - 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, - 0x73, 0x75, 0x63, 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x06, + 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x22, 0x30, 0x0a, 0x16, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, + 0x73, 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, + 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, + 0x73, 0x73, 0x75, 0x63, 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -575,16 +576,18 @@ var file_moonfantasy_moonfantasy_msg_proto_goTypes = []interface{}{ (*MoonfantasyReceiveResp)(nil), // 7: MoonfantasyReceiveResp (ErrorCode)(0), // 8: ErrorCode (*BattleInfo)(nil), // 9: BattleInfo + (*BattleReport)(nil), // 10: BattleReport } var file_moonfantasy_moonfantasy_msg_proto_depIdxs = []int32{ - 8, // 0: MoonfantasyAskResp.code:type_name -> ErrorCode - 8, // 1: MoonfantasyBattleResp.code:type_name -> ErrorCode - 9, // 2: MoonfantasyBattleResp.info:type_name -> BattleInfo - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 8, // 0: MoonfantasyAskResp.code:type_name -> ErrorCode + 8, // 1: MoonfantasyBattleResp.code:type_name -> ErrorCode + 9, // 2: MoonfantasyBattleResp.info:type_name -> BattleInfo + 10, // 3: MoonfantasyReceiveReq.report:type_name -> BattleReport + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_moonfantasy_moonfantasy_msg_proto_init() }