From d4c37caec46df119fa0c2825ea880b27100c0633 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 24 Nov 2022 11:05:31 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97rpc?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pb/battle_msg.pb.go | 298 ++++++++++++++++++++++++++++---------------- 1 file changed, 193 insertions(+), 105 deletions(-) diff --git a/pb/battle_msg.pb.go b/pb/battle_msg.pb.go index ae86bb767..0b098f8d8 100644 --- a/pb/battle_msg.pb.go +++ b/pb/battle_msg.pb.go @@ -9,6 +9,7 @@ package pb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" reflect "reflect" sync "sync" ) @@ -627,6 +628,70 @@ func (x *BattleReport) GetCompletetask() []int32 { return nil } +//公用消息结构代码 +type BattleRpcMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rid uint64 `protobuf:"varint,1,opt,name=rid,proto3" json:"rid"` //服务回调id + Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method"` //方法名 + Data *anypb.Any `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data"` +} + +func (x *BattleRpcMessage) Reset() { + *x = BattleRpcMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_battle_battle_msg_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BattleRpcMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BattleRpcMessage) ProtoMessage() {} + +func (x *BattleRpcMessage) ProtoReflect() protoreflect.Message { + mi := &file_battle_battle_msg_proto_msgTypes[8] + 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 BattleRpcMessage.ProtoReflect.Descriptor instead. +func (*BattleRpcMessage) Descriptor() ([]byte, []int) { + return file_battle_battle_msg_proto_rawDescGZIP(), []int{8} +} + +func (x *BattleRpcMessage) GetRid() uint64 { + if x != nil { + return x.Rid + } + return 0 +} + +func (x *BattleRpcMessage) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *BattleRpcMessage) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + var File_battle_battle_msg_proto protoreflect.FileDescriptor var file_battle_battle_msg_proto_rawDesc = []byte{ @@ -634,84 +699,92 @@ var file_battle_battle_msg_proto_rawDesc = []byte{ 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x2f, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x68, 0x65, 0x72, 0x6f, 0x2f, 0x68, 0x65, 0x72, 0x6f, 0x5f, 0x64, 0x62, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e, 0x0a, 0x06, 0x4c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x12, - 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x69, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x04, 0x73, 0x74, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0x67, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x64, - 0x70, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, - 0x6f, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0xd1, - 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x45, 0x56, 0x45, 0x52, 0x65, 0x71, 0x12, - 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, - 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x79, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, - 0x03, 0x28, 0x05, 0x52, 0x09, 0x73, 0x79, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x22, - 0x0a, 0x0c, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x66, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x18, 0x06, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x56, 0x45, - 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, - 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x66, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, - 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x66, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, - 0x05, 0x20, 0x03, 0x28, 0x05, 0x52, 0x07, 0x6d, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x5b, - 0x0a, 0x0c, 0x50, 0x56, 0x50, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, - 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x12, 0x1f, 0x0a, 0x06, 0x66, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, - 0x65, 0x72, 0x6f, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x0c, - 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x56, 0x50, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, - 0x70, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, - 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, - 0x74, 0x6c, 0x65, 0x12, 0x2b, 0x0a, 0x09, 0x72, 0x65, 0x64, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x56, 0x50, 0x46, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x72, 0x65, 0x64, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x12, 0x2d, 0x0a, 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x56, 0x50, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, - 0xa4, 0x02, 0x0a, 0x0a, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, - 0x69, 0x74, 0x6c, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, - 0x52, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, - 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x64, 0x43, - 0x6f, 0x6d, 0x70, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x64, - 0x43, 0x6f, 0x6d, 0x70, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x66, 0x6c, 0x69, - 0x73, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x42, 0x61, 0x74, - 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x74, 0x52, 0x08, 0x72, 0x65, 0x64, 0x66, 0x6c, 0x69, - 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x6c, 0x75, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x49, 0x64, - 0x18, 0x07, 0x20, 0x01, 0x28, 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, - 0x08, 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, - 0x12, 0x14, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x05, 0x52, - 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x74, 0x6c, - 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x6f, 0x73, 0x74, - 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x43, 0x6f, 0x73, 0x74, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x22, - 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x05, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x74, 0x61, - 0x73, 0x6b, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x3e, 0x0a, 0x06, 0x4c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x73, 0x74, 0x61, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, + 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, + 0x22, 0x67, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x12, 0x16, 0x0a, + 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0xd1, 0x01, 0x0a, 0x0c, 0x42, 0x61, + 0x74, 0x74, 0x6c, 0x65, 0x45, 0x56, 0x45, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, + 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x12, 0x28, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x73, + 0x79, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, 0x09, + 0x73, 0x79, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x61, 0x63, + 0x6b, 0x75, 0x70, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x05, 0x20, 0x03, 0x28, 0x05, 0x52, + 0x0c, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x1e, 0x0a, + 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, + 0x05, 0x52, 0x0a, 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x89, 0x01, + 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x56, 0x45, 0x52, 0x65, 0x71, 0x12, 0x1f, + 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, + 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, + 0x18, 0x0a, 0x07, 0x6d, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x05, 0x20, 0x03, 0x28, 0x05, + 0x52, 0x07, 0x6d, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x5b, 0x0a, 0x0c, 0x50, 0x56, 0x50, + 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6c, + 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x65, + 0x61, 0x64, 0x70, 0x6f, 0x73, 0x12, 0x1f, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, + 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0xa1, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x74, 0x6c, + 0x65, 0x50, 0x56, 0x50, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x2b, + 0x0a, 0x09, 0x72, 0x65, 0x64, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x56, 0x50, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x09, 0x72, 0x65, 0x64, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x2d, 0x0a, 0x0a, 0x62, + 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0d, 0x2e, 0x50, 0x56, 0x50, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, + 0x62, 0x75, 0x6c, 0x65, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0xa4, 0x02, 0x0a, 0x0a, 0x42, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, + 0x21, 0x0a, 0x05, 0x62, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, + 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x62, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x70, 0x49, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x70, 0x49, + 0x64, 0x12, 0x2a, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x66, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x06, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x6f, + 0x72, 0x6d, 0x74, 0x52, 0x08, 0x72, 0x65, 0x64, 0x66, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x1e, 0x0a, + 0x0a, 0x62, 0x6c, 0x75, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, + 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, 0x08, 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, 0x12, 0x14, 0x0a, 0x05, 0x74, + 0x61, 0x73, 0x6b, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x05, 0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, + 0x73, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, + 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x6f, 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x43, 0x6f, 0x73, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, + 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, + 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x74, 0x61, 0x73, 0x6b, 0x22, 0x66, 0x0a, + 0x10, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x70, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, + 0x72, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x44, + 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, + 0x04, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -726,40 +799,43 @@ 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, 8) +var file_battle_battle_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_battle_battle_msg_proto_goTypes = []interface{}{ - (*LineUp)(nil), // 0: LineUp - (*BattleFormation)(nil), // 1: BattleFormation - (*BattleEVEReq)(nil), // 2: BattleEVEReq - (*BattlePVEReq)(nil), // 3: BattlePVEReq - (*PVPFormation)(nil), // 4: PVPFormation - (*BattlePVPReq)(nil), // 5: BattlePVPReq - (*BattleInfo)(nil), // 6: BattleInfo - (*BattleReport)(nil), // 7: BattleReport - (PlayType)(0), // 8: PlayType - (*DBHero)(nil), // 9: DBHero - (BattleType)(0), // 10: BattleType - (*DBBattleFormt)(nil), // 11: DBBattleFormt + (*LineUp)(nil), // 0: LineUp + (*BattleFormation)(nil), // 1: BattleFormation + (*BattleEVEReq)(nil), // 2: BattleEVEReq + (*BattlePVEReq)(nil), // 3: BattlePVEReq + (*PVPFormation)(nil), // 4: PVPFormation + (*BattlePVPReq)(nil), // 5: BattlePVPReq + (*BattleInfo)(nil), // 6: BattleInfo + (*BattleReport)(nil), // 7: BattleReport + (*BattleRpcMessage)(nil), // 8: BattleRpcMessage + (PlayType)(0), // 9: PlayType + (*DBHero)(nil), // 10: DBHero + (BattleType)(0), // 11: BattleType + (*DBBattleFormt)(nil), // 12: DBBattleFormt + (*anypb.Any)(nil), // 13: google.protobuf.Any } var file_battle_battle_msg_proto_depIdxs = []int32{ - 8, // 0: BattleEVEReq.ptype:type_name -> PlayType + 9, // 0: BattleEVEReq.ptype:type_name -> PlayType 1, // 1: BattleEVEReq.format:type_name -> BattleFormation - 8, // 2: BattlePVEReq.ptype:type_name -> PlayType + 9, // 2: BattlePVEReq.ptype:type_name -> PlayType 1, // 3: BattlePVEReq.format:type_name -> BattleFormation - 9, // 4: PVPFormation.format:type_name -> DBHero - 8, // 5: BattlePVPReq.ptype:type_name -> PlayType + 10, // 4: PVPFormation.format:type_name -> DBHero + 9, // 5: BattlePVPReq.ptype:type_name -> PlayType 4, // 6: BattlePVPReq.redformat:type_name -> PVPFormation 4, // 7: BattlePVPReq.buleformat:type_name -> PVPFormation - 10, // 8: BattleInfo.btype:type_name -> BattleType - 8, // 9: BattleInfo.ptype:type_name -> PlayType - 11, // 10: BattleInfo.redflist:type_name -> DBBattleFormt - 11, // 11: BattleInfo.buleflist:type_name -> DBBattleFormt + 11, // 8: BattleInfo.btype:type_name -> BattleType + 9, // 9: BattleInfo.ptype:type_name -> PlayType + 12, // 10: BattleInfo.redflist:type_name -> DBBattleFormt + 12, // 11: BattleInfo.buleflist:type_name -> DBBattleFormt 6, // 12: BattleReport.info:type_name -> BattleInfo - 13, // [13:13] is the sub-list for method output_type - 13, // [13:13] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 13, // 13: BattleRpcMessage.Data:type_name -> google.protobuf.Any + 14, // [14:14] is the sub-list for method output_type + 14, // [14:14] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_battle_battle_msg_proto_init() } @@ -866,6 +942,18 @@ func file_battle_battle_msg_proto_init() { return nil } } + file_battle_battle_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BattleRpcMessage); 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{ @@ -873,7 +961,7 @@ func file_battle_battle_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_battle_battle_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, From a7b469b5238e91d58f85f7b8e1571a38c894594f Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 24 Nov 2022 11:06:10 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E8=BF=9C=E7=A8=8B=E8=BF=9E=E6=8E=A5=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/battle/client.go | 40 +++++++++++++++++++++++++++++++ modules/battle/module_test.go | 13 +++++++++- modules/battle/options.go | 45 +++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 modules/battle/client.go create mode 100644 modules/battle/options.go diff --git a/modules/battle/client.go b/modules/battle/client.go new file mode 100644 index 000000000..c33801b19 --- /dev/null +++ b/modules/battle/client.go @@ -0,0 +1,40 @@ +package battle + +import ( + "go_dreamfactory/modules" + + "go_dreamfactory/lego/core" + + "github.com/gorilla/websocket" +) + +/* +战斗服务客户端组件 +*/ +type clientComp struct { + modules.MCompGate + options *Options + service core.IService + module *Battle + conn *websocket.Conn +} + +//组件初始化接口 +func (this *clientComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompGate.Init(service, module, comp, options) + this.options = options.(*Options) + this.module = module.(*Battle) + return +} + +func (this *clientComp) Start() (err error) { + err = this.MCompGate.Start() + dialer := websocket.Dialer{} + this.conn, _, err = dialer.Dial(this.options.BattleServerAddr, nil) + return +} + +//校验战斗过程 +func (this *clientComp) CheckBattle() { + +} diff --git a/modules/battle/module_test.go b/modules/battle/module_test.go index f56773078..c7242c0fc 100644 --- a/modules/battle/module_test.go +++ b/modules/battle/module_test.go @@ -18,6 +18,8 @@ import ( "os" "testing" "time" + + "github.com/gorilla/websocket" ) func newService(ops ...rpcx.Option) core.IService { @@ -86,4 +88,13 @@ func testdefer(data *[]int) { *data = append(*data, 0) } -// 3 +func Test_Comment(t *testing.T) { + dialer := websocket.Dialer{} + if connect, _, err := dialer.Dial("ws://127.0.0.1:9898", nil); err != nil { + fmt.Println(err) + return + } else { + defer connect.Close() + connect.WriteMessage(websocket.TextMessage, []byte("from client to server")) + } +} diff --git a/modules/battle/options.go b/modules/battle/options.go new file mode 100644 index 000000000..334bc85cd --- /dev/null +++ b/modules/battle/options.go @@ -0,0 +1,45 @@ +package battle + +import ( + "errors" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/lego/utils/mapstructure" + "go_dreamfactory/modules" +) + +type ( + IOptions interface { + modules.IOptions + } + Options struct { + modules.Options + BattleServerAddr string + } +) + +func (this *Options) GetDebug() bool { + return this.Debug +} + +func (this *Options) GetLog() log.ILogger { + return this.Log +} + +func (this *Options) GetBattleServerAddr() string { + return this.BattleServerAddr +} + +func (this *Options) LoadConfig(settings map[string]interface{}) (err error) { + if settings != nil { + if err = mapstructure.Decode(settings, &this.Options); err != nil { + return + } + if err = mapstructure.Decode(settings, this); err != nil { + return + } + } + if this.Log = log.NewTurnlog(true, log.Clone("", 4)); this.Log == nil { + err = errors.New("log is nil") + } + return +} From 3eea25c1e209ab6ae74a17e04c969db96f67edd4 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 24 Nov 2022 11:18:59 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pb/battle_msg.pb.go | 125 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 98 insertions(+), 27 deletions(-) diff --git a/pb/battle_msg.pb.go b/pb/battle_msg.pb.go index 0b098f8d8..acc0d68ad 100644 --- a/pb/battle_msg.pb.go +++ b/pb/battle_msg.pb.go @@ -692,6 +692,61 @@ func (x *BattleRpcMessage) GetData() *anypb.Any { return nil } +type BattleTestMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"` +} + +func (x *BattleTestMessage) Reset() { + *x = BattleTestMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_battle_battle_msg_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BattleTestMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BattleTestMessage) ProtoMessage() {} + +func (x *BattleTestMessage) ProtoReflect() protoreflect.Message { + mi := &file_battle_battle_msg_proto_msgTypes[9] + 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 BattleTestMessage.ProtoReflect.Descriptor instead. +func (*BattleTestMessage) Descriptor() ([]byte, []int) { + return file_battle_battle_msg_proto_rawDescGZIP(), []int{9} +} + +func (x *BattleTestMessage) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *BattleTestMessage) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + var File_battle_battle_msg_proto protoreflect.FileDescriptor var file_battle_battle_msg_proto_rawDesc = []byte{ @@ -783,8 +838,11 @@ var file_battle_battle_msg_proto_rawDesc = []byte{ 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x04, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x35, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x54, + 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, + 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -799,38 +857,39 @@ 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, 9) +var file_battle_battle_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_battle_battle_msg_proto_goTypes = []interface{}{ - (*LineUp)(nil), // 0: LineUp - (*BattleFormation)(nil), // 1: BattleFormation - (*BattleEVEReq)(nil), // 2: BattleEVEReq - (*BattlePVEReq)(nil), // 3: BattlePVEReq - (*PVPFormation)(nil), // 4: PVPFormation - (*BattlePVPReq)(nil), // 5: BattlePVPReq - (*BattleInfo)(nil), // 6: BattleInfo - (*BattleReport)(nil), // 7: BattleReport - (*BattleRpcMessage)(nil), // 8: BattleRpcMessage - (PlayType)(0), // 9: PlayType - (*DBHero)(nil), // 10: DBHero - (BattleType)(0), // 11: BattleType - (*DBBattleFormt)(nil), // 12: DBBattleFormt - (*anypb.Any)(nil), // 13: google.protobuf.Any + (*LineUp)(nil), // 0: LineUp + (*BattleFormation)(nil), // 1: BattleFormation + (*BattleEVEReq)(nil), // 2: BattleEVEReq + (*BattlePVEReq)(nil), // 3: BattlePVEReq + (*PVPFormation)(nil), // 4: PVPFormation + (*BattlePVPReq)(nil), // 5: BattlePVPReq + (*BattleInfo)(nil), // 6: BattleInfo + (*BattleReport)(nil), // 7: BattleReport + (*BattleRpcMessage)(nil), // 8: BattleRpcMessage + (*BattleTestMessage)(nil), // 9: BattleTestMessage + (PlayType)(0), // 10: PlayType + (*DBHero)(nil), // 11: DBHero + (BattleType)(0), // 12: BattleType + (*DBBattleFormt)(nil), // 13: DBBattleFormt + (*anypb.Any)(nil), // 14: google.protobuf.Any } var file_battle_battle_msg_proto_depIdxs = []int32{ - 9, // 0: BattleEVEReq.ptype:type_name -> PlayType + 10, // 0: BattleEVEReq.ptype:type_name -> PlayType 1, // 1: BattleEVEReq.format:type_name -> BattleFormation - 9, // 2: BattlePVEReq.ptype:type_name -> PlayType + 10, // 2: BattlePVEReq.ptype:type_name -> PlayType 1, // 3: BattlePVEReq.format:type_name -> BattleFormation - 10, // 4: PVPFormation.format:type_name -> DBHero - 9, // 5: BattlePVPReq.ptype:type_name -> PlayType + 11, // 4: PVPFormation.format:type_name -> DBHero + 10, // 5: BattlePVPReq.ptype:type_name -> PlayType 4, // 6: BattlePVPReq.redformat:type_name -> PVPFormation 4, // 7: BattlePVPReq.buleformat:type_name -> PVPFormation - 11, // 8: BattleInfo.btype:type_name -> BattleType - 9, // 9: BattleInfo.ptype:type_name -> PlayType - 12, // 10: BattleInfo.redflist:type_name -> DBBattleFormt - 12, // 11: BattleInfo.buleflist:type_name -> DBBattleFormt + 12, // 8: BattleInfo.btype:type_name -> BattleType + 10, // 9: BattleInfo.ptype:type_name -> PlayType + 13, // 10: BattleInfo.redflist:type_name -> DBBattleFormt + 13, // 11: BattleInfo.buleflist:type_name -> DBBattleFormt 6, // 12: BattleReport.info:type_name -> BattleInfo - 13, // 13: BattleRpcMessage.Data:type_name -> google.protobuf.Any + 14, // 13: BattleRpcMessage.Data:type_name -> google.protobuf.Any 14, // [14:14] is the sub-list for method output_type 14, // [14:14] is the sub-list for method input_type 14, // [14:14] is the sub-list for extension type_name @@ -954,6 +1013,18 @@ func file_battle_battle_msg_proto_init() { return nil } } + file_battle_battle_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BattleTestMessage); 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{ @@ -961,7 +1032,7 @@ func file_battle_battle_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_battle_battle_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 9, + NumMessages: 10, NumExtensions: 0, NumServices: 0, }, From df94e2f89c0e858fb62d818f1d65285459ae8f9d Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 24 Nov 2022 13:56:20 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/worldtask/api_finish.go | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 8a3cbdd60..6aa101688 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -102,7 +102,6 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe finishCall() } else { this.module.Debug("任务完成条件未通过", log.Fields{"uid": uid, "condiId": curTaskConf.Completetask}) - code = pb.ErrorCode_WorldtaskNoComplete return } } else { From 2b478ce28242f10b20bd3f07fc08f28cc13d694c Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 24 Nov 2022 14:10:04 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BA=A2=E7=82=B9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/modelarena.go | 24 ++++++++++++++++++++++++ modules/arena/module.go | 4 +--- modules/battle/client.go | 21 +++++++++++++++++++++ modules/battle/module_test.go | 11 ++++++++++- modules/horoscope/module.go | 4 +--- modules/martialhall/module.go | 12 +++--------- 6 files changed, 60 insertions(+), 16 deletions(-) diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index a1ac5c384..bf4b38702 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -387,11 +387,35 @@ func (this *modelArena) recoverTicket(info *pb.DBArenaUser) { func (this *modelArena) reddot(session comm.IUserSession) bool { var ( info *pb.DBArenaUser + user *pb.DBUser err error ) if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil { return false } + if err == mgo.MongodbNil { + global := this.module.configure.GetGlobalConf() + if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { + return false + } + info = &pb.DBArenaUser{ + Uid: session.GetUserId(), + Name: user.Name, + Integral: global.ArenaInitiaIntegral, + Ticket: 10, + Streak: 0, + Record: make([]*pb.DBArenaBattleRecord, 0), + Lastrtickettime: 0, + Isdef: false, + Npc: make(map[int32]*pb.DBNpc), + } + if info.Dan, err = this.module.modelArena.computedan(info.Integral); err != nil { + return false + } + if err = this.module.modelArena.Add(session.GetUserId(), info); err != nil { + return false + } + } if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos { return true } diff --git a/modules/arena/module.go b/modules/arena/module.go index da92f88e4..c7873cc90 100644 --- a/modules/arena/module.go +++ b/modules/arena/module.go @@ -78,9 +78,7 @@ func (this *Arena) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (re for _, v := range rid { switch v { case comm.Reddot19: - if isredot := this.modelArena.reddot(session); isredot { - result[comm.Reddot19] = true - } + result[comm.Reddot19] = this.modelArena.reddot(session) break } } diff --git a/modules/battle/client.go b/modules/battle/client.go index c33801b19..e58bdbd01 100644 --- a/modules/battle/client.go +++ b/modules/battle/client.go @@ -2,10 +2,12 @@ package battle import ( "go_dreamfactory/modules" + "go_dreamfactory/pb" "go_dreamfactory/lego/core" "github.com/gorilla/websocket" + "google.golang.org/protobuf/proto" ) /* @@ -38,3 +40,22 @@ func (this *clientComp) Start() (err error) { func (this *clientComp) CheckBattle() { } + +func (this *clientComp) run() { + var ( + data []byte + msg *pb.BattleRpcMessage = &pb.BattleRpcMessage{} + err error + ) +locp: + for { + if _, data, err = this.conn.ReadMessage(); err != nil { + this.module.Errorf("client err:%v", err) + break locp + } + if err = proto.Unmarshal(data, msg); err != nil { + this.module.Errorf("client Unmarshal err:%v", err) + break locp + } + } +} diff --git a/modules/battle/module_test.go b/modules/battle/module_test.go index c7242c0fc..b6160342f 100644 --- a/modules/battle/module_test.go +++ b/modules/battle/module_test.go @@ -12,6 +12,7 @@ import ( "go_dreamfactory/modules/hero" "go_dreamfactory/modules/items" "go_dreamfactory/modules/user" + "go_dreamfactory/pb" "go_dreamfactory/services" "go_dreamfactory/sys/configure" "go_dreamfactory/sys/db" @@ -20,6 +21,8 @@ import ( "time" "github.com/gorilla/websocket" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" ) func newService(ops ...rpcx.Option) core.IService { @@ -95,6 +98,12 @@ func Test_Comment(t *testing.T) { return } else { defer connect.Close() - connect.WriteMessage(websocket.TextMessage, []byte("from client to server")) + msg := &pb.BattleRpcMessage{ + Rid: 1, + Method: "test", + } + msg.Data, _ = anypb.New(&pb.BattleTestMessage{}) + data, _ := proto.Marshal(msg) + connect.WriteMessage(websocket.BinaryMessage, data) } } diff --git a/modules/horoscope/module.go b/modules/horoscope/module.go index 71506aa44..c1e0250cd 100644 --- a/modules/horoscope/module.go +++ b/modules/horoscope/module.go @@ -64,9 +64,7 @@ func (this *Horoscope) Reddot(session comm.IUserSession, rid ...comm.ReddotType) for _, v := range rid { switch v { case comm.Reddot17: - if isredot := this.modelHoroscope.reddot(session); isredot { - result[comm.Reddot17] = true - } + result[comm.Reddot17] = this.modelHoroscope.reddot(session) break } } diff --git a/modules/martialhall/module.go b/modules/martialhall/module.go index c8305cedb..8fdf936ae 100644 --- a/modules/martialhall/module.go +++ b/modules/martialhall/module.go @@ -56,19 +56,13 @@ func (this *Martialhall) Reddot(session comm.IUserSession, rid ...comm.ReddotTyp for _, v := range rid { switch v { case comm.Reddot23: - if isredot := this.modelMartialhall.checkReddot23(session); isredot { - reddot[comm.Reddot23] = true - } + reddot[comm.Reddot23] = this.modelMartialhall.checkReddot23(session) break case comm.Reddot24: - if isredot := this.modelMartialhall.checkReddot24(session); isredot { - reddot[comm.Reddot24] = true - } + reddot[comm.Reddot24] = this.modelMartialhall.checkReddot24(session) break case comm.Reddot25: - if isredot := this.modelMartialhall.checkReddot25(session); isredot { - reddot[comm.Reddot25] = true - } + reddot[comm.Reddot25] = this.modelMartialhall.checkReddot25(session) break } } From d308ecaaf4f944b8722ac1999db075bbdeb658c9 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 24 Nov 2022 14:20:54 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80?= =?UTF-8?q?=E5=9C=BA=E7=BA=A2=E7=82=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/modelarena.go | 22 ++-------------------- modules/battle/call.go | 12 ++++++++++++ 2 files changed, 14 insertions(+), 20 deletions(-) create mode 100644 modules/battle/call.go diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index bf4b38702..8ca76c36c 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -387,7 +387,6 @@ func (this *modelArena) recoverTicket(info *pb.DBArenaUser) { func (this *modelArena) reddot(session comm.IUserSession) bool { var ( info *pb.DBArenaUser - user *pb.DBUser err error ) if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil { @@ -395,25 +394,8 @@ func (this *modelArena) reddot(session comm.IUserSession) bool { } if err == mgo.MongodbNil { global := this.module.configure.GetGlobalConf() - if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { - return false - } - info = &pb.DBArenaUser{ - Uid: session.GetUserId(), - Name: user.Name, - Integral: global.ArenaInitiaIntegral, - Ticket: 10, - Streak: 0, - Record: make([]*pb.DBArenaBattleRecord, 0), - Lastrtickettime: 0, - Isdef: false, - Npc: make(map[int32]*pb.DBNpc), - } - if info.Dan, err = this.module.modelArena.computedan(info.Integral); err != nil { - return false - } - if err = this.module.modelArena.Add(session.GetUserId(), info); err != nil { - return false + if global.ArenaTicketMax >= global.ArenaTicketCos { + return true } } if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos { diff --git a/modules/battle/call.go b/modules/battle/call.go new file mode 100644 index 000000000..5f310a06f --- /dev/null +++ b/modules/battle/call.go @@ -0,0 +1,12 @@ +package battle + +//异步返回结构 +type MessageCall struct { + Method string + Metadata map[string]string + ResMetadata map[string]string + Args interface{} //请求参数 + Reply interface{} //返回参数 + Error error //错误信息 + Done chan *MessageCall +} From 85c174a498396b30606d59cfbdcde342690725e5 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 24 Nov 2022 14:27:46 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=AB=9E=E6=8A=80?= =?UTF-8?q?=E5=9C=BA=E7=BA=A2=E7=82=B9=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/api_info.go | 2 +- modules/arena/modelarena.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/arena/api_info.go b/modules/arena/api_info.go index f0fccaf62..954457ece 100644 --- a/modules/arena/api_info.go +++ b/modules/arena/api_info.go @@ -50,7 +50,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code Uid: session.GetUserId(), Name: user.Name, Integral: global.ArenaInitiaIntegral, - Ticket: 10, + Ticket: global.ArenaTicketMax, Streak: 0, Record: make([]*pb.DBArenaBattleRecord, 0), Lastrtickettime: 0, diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index 8ca76c36c..e48f2f957 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -389,7 +389,7 @@ func (this *modelArena) reddot(session comm.IUserSession) bool { info *pb.DBArenaUser err error ) - if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil { + if info, err = this.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil { return false } if err == mgo.MongodbNil { @@ -397,6 +397,7 @@ func (this *modelArena) reddot(session comm.IUserSession) bool { if global.ArenaTicketMax >= global.ArenaTicketCos { return true } + return false } if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos { return true