From ac9dd9a7ca238c472d64314fd4f1a25625e30cc1 Mon Sep 17 00:00:00 2001 From: tangmingyou <234767776@qq.com> Date: Thu, 2 Feb 2023 18:01:03 +0800 Subject: [PATCH] join leave kickout game --- api/operation.go | 2 + api/poker.pb.go | 219 ++++++++++++++++---------- api/poker.proto | 10 +- api/proto.js | 276 ++++++++++++++++++++++++++++++--- internal/game/table.go | 15 +- internal/server/wsroute.go | 6 + internal/service/table.go | 81 +++++++++- internal/session/net_client.go | 5 + 8 files changed, 495 insertions(+), 119 deletions(-) diff --git a/api/operation.go b/api/operation.go index 528e715..8ad65e5 100644 --- a/api/operation.go +++ b/api/operation.go @@ -38,7 +38,9 @@ var protoInstances = []proto.Message{ &ResGameFullStatus{}, &ReqReadyStart{}, + &ReqKickOutTable{}, + &ResKickOutTable{}, } var ( diff --git a/api/poker.pb.go b/api/poker.pb.go index 0091674..4e7c8c1 100644 --- a/api/poker.pb.go +++ b/api/poker.pb.go @@ -864,7 +864,7 @@ type ReqKickOutTable struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PlayerId int32 `protobuf:"varint,1,opt,name=playerId,proto3" json:"playerId,omitempty"` + PlayerId int64 `protobuf:"varint,1,opt,name=playerId,proto3" json:"playerId,omitempty"` } func (x *ReqKickOutTable) Reset() { @@ -899,13 +899,52 @@ func (*ReqKickOutTable) Descriptor() ([]byte, []int) { return file_poker_proto_rawDescGZIP(), []int{16} } -func (x *ReqKickOutTable) GetPlayerId() int32 { +func (x *ReqKickOutTable) GetPlayerId() int64 { if x != nil { return x.PlayerId } return 0 } +// 被踢人接受消息 +type ResKickOutTable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ResKickOutTable) Reset() { + *x = ResKickOutTable{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResKickOutTable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResKickOutTable) ProtoMessage() {} + +func (x *ResKickOutTable) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[17] + 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 ResKickOutTable.ProtoReflect.Descriptor instead. +func (*ResKickOutTable) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{17} +} + type ReqGameAction struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -918,7 +957,7 @@ type ReqGameAction struct { func (x *ReqGameAction) Reset() { *x = ReqGameAction{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[17] + mi := &file_poker_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -931,7 +970,7 @@ func (x *ReqGameAction) String() string { func (*ReqGameAction) ProtoMessage() {} func (x *ReqGameAction) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[17] + mi := &file_poker_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -944,7 +983,7 @@ func (x *ReqGameAction) ProtoReflect() protoreflect.Message { // Deprecated: Use ReqGameAction.ProtoReflect.Descriptor instead. func (*ReqGameAction) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{17} + return file_poker_proto_rawDescGZIP(), []int{18} } func (x *ReqGameAction) GetAction() int32 { @@ -970,7 +1009,7 @@ type ResGameAction struct { func (x *ResGameAction) Reset() { *x = ResGameAction{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[18] + mi := &file_poker_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -983,7 +1022,7 @@ func (x *ResGameAction) String() string { func (*ResGameAction) ProtoMessage() {} func (x *ResGameAction) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[18] + mi := &file_poker_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -996,7 +1035,7 @@ func (x *ResGameAction) ProtoReflect() protoreflect.Message { // Deprecated: Use ResGameAction.ProtoReflect.Descriptor instead. func (*ResGameAction) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{18} + return file_poker_proto_rawDescGZIP(), []int{19} } // 查询玩家当前游戏状态 @@ -1009,7 +1048,7 @@ type ReqGameFullStatus struct { func (x *ReqGameFullStatus) Reset() { *x = ReqGameFullStatus{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[19] + mi := &file_poker_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1022,7 +1061,7 @@ func (x *ReqGameFullStatus) String() string { func (*ReqGameFullStatus) ProtoMessage() {} func (x *ReqGameFullStatus) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[19] + mi := &file_poker_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1035,7 +1074,7 @@ func (x *ReqGameFullStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use ReqGameFullStatus.ProtoReflect.Descriptor instead. func (*ReqGameFullStatus) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{19} + return file_poker_proto_rawDescGZIP(), []int{20} } type ResGameFullStatus struct { @@ -1047,7 +1086,8 @@ type ResGameFullStatus struct { TableNo int32 `protobuf:"varint,2,opt,name=tableNo,proto3" json:"tableNo,omitempty"` // 所在桌面编号 GameStage int32 `protobuf:"varint,3,opt,name=gameStage,proto3" json:"gameStage,omitempty"` // 游戏阶段? Chip int32 `protobuf:"varint,4,opt,name=chip,proto3" json:"chip,omitempty"` // 牌桌筹码 - RoundTimes int32 `protobuf:"varint,5,opt,name=RoundTimes,proto3" json:"RoundTimes,omitempty"` // 回合次数 + RoundTimes int32 `protobuf:"varint,5,opt,name=roundTimes,proto3" json:"roundTimes,omitempty"` // 回合次数 + PlayerId int64 `protobuf:"varint,6,opt,name=playerId,proto3" json:"playerId,omitempty"` // 当前玩家id PublicCard []*Card `protobuf:"bytes,9,rep,name=publicCard,proto3" json:"publicCard,omitempty"` // 公共牌 Players []*TablePlayer `protobuf:"bytes,10,rep,name=players,proto3" json:"players,omitempty"` } @@ -1055,7 +1095,7 @@ type ResGameFullStatus struct { func (x *ResGameFullStatus) Reset() { *x = ResGameFullStatus{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[20] + mi := &file_poker_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1068,7 +1108,7 @@ func (x *ResGameFullStatus) String() string { func (*ResGameFullStatus) ProtoMessage() {} func (x *ResGameFullStatus) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[20] + mi := &file_poker_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1081,7 +1121,7 @@ func (x *ResGameFullStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use ResGameFullStatus.ProtoReflect.Descriptor instead. func (*ResGameFullStatus) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{20} + return file_poker_proto_rawDescGZIP(), []int{21} } func (x *ResGameFullStatus) GetInGame() bool { @@ -1119,6 +1159,13 @@ func (x *ResGameFullStatus) GetRoundTimes() int32 { return 0 } +func (x *ResGameFullStatus) GetPlayerId() int64 { + if x != nil { + return x.PlayerId + } + return 0 +} + func (x *ResGameFullStatus) GetPublicCard() []*Card { if x != nil { return x.PublicCard @@ -1151,7 +1198,7 @@ type TablePlayer struct { func (x *TablePlayer) Reset() { *x = TablePlayer{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[21] + mi := &file_poker_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1164,7 +1211,7 @@ func (x *TablePlayer) String() string { func (*TablePlayer) ProtoMessage() {} func (x *TablePlayer) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[21] + mi := &file_poker_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1177,7 +1224,7 @@ func (x *TablePlayer) ProtoReflect() protoreflect.Message { // Deprecated: Use TablePlayer.ProtoReflect.Descriptor instead. func (*TablePlayer) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{21} + return file_poker_proto_rawDescGZIP(), []int{22} } func (x *TablePlayer) GetRobot() bool { @@ -1242,13 +1289,13 @@ type Card struct { unknownFields protoimpl.UnknownFields Dot int32 `protobuf:"varint,1,opt,name=dot,proto3" json:"dot,omitempty"` // 点数 - Suit string `protobuf:"bytes,2,opt,name=suit,proto3" json:"suit,omitempty"` // 花色 + Suit string `protobuf:"bytes,2,opt,name=suit,proto3" json:"suit,omitempty"` // 花色, protobuf默认值0, string类型区分空白牌 } func (x *Card) Reset() { *x = Card{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[22] + mi := &file_poker_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1261,7 +1308,7 @@ func (x *Card) String() string { func (*Card) ProtoMessage() {} func (x *Card) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[22] + mi := &file_poker_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1274,7 +1321,7 @@ func (x *Card) ProtoReflect() protoreflect.Message { // Deprecated: Use Card.ProtoReflect.Descriptor instead. func (*Card) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{22} + return file_poker_proto_rawDescGZIP(), []int{23} } func (x *Card) GetDot() int32 { @@ -1351,46 +1398,49 @@ var file_poker_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x52, 0x65, 0x61, 0x64, 0x79, 0x53, 0x74, 0x61, 0x72, 0x74, 0x22, 0x2d, 0x0a, 0x0f, 0x52, 0x65, 0x71, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x22, 0x3b, - 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, 0x69, 0x70, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x22, 0x0f, 0x0a, 0x0d, 0x52, - 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x13, 0x0a, 0x11, - 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x75, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0xee, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x75, 0x6c, - 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, 0x47, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x6e, 0x47, 0x61, 0x6d, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x61, 0x6d, - 0x65, 0x53, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x67, 0x61, - 0x6d, 0x65, 0x53, 0x74, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, 0x69, 0x70, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x52, - 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x0a, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x63, 0x43, 0x61, 0x72, 0x64, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x0a, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x43, 0x61, 0x72, 0x64, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, - 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x61, - 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, - 0x72, 0x73, 0x22, 0xd2, 0x01, 0x0a, 0x0b, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x61, 0x79, - 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, - 0x63, 0x68, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, - 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x73, 0x74, - 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, - 0x12, 0x25, 0x0a, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x08, 0x68, - 0x61, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x22, 0x2c, 0x0a, 0x04, 0x43, 0x61, 0x72, 0x64, 0x12, - 0x10, 0x0a, 0x03, 0x64, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x64, 0x6f, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x75, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x73, 0x75, 0x69, 0x74, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, - 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x22, 0x11, + 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x54, 0x61, 0x62, 0x6c, + 0x65, 0x22, 0x3b, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, + 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x22, 0x0f, + 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, + 0x13, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x75, 0x6c, 0x6c, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x22, 0x8a, 0x02, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, + 0x46, 0x75, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, + 0x47, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x6e, 0x47, 0x61, + 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, + 0x67, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x67, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, + 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x12, 0x1e, + 0x0a, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x0a, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x43, 0x61, 0x72, 0x64, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x43, 0x61, 0x72, 0x64, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, + 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x61, 0x62, + 0x6c, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x73, 0x22, 0xd2, 0x01, 0x0a, 0x0b, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x63, + 0x68, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x73, 0x74, 0x65, + 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x12, + 0x25, 0x0a, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x08, 0x68, 0x61, + 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x22, 0x2c, 0x0a, 0x04, 0x43, 0x61, 0x72, 0x64, 0x12, 0x10, + 0x0a, 0x03, 0x64, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x64, 0x6f, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x73, 0x75, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x73, 0x75, 0x69, 0x74, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, + 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1405,7 +1455,7 @@ func file_poker_proto_rawDescGZIP() []byte { return file_poker_proto_rawDescData } -var file_poker_proto_msgTypes = make([]protoimpl.MessageInfo, 23) +var file_poker_proto_msgTypes = make([]protoimpl.MessageInfo, 24) var file_poker_proto_goTypes = []interface{}{ (*ProtoWrap)(nil), // 0: api.ProtoWrap (*Ping)(nil), // 1: api.Ping @@ -1424,19 +1474,20 @@ var file_poker_proto_goTypes = []interface{}{ (*ReqLeaveTable)(nil), // 14: api.ReqLeaveTable (*ReqReadyStart)(nil), // 15: api.ReqReadyStart (*ReqKickOutTable)(nil), // 16: api.ReqKickOutTable - (*ReqGameAction)(nil), // 17: api.ReqGameAction - (*ResGameAction)(nil), // 18: api.ResGameAction - (*ReqGameFullStatus)(nil), // 19: api.ReqGameFullStatus - (*ResGameFullStatus)(nil), // 20: api.ResGameFullStatus - (*TablePlayer)(nil), // 21: api.TablePlayer - (*Card)(nil), // 22: api.Card + (*ResKickOutTable)(nil), // 17: api.ResKickOutTable + (*ReqGameAction)(nil), // 18: api.ReqGameAction + (*ResGameAction)(nil), // 19: api.ResGameAction + (*ReqGameFullStatus)(nil), // 20: api.ReqGameFullStatus + (*ResGameFullStatus)(nil), // 21: api.ResGameFullStatus + (*TablePlayer)(nil), // 22: api.TablePlayer + (*Card)(nil), // 23: api.Card } var file_poker_proto_depIdxs = []int32{ 9, // 0: api.ResLobbyView.tables:type_name -> api.LobbyTable 10, // 1: api.LobbyTable.players:type_name -> api.LobbyPlayer - 22, // 2: api.ResGameFullStatus.publicCard:type_name -> api.Card - 21, // 3: api.ResGameFullStatus.players:type_name -> api.TablePlayer - 22, // 4: api.TablePlayer.handCard:type_name -> api.Card + 23, // 2: api.ResGameFullStatus.publicCard:type_name -> api.Card + 22, // 3: api.ResGameFullStatus.players:type_name -> api.TablePlayer + 23, // 4: api.TablePlayer.handCard:type_name -> api.Card 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 @@ -1655,7 +1706,7 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReqGameAction); i { + switch v := v.(*ResKickOutTable); i { case 0: return &v.state case 1: @@ -1667,7 +1718,7 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResGameAction); i { + switch v := v.(*ReqGameAction); i { case 0: return &v.state case 1: @@ -1679,7 +1730,7 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReqGameFullStatus); i { + switch v := v.(*ResGameAction); i { case 0: return &v.state case 1: @@ -1691,7 +1742,7 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResGameFullStatus); i { + switch v := v.(*ReqGameFullStatus); i { case 0: return &v.state case 1: @@ -1703,7 +1754,7 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TablePlayer); i { + switch v := v.(*ResGameFullStatus); i { case 0: return &v.state case 1: @@ -1715,6 +1766,18 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TablePlayer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poker_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Card); i { case 0: return &v.state @@ -1733,7 +1796,7 @@ func file_poker_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poker_proto_rawDesc, NumEnums: 0, - NumMessages: 23, + NumMessages: 24, NumExtensions: 0, NumServices: 0, }, diff --git a/api/poker.proto b/api/poker.proto index 117c1e0..a06f4c9 100644 --- a/api/poker.proto +++ b/api/poker.proto @@ -97,7 +97,12 @@ message ReqReadyStart { // 房主踢人 message ReqKickOutTable { - int32 playerId = 1; + int64 playerId = 1; +} + +// 被踢人接受消息 +message ResKickOutTable { + } message ReqGameAction { @@ -118,7 +123,8 @@ message ResGameFullStatus { // 玩家当前游戏状态: 断线,重新登录.... int32 tableNo = 2; // 所在桌面编号 int32 gameStage = 3; // 游戏阶段? int32 chip = 4; // 牌桌筹码 - int32 RoundTimes = 5; // 回合次数 + int32 roundTimes = 5; // 回合次数 + int64 playerId = 6; // 当前玩家id repeated Card publicCard = 9; // 公共牌 repeated TablePlayer players = 10; diff --git a/api/proto.js b/api/proto.js index b88b066..7ff0152 100644 --- a/api/proto.js +++ b/api/proto.js @@ -3585,7 +3585,7 @@ export const api = $root.api = (() => { * Properties of a ReqKickOutTable. * @memberof api * @interface IReqKickOutTable - * @property {number|null} [playerId] ReqKickOutTable playerId + * @property {number|Long|null} [playerId] ReqKickOutTable playerId */ /** @@ -3605,11 +3605,11 @@ export const api = $root.api = (() => { /** * ReqKickOutTable playerId. - * @member {number} playerId + * @member {number|Long} playerId * @memberof api.ReqKickOutTable * @instance */ - ReqKickOutTable.prototype.playerId = 0; + ReqKickOutTable.prototype.playerId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * Creates a new ReqKickOutTable instance using the specified properties. @@ -3636,7 +3636,7 @@ export const api = $root.api = (() => { if (!writer) writer = $Writer.create(); if (message.playerId != null && Object.hasOwnProperty.call(message, "playerId")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.playerId); + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.playerId); return writer; }; @@ -3672,7 +3672,7 @@ export const api = $root.api = (() => { let tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.playerId = reader.int32(); + message.playerId = reader.int64(); break; } default: @@ -3711,8 +3711,8 @@ export const api = $root.api = (() => { if (typeof message !== "object" || message === null) return "object expected"; if (message.playerId != null && message.hasOwnProperty("playerId")) - if (!$util.isInteger(message.playerId)) - return "playerId: integer expected"; + if (!$util.isInteger(message.playerId) && !(message.playerId && $util.isInteger(message.playerId.low) && $util.isInteger(message.playerId.high))) + return "playerId: integer|Long expected"; return null; }; @@ -3729,7 +3729,14 @@ export const api = $root.api = (() => { return object; let message = new $root.api.ReqKickOutTable(); if (object.playerId != null) - message.playerId = object.playerId | 0; + if ($util.Long) + (message.playerId = $util.Long.fromValue(object.playerId)).unsigned = false; + else if (typeof object.playerId === "string") + message.playerId = parseInt(object.playerId, 10); + else if (typeof object.playerId === "number") + message.playerId = object.playerId; + else if (typeof object.playerId === "object") + message.playerId = new $util.LongBits(object.playerId.low >>> 0, object.playerId.high >>> 0).toNumber(); return message; }; @@ -3747,9 +3754,16 @@ export const api = $root.api = (() => { options = {}; let object = {}; if (options.defaults) - object.playerId = 0; + if ($util.Long) { + let long = new $util.Long(0, 0, false); + object.playerId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.playerId = options.longs === String ? "0" : 0; if (message.playerId != null && message.hasOwnProperty("playerId")) - object.playerId = message.playerId; + if (typeof message.playerId === "number") + object.playerId = options.longs === String ? String(message.playerId) : message.playerId; + else + object.playerId = options.longs === String ? $util.Long.prototype.toString.call(message.playerId) : options.longs === Number ? new $util.LongBits(message.playerId.low >>> 0, message.playerId.high >>> 0).toNumber() : message.playerId; return object; }; @@ -3782,6 +3796,181 @@ export const api = $root.api = (() => { return ReqKickOutTable; })(); + api.ResKickOutTable = (function() { + + /** + * Properties of a ResKickOutTable. + * @memberof api + * @interface IResKickOutTable + */ + + /** + * Constructs a new ResKickOutTable. + * @memberof api + * @classdesc Represents a ResKickOutTable. + * @implements IResKickOutTable + * @constructor + * @param {api.IResKickOutTable=} [properties] Properties to set + */ + function ResKickOutTable(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ResKickOutTable instance using the specified properties. + * @function create + * @memberof api.ResKickOutTable + * @static + * @param {api.IResKickOutTable=} [properties] Properties to set + * @returns {api.ResKickOutTable} ResKickOutTable instance + */ + ResKickOutTable.create = function create(properties) { + return new ResKickOutTable(properties); + }; + + /** + * Encodes the specified ResKickOutTable message. Does not implicitly {@link api.ResKickOutTable.verify|verify} messages. + * @function encode + * @memberof api.ResKickOutTable + * @static + * @param {api.IResKickOutTable} message ResKickOutTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResKickOutTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ResKickOutTable message, length delimited. Does not implicitly {@link api.ResKickOutTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResKickOutTable + * @static + * @param {api.IResKickOutTable} message ResKickOutTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResKickOutTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResKickOutTable message from the specified reader or buffer. + * @function decode + * @memberof api.ResKickOutTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResKickOutTable} ResKickOutTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResKickOutTable.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResKickOutTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResKickOutTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResKickOutTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResKickOutTable} ResKickOutTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResKickOutTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResKickOutTable message. + * @function verify + * @memberof api.ResKickOutTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResKickOutTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ResKickOutTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResKickOutTable + * @static + * @param {Object.} object Plain object + * @returns {api.ResKickOutTable} ResKickOutTable + */ + ResKickOutTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResKickOutTable) + return object; + return new $root.api.ResKickOutTable(); + }; + + /** + * Creates a plain object from a ResKickOutTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResKickOutTable + * @static + * @param {api.ResKickOutTable} message ResKickOutTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResKickOutTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ResKickOutTable to JSON. + * @function toJSON + * @memberof api.ResKickOutTable + * @instance + * @returns {Object.} JSON object + */ + ResKickOutTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResKickOutTable + * @function getTypeUrl + * @memberof api.ResKickOutTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResKickOutTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResKickOutTable"; + }; + + return ResKickOutTable; + })(); + api.ReqGameAction = (function() { /** @@ -4369,7 +4558,8 @@ export const api = $root.api = (() => { * @property {number|null} [tableNo] ResGameFullStatus tableNo * @property {number|null} [gameStage] ResGameFullStatus gameStage * @property {number|null} [chip] ResGameFullStatus chip - * @property {number|null} [RoundTimes] ResGameFullStatus RoundTimes + * @property {number|null} [roundTimes] ResGameFullStatus roundTimes + * @property {number|Long|null} [playerId] ResGameFullStatus playerId * @property {Array.|null} [publicCard] ResGameFullStatus publicCard * @property {Array.|null} [players] ResGameFullStatus players */ @@ -4424,12 +4614,20 @@ export const api = $root.api = (() => { ResGameFullStatus.prototype.chip = 0; /** - * ResGameFullStatus RoundTimes. - * @member {number} RoundTimes + * ResGameFullStatus roundTimes. + * @member {number} roundTimes * @memberof api.ResGameFullStatus * @instance */ - ResGameFullStatus.prototype.RoundTimes = 0; + ResGameFullStatus.prototype.roundTimes = 0; + + /** + * ResGameFullStatus playerId. + * @member {number|Long} playerId + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.playerId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * ResGameFullStatus publicCard. @@ -4479,8 +4677,10 @@ export const api = $root.api = (() => { writer.uint32(/* id 3, wireType 0 =*/24).int32(message.gameStage); if (message.chip != null && Object.hasOwnProperty.call(message, "chip")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.chip); - if (message.RoundTimes != null && Object.hasOwnProperty.call(message, "RoundTimes")) - writer.uint32(/* id 5, wireType 0 =*/40).int32(message.RoundTimes); + if (message.roundTimes != null && Object.hasOwnProperty.call(message, "roundTimes")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.roundTimes); + if (message.playerId != null && Object.hasOwnProperty.call(message, "playerId")) + writer.uint32(/* id 6, wireType 0 =*/48).int64(message.playerId); if (message.publicCard != null && message.publicCard.length) for (let i = 0; i < message.publicCard.length; ++i) $root.api.Card.encode(message.publicCard[i], writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); @@ -4538,7 +4738,11 @@ export const api = $root.api = (() => { break; } case 5: { - message.RoundTimes = reader.int32(); + message.roundTimes = reader.int32(); + break; + } + case 6: { + message.playerId = reader.int64(); break; } case 9: { @@ -4600,9 +4804,12 @@ export const api = $root.api = (() => { if (message.chip != null && message.hasOwnProperty("chip")) if (!$util.isInteger(message.chip)) return "chip: integer expected"; - if (message.RoundTimes != null && message.hasOwnProperty("RoundTimes")) - if (!$util.isInteger(message.RoundTimes)) - return "RoundTimes: integer expected"; + if (message.roundTimes != null && message.hasOwnProperty("roundTimes")) + if (!$util.isInteger(message.roundTimes)) + return "roundTimes: integer expected"; + if (message.playerId != null && message.hasOwnProperty("playerId")) + if (!$util.isInteger(message.playerId) && !(message.playerId && $util.isInteger(message.playerId.low) && $util.isInteger(message.playerId.high))) + return "playerId: integer|Long expected"; if (message.publicCard != null && message.hasOwnProperty("publicCard")) { if (!Array.isArray(message.publicCard)) return "publicCard: array expected"; @@ -4644,8 +4851,17 @@ export const api = $root.api = (() => { message.gameStage = object.gameStage | 0; if (object.chip != null) message.chip = object.chip | 0; - if (object.RoundTimes != null) - message.RoundTimes = object.RoundTimes | 0; + if (object.roundTimes != null) + message.roundTimes = object.roundTimes | 0; + if (object.playerId != null) + if ($util.Long) + (message.playerId = $util.Long.fromValue(object.playerId)).unsigned = false; + else if (typeof object.playerId === "string") + message.playerId = parseInt(object.playerId, 10); + else if (typeof object.playerId === "number") + message.playerId = object.playerId; + else if (typeof object.playerId === "object") + message.playerId = new $util.LongBits(object.playerId.low >>> 0, object.playerId.high >>> 0).toNumber(); if (object.publicCard) { if (!Array.isArray(object.publicCard)) throw TypeError(".api.ResGameFullStatus.publicCard: array expected"); @@ -4691,7 +4907,12 @@ export const api = $root.api = (() => { object.tableNo = 0; object.gameStage = 0; object.chip = 0; - object.RoundTimes = 0; + object.roundTimes = 0; + if ($util.Long) { + let long = new $util.Long(0, 0, false); + object.playerId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.playerId = options.longs === String ? "0" : 0; } if (message.inGame != null && message.hasOwnProperty("inGame")) object.inGame = message.inGame; @@ -4701,8 +4922,13 @@ export const api = $root.api = (() => { object.gameStage = message.gameStage; if (message.chip != null && message.hasOwnProperty("chip")) object.chip = message.chip; - if (message.RoundTimes != null && message.hasOwnProperty("RoundTimes")) - object.RoundTimes = message.RoundTimes; + if (message.roundTimes != null && message.hasOwnProperty("roundTimes")) + object.roundTimes = message.roundTimes; + if (message.playerId != null && message.hasOwnProperty("playerId")) + if (typeof message.playerId === "number") + object.playerId = options.longs === String ? String(message.playerId) : message.playerId; + else + object.playerId = options.longs === String ? $util.Long.prototype.toString.call(message.playerId) : options.longs === Number ? new $util.LongBits(message.playerId.low >>> 0, message.playerId.high >>> 0).toNumber() : message.playerId; if (message.publicCard && message.publicCard.length) { object.publicCard = []; for (let j = 0; j < message.publicCard.length; ++j) diff --git a/internal/game/table.go b/internal/game/table.go index dad9a6e..afe5dc3 100644 --- a/internal/game/table.go +++ b/internal/game/table.go @@ -24,14 +24,14 @@ type Table struct { Robots []*Robot BigBlindsPos int32 // 大盲注位 - PlayerJoinLock *sync.Mutex - ChipLock *sync.Mutex // 桌面筹码更新锁 + PlayersLock *sync.Mutex + ChipLock *sync.Mutex // 桌面筹码更新锁 // TODO game logs7 } func (t *Table) JoinPlayer(player *Player) error { - t.PlayerJoinLock.Lock() - defer t.PlayerJoinLock.Unlock() + t.PlayersLock.Lock() + defer t.PlayersLock.Unlock() for i := range t.Players { // 找个空位坐下 if t.Players[i] == nil { @@ -98,15 +98,16 @@ func (t *Table) NoticeGameFullStatus() { // 发送当前游戏状态消息到牌桌所有用户 for _, player := range t.Players { if player != nil && player.ProtoWriter != nil { + resGame.PlayerId = player.Id player.ProtoWriter.Write(resGame) } } } // NoticeGamePlayerCall TODO 发送(下注信息、下注人、下一位下注人)到牌桌所有用户 -func (t *Table) NoticeGamePlayerCall() { - -} +//func (t *Table) NoticeGamePlayerCall() { +// +//} type Stage int diff --git a/internal/server/wsroute.go b/internal/server/wsroute.go index 0463eb8..48a82d0 100644 --- a/internal/server/wsroute.go +++ b/internal/server/wsroute.go @@ -24,6 +24,12 @@ func init() { HandleNetPlayerMsg(&api.ReqGameFullStatus{}, service.HandleReqGameFullStatus) // 加入桌面 HandleNetAccountMsg(&api.ReqJoinTable{}, service.HandleJoinTable) + + // 踢人 + HandleNetPlayerMsg(&api.ReqKickOutTable{}, service.HandleReqKickOutTable) + // 离开房间 + HandleNetPlayerMsg(&api.ReqLeaveTable{}, service.HandleReqLeaveTable) + } func checkExistsTypeHandler(op int32, err error) { diff --git a/internal/service/table.go b/internal/service/table.go index 07035b1..17278d6 100644 --- a/internal/service/table.go +++ b/internal/service/table.go @@ -30,13 +30,13 @@ func HandleReqCreateTable(account *session.NetAccount, msg *api.ReqCreateTable) Dealer: game.NewDealer(), PublicCards: [5]*game.Card{&game.Card{Dot: 0, Suit: 3}, &game.Card{Dot: 1, Suit: 3}, nil, nil, nil}, - PlayerNum: playerNum + 1, - RobotNum: robotNum, - Players: make([]*game.Player, playerNum), - Robots: make([]*game.Robot, robotNum), - BigBlindsPos: 0, - PlayerJoinLock: &sync.Mutex{}, - ChipLock: &sync.Mutex{}, + PlayerNum: playerNum + 1, + RobotNum: robotNum, + Players: make([]*game.Player, playerNum), + Robots: make([]*game.Robot, robotNum), + BigBlindsPos: 0, + PlayersLock: &sync.Mutex{}, + ChipLock: &sync.Mutex{}, } // 房主 [0] @@ -142,6 +142,10 @@ func HandleJoinTable(account *session.NetAccount, msg *api.ReqJoinTable) (proto. // 从账户扣除进入牌桌的金额 account.DecrementBalance(500) account.Player = player + + // 通知其他玩家 + player.GameTable.NoticeGameFullStatus() + return &api.ResSuccess{}, nil } @@ -173,12 +177,75 @@ func HandleLeaveTable(account session.NetAccount, msg *api.ReqCreateTable) (prot } } +// HandleReqKickOutTable 踢人 +func HandleReqKickOutTable(player *game.Player, msg *api.ReqKickOutTable) (proto.Message, error) { + player.GameTable.PlayersLock.Lock() + defer player.GameTable.PlayersLock.Unlock() + + if player.GameTable.MasterId != player.Id { + return &api.ResFail{Msg: "不是房主不能踢人"}, nil + } + if player.Id == msg.PlayerId { + return &api.ResFail{Msg: "不能踢自己"}, nil + } + if player.GameTable.Stage != 1 { + return &api.ResFail{Msg: "牌局进行中不能踢人"}, nil + } + for i, p := range player.GameTable.Players { + if p != nil && p.Id == msg.PlayerId { + // 从牌桌移除该玩家 + player.GameTable.Players[i] = nil + // 被对踢出人发送消息 + account := store.NetAccounts[p.Id] + account.Player = nil // 解除账户绑定 + account.IncrementBalance(player.Chip) // 筹码返还账户 + p.ProtoWriter.Write(&api.ResKickOutTable{}) // 被踢玩家消息 + break + } + } + // 通知牌桌所有玩家 + player.GameTable.NoticeGameFullStatus() + return &api.ResSuccess{}, nil +} + +// HandleReqLeaveTable 离开桌面 +func HandleReqLeaveTable(player *game.Player, msg *api.ReqLeaveTable) (proto.Message, error) { + player.GameTable.PlayersLock.Lock() + defer player.GameTable.PlayersLock.Unlock() + if player.GameTable.Stage != 1 { + return &api.ResFail{Msg: "牌局进行中不能退出"}, nil + } + if player.Status != 1 { + return &api.ResFail{Msg: "您已准备不能退出"}, nil + } + if player.GameTable.MasterId == player.Id { + return &api.ResFail{Msg: "房主不能退出,请解散房间"}, nil + } + // 从牌桌移除 + for i, p := range player.GameTable.Players { + if p.Id == player.Id { + player.GameTable.Players[i] = nil + break + } + } + account := store.NetAccounts[player.Id] + account.Player = nil // 解除账户绑定 + account.IncrementBalance(player.Chip) // 筹码返还账户 + + // 通知牌桌其他玩家 + player.GameTable.NoticeGameFullStatus() + + return &api.ResSuccess{}, nil +} + // HandleReqGameFullStatus 获取牌桌当前所有状态 func HandleReqGameFullStatus(player *game.Player, msg *api.ReqGameFullStatus) (proto.Message, error) { if player.GameTable == nil { return &api.ResFail{Msg: "当前未加入牌桌"}, nil } resGame := player.GameTable.BuildResGameFullStatus() + resGame.PlayerId = player.Id + // TODO 其他玩家手牌不返回,计算自己的5张推荐牌 return resGame, nil } diff --git a/internal/session/net_client.go b/internal/session/net_client.go index 33874c7..a1efde6 100644 --- a/internal/session/net_client.go +++ b/internal/session/net_client.go @@ -1,6 +1,7 @@ package session import ( + "fmt" "github.com/golang/protobuf/proto" "github.com/gorilla/websocket" "log" @@ -28,12 +29,16 @@ func (c *NetClient) Write(msg proto.Message) { func (c *NetClient) WriteSeq(success bool, seq int32, msg proto.Message) { op, err := api.GetProtoOp(msg) if err != nil { + fmt.Println("write msg match op err:", err) return } bytes, err := proto.Marshal(msg) wrap := &api.ProtoWrap{Ver: 1, Op: op, Seq: seq, Success: success, Body: bytes} wrapBytes, err := proto.Marshal(wrap) err = c.Conn.WriteMessage(websocket.BinaryMessage, wrapBytes) + if err != nil { + fmt.Println("write msg err:", err) + } } func NewNetClient(conn *websocket.Conn) *NetClient {