From b8384602001e0dc40c3622cd5429a2d30ecdfe6e Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 6 Sep 2022 16:44:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=8A=A5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=8B=AC=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 - modules/battle/api_result.go | 30 ----- modules/battle/modelBattle.go | 9 +- modules/moonfantasy/api_receive.go | 19 +--- pb/battle_msg.pb.go | 173 +++-------------------------- pb/moonfantasy_msg.pb.go | 22 +++- 6 files changed, 37 insertions(+), 218 deletions(-) delete mode 100644 modules/battle/api_result.go diff --git a/comm/imodule.go b/comm/imodule.go index d6a651e6c..60d646a29 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -133,8 +133,6 @@ type ( //战斗系统 IBattle interface { - ///查询战斗记录接口 - QueryBattleRecord(oid string) (code pb.ErrorCode, record *pb.DBBattleRecord) ///创建pve战斗 CreatePveBattle(session IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) ///创建pvb战斗 diff --git a/modules/battle/api_result.go b/modules/battle/api_result.go deleted file mode 100644 index 72c73aba5..000000000 --- a/modules/battle/api_result.go +++ /dev/null @@ -1,30 +0,0 @@ -package battle - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) ResultCheck(session comm.IUserSession, req *pb.BattleResultReq) (code pb.ErrorCode) { - if req.Id == "" { - code = pb.ErrorCode_ReqParameterError - } - return -} - -///获取本服聊天消息记录 -func (this *apiComp) Result(session comm.IUserSession, req *pb.BattleResultReq) (code pb.ErrorCode, data proto.Message) { - var () - if code = this.ResultCheck(session, req); code != pb.ErrorCode_Success { - return - } - this.module.modelBattle.Change(req.Id, map[string]interface{}{ - "state": pb.BBattleState_end, - "result": pb.DBBattleComp_red, - }) - session.SendMsg(string(this.module.GetType()), "result", &pb.BattleResultResp{Id: req.Id, Issucc: true}) - return -} diff --git a/modules/battle/modelBattle.go b/modules/battle/modelBattle.go index 4b9451dfa..2a74fa0b5 100644 --- a/modules/battle/modelBattle.go +++ b/modules/battle/modelBattle.go @@ -91,10 +91,9 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, btype pb.Battl } } } - if err := this.Add(record.Id, record); err != nil { - this.module.Errorln(err) - return - } - + // if err := this.Add(record.Id, record); err != nil { + // this.module.Errorln(err) + // return + // } return } diff --git a/modules/moonfantasy/api_receive.go b/modules/moonfantasy/api_receive.go index c4704c858..ae0f9edf7 100644 --- a/modules/moonfantasy/api_receive.go +++ b/modules/moonfantasy/api_receive.go @@ -19,10 +19,9 @@ func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.Moonfantasy ///询问怪物是否可以挑战 func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyReceiveReq) (code pb.ErrorCode, data proto.Message) { var ( - boss *cfg.GameDreamlandBoosData - record *pb.DBBattleRecord - award []*cfg.Gameatn = make([]*cfg.Gameatn, 0) - err error + boss *cfg.GameDreamlandBoosData + award []*cfg.Gameatn = make([]*cfg.Gameatn, 0) + err error ) if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success { @@ -32,19 +31,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei code = pb.ErrorCode_ConfigNoFound return } - if code, record = this.module.battle.QueryBattleRecord(req.Bid); code != pb.ErrorCode_Success { - return - } - if record.State != pb.BBattleState_end { - code = pb.ErrorCode_MoonfantasyBattleNoEnd - return - } - - if record.Result != pb.DBBattleComp_red { - 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 e80858456..023d4b38d 100644 --- a/pb/battle_msg.pb.go +++ b/pb/battle_msg.pb.go @@ -188,118 +188,6 @@ func (x *BattleInfo) GetBuleflist() []*DBBattleFormt { return nil } -//战斗结果请求 -type BattleResultReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //战斗id - Iswin bool `protobuf:"varint,2,opt,name=iswin,proto3" json:"iswin"` //是否胜利 -} - -func (x *BattleResultReq) Reset() { - *x = BattleResultReq{} - if protoimpl.UnsafeEnabled { - mi := &file_battle_battle_msg_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BattleResultReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BattleResultReq) ProtoMessage() {} - -func (x *BattleResultReq) 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 BattleResultReq.ProtoReflect.Descriptor instead. -func (*BattleResultReq) Descriptor() ([]byte, []int) { - return file_battle_battle_msg_proto_rawDescGZIP(), []int{2} -} - -func (x *BattleResultReq) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *BattleResultReq) GetIswin() bool { - if x != nil { - return x.Iswin - } - return false -} - -//战斗结果请求 -type BattleResultResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //战斗id - Issucc bool `protobuf:"varint,2,opt,name=issucc,proto3" json:"issucc"` //是否生效 -} - -func (x *BattleResultResp) Reset() { - *x = BattleResultResp{} - if protoimpl.UnsafeEnabled { - mi := &file_battle_battle_msg_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BattleResultResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BattleResultResp) ProtoMessage() {} - -func (x *BattleResultResp) ProtoReflect() protoreflect.Message { - mi := &file_battle_battle_msg_proto_msgTypes[3] - 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 BattleResultResp.ProtoReflect.Descriptor instead. -func (*BattleResultResp) Descriptor() ([]byte, []int) { - return file_battle_battle_msg_proto_rawDescGZIP(), []int{3} -} - -func (x *BattleResultResp) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *BattleResultResp) GetIssucc() bool { - if x != nil { - return x.Issucc - } - return false -} - var File_battle_battle_msg_proto protoreflect.FileDescriptor var file_battle_battle_msg_proto_rawDesc = []byte{ @@ -329,15 +217,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, 0x22, 0x37, 0x0a, 0x0f, 0x42, - 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x71, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x69, 0x73, 0x77, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, - 0x73, 0x77, 0x69, 0x6e, 0x22, 0x3a, 0x0a, 0x10, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, - 0x63, 0x63, 0x18, 0x02, 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, + 0x52, 0x09, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6c, 0x69, 0x73, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -352,22 +233,20 @@ 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, 4) +var file_battle_battle_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_battle_battle_msg_proto_goTypes = []interface{}{ - (*BattlePVEReq)(nil), // 0: BattlePVEReq - (*BattleInfo)(nil), // 1: BattleInfo - (*BattleResultReq)(nil), // 2: BattleResultReq - (*BattleResultResp)(nil), // 3: BattleResultResp - (PlayType)(0), // 4: PlayType - (BattleType)(0), // 5: BattleType - (*DBBattleFormt)(nil), // 6: DBBattleFormt + (*BattlePVEReq)(nil), // 0: BattlePVEReq + (*BattleInfo)(nil), // 1: BattleInfo + (PlayType)(0), // 2: PlayType + (BattleType)(0), // 3: BattleType + (*DBBattleFormt)(nil), // 4: DBBattleFormt } var file_battle_battle_msg_proto_depIdxs = []int32{ - 4, // 0: BattlePVEReq.ptype:type_name -> PlayType - 5, // 1: BattleInfo.btype:type_name -> BattleType - 4, // 2: BattleInfo.ptype:type_name -> PlayType - 6, // 3: BattleInfo.redflist:type_name -> DBBattleFormt - 6, // 4: BattleInfo.buleflist:type_name -> DBBattleFormt + 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 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 @@ -406,30 +285,6 @@ 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.(*BattleResultReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_battle_battle_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BattleResultResp); 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{ @@ -437,7 +292,7 @@ func file_battle_battle_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_battle_battle_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/moonfantasy_msg.pb.go b/pb/moonfantasy_msg.pb.go index ae02b8c3e..7e21b20df 100644 --- a/pb/moonfantasy_msg.pb.go +++ b/pb/moonfantasy_msg.pb.go @@ -394,6 +394,7 @@ type MoonfantasyReceiveReq struct { 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"` //是否胜利 } func (x *MoonfantasyReceiveReq) Reset() { @@ -442,6 +443,13 @@ func (x *MoonfantasyReceiveReq) GetMonster() string { return "" } +func (x *MoonfantasyReceiveReq) GetIswin() bool { + if x != nil { + return x.Iswin + } + return false +} + ///领取战斗奖励 type MoonfantasyReceiveResp struct { state protoimpl.MessageState @@ -530,15 +538,17 @@ 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, 0x43, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, + 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x59, 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, 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, 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, } var (