From 7487a66eb6008b236d2ae6b42bcd1fb91ae9d58a Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 8 Feb 2023 18:45:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/battle/battleclient.go | 2 +- modules/pvp/module.go | 1 + pb/battle_msg.pb.go | 47 ++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/modules/battle/battleclient.go b/modules/battle/battleclient.go index 235ac017b..601ac17ed 100644 --- a/modules/battle/battleclient.go +++ b/modules/battle/battleclient.go @@ -104,7 +104,7 @@ func (this *client) handleresponse(resp *pb.BattleRpcMessage) { call.done(this.log) } else { switch resp.Method { - case "OutCmd": //输出指令 + case "BattleOutCmd": //输出指令 if msg, err := resp.Data.UnmarshalNew(); err != nil { this.log.Errorf("C# OutCmd Unmarshal err:%v", err) break diff --git a/modules/pvp/module.go b/modules/pvp/module.go index 609d97404..0477e67d8 100644 --- a/modules/pvp/module.go +++ b/modules/pvp/module.go @@ -42,6 +42,7 @@ func (this *Pvp) GetType() core.M_Modules { func (this *Pvp) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) + this.battles = make(map[string]*BattleItem) return } diff --git a/pb/battle_msg.pb.go b/pb/battle_msg.pb.go index bafd1803c..9c755dd7e 100644 --- a/pb/battle_msg.pb.go +++ b/pb/battle_msg.pb.go @@ -1098,7 +1098,8 @@ type BattleInCmdReq struct { unknownFields protoimpl.UnknownFields Battleid string `protobuf:"bytes,1,opt,name=battleid,proto3" json:"battleid"` - In *BattleCmd `protobuf:"bytes,2,opt,name=in,proto3" json:"in"` + Side int32 `protobuf:"varint,2,opt,name=side,proto3" json:"side"` + In *BattleCmd `protobuf:"bytes,3,opt,name=in,proto3" json:"in"` } func (x *BattleInCmdReq) Reset() { @@ -1140,6 +1141,13 @@ func (x *BattleInCmdReq) GetBattleid() string { return "" } +func (x *BattleInCmdReq) GetSide() int32 { + if x != nil { + return x.Side + } + return 0 +} + func (x *BattleInCmdReq) GetIn() *BattleCmd { if x != nil { return x.In @@ -1451,27 +1459,28 @@ var file_battle_battle_msg_proto_rawDesc = []byte{ 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x30, 0x0a, 0x16, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 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, 0x22, 0x48, 0x0a, 0x0e, 0x42, 0x61, 0x74, 0x74, + 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x22, 0x5c, 0x0a, 0x0e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x43, 0x6d, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, - 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6d, 0x64, 0x52, 0x02, - 0x69, 0x6e, 0x22, 0x61, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x43, 0x6d, - 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, - 0x64, 0x12, 0x1a, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, - 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6d, 0x64, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x16, 0x0a, - 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, - 0x73, 0x73, 0x75, 0x63, 0x63, 0x22, 0x4c, 0x0a, 0x10, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4f, - 0x75, 0x74, 0x43, 0x6d, 0x64, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x74, + 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x64, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x69, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x02, 0x69, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, + 0x6d, 0x64, 0x52, 0x02, 0x69, 0x6e, 0x22, 0x61, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, + 0x49, 0x6e, 0x43, 0x6d, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x74, - 0x74, 0x6c, 0x65, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6d, 0x64, 0x52, 0x03, - 0x63, 0x6d, 0x64, 0x22, 0x2e, 0x0a, 0x10, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x69, 0x6e, - 0x69, 0x73, 0x68, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, - 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, - 0x65, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x74, 0x6c, 0x65, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0a, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6d, 0x64, 0x52, 0x02, 0x69, + 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x22, 0x4c, 0x0a, 0x10, 0x42, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x4f, 0x75, 0x74, 0x43, 0x6d, 0x64, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1a, 0x0a, + 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x03, 0x63, 0x6d, 0x64, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, + 0x6d, 0x64, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x22, 0x2e, 0x0a, 0x10, 0x42, 0x61, 0x74, 0x74, 0x6c, + 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x62, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 885993f5499053c505080986129d193d73a8114d Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Wed, 8 Feb 2023 18:52:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E5=88=87=E7=A3=8Bpvp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/friend/api_cross_accept.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/friend/api_cross_accept.go b/modules/friend/api_cross_accept.go index c7881b6b2..da1dc7855 100644 --- a/modules/friend/api_cross_accept.go +++ b/modules/friend/api_cross_accept.go @@ -23,7 +23,7 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.FriendAcceptReq) } if imodule, err := this.moduleFriend.service.GetModule(comm.ModulePvp); err == nil { - if _, ok := imodule.(comm.IPvp); ok { + if ipvp, ok := imodule.(comm.IPvp); ok { //发起者 red red := this.moduleFriend.ModuleUser.GetUser(req.Uid) if red == nil { @@ -37,13 +37,13 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.FriendAcceptReq) this.moduleFriend.Error("未找到蓝方信息", log.Field{Key: "uid", Value: session.GetUserId()}) return } - // if _, code = ipvp.CreatePvp( - // &pb.PvpUserInfo{Uid: red.Uid, Name: red.Name, Avatar: red.Avatar, Lv: red.Lv}, - // &pb.PvpUserInfo{Uid: blue.Uid, Name: blue.Name, Avatar: blue.Avatar, Lv: blue.Lv}, - // pb.PvpType_friends, - // ); code != pb.ErrorCode_Success { - // return - // } + if _, code = ipvp.CreatePvp( + &pb.PvpUserInfo{Uid: red.Uid, Name: red.Name, Avatar: red.Avatar, Lv: red.Lv}, + &pb.PvpUserInfo{Uid: blue.Uid, Name: blue.Name, Avatar: blue.Avatar, Lv: blue.Lv}, + pb.PvpType_friends, + ); code != pb.ErrorCode_Success { + return + } } }