diff --git a/comm/imodule.go b/comm/imodule.go index e1703b0ba..b1b4974ca 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -676,11 +676,15 @@ type ( IDColor interface { CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error) UserOffline(roomid string, uid string) (err error) + //主动认输 + AdmitDefeat(roomid string, uid string) (err error) } //犬兔大战 ICanineRabbit interface { CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error) UserOffline(roomid string, uid string) (err error) + //主动认输 + AdmitDefeat(roomid string, uid string) (err error) } IEntertainment interface { // 添加三消卡片资源 @@ -692,7 +696,10 @@ type ( //捉虫子 ICatchBugs interface { CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error) + //用户离线 UserOffline(roomid string, uid string) (err error) + //主动认输 + AdmitDefeat(roomid string, uid string) (err error) } //海岛 IIsland interface { diff --git a/modules/caninerabbit/module.go b/modules/caninerabbit/module.go index f027271c9..606410cca 100644 --- a/modules/caninerabbit/module.go +++ b/modules/caninerabbit/module.go @@ -170,3 +170,15 @@ func (this *CanineRabbit) UserOffline(roomid string, uid string) (err error) { err = room.PlayerWin(uid, &pb.CanineRabbitWinReq{Roomid: roomid, Iswin: false}) return } + +//用户离线 +func (this *CanineRabbit) AdmitDefeat(roomid string, uid string) (err error) { + var ( + room *Room + ) + if room, err = this.rooms.queryRoom(roomid); err != nil { + return + } + err = room.PlayerWin(uid, &pb.CanineRabbitWinReq{Roomid: roomid, Iswin: false}) + return +} diff --git a/modules/catchbugs/module.go b/modules/catchbugs/module.go index 1348c7a09..f01809bc3 100644 --- a/modules/catchbugs/module.go +++ b/modules/catchbugs/module.go @@ -169,3 +169,15 @@ func (this *CatchBugs) UserOffline(roomid string, uid string) (err error) { err = room.PlayerOffline(uid) return } + +//用户离线 +func (this *CatchBugs) AdmitDefeat(roomid string, uid string) (err error) { + var ( + room *Room + ) + if room, err = this.rooms.queryRoom(roomid); err != nil { + return + } + err = room.PlayerOffline(uid) + return +} diff --git a/modules/dcolor/module.go b/modules/dcolor/module.go index d5f2fde71..f8e7f3e9f 100644 --- a/modules/dcolor/module.go +++ b/modules/dcolor/module.go @@ -135,3 +135,15 @@ func (this *DColor) UserOffline(roomid string, uid string) (err error) { err = room.PlayerOffline(uid) return } + +//用户离线 +func (this *DColor) AdmitDefeat(roomid string, uid string) (err error) { + var ( + room *Room + ) + if room, err = this.rooms.queryRoom(roomid); err != nil { + return + } + err = room.PlayerOffline(uid) + return +} diff --git a/modules/gameinvite/api_admitdefeat.go b/modules/gameinvite/api_admitdefeat.go new file mode 100644 index 000000000..67003aeeb --- /dev/null +++ b/modules/gameinvite/api_admitdefeat.go @@ -0,0 +1,62 @@ +package gameinvite + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" +) + +// 踢馆(熊猫武馆) +func (this *apiComp) AdmitDefeatCheck(session comm.IUserSession, req *pb.GameInviteAdmitDefeatReq) (errdata *pb.ErrorData) { + if req.Roomid == "" { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + } + } + return +} + +func (this *apiComp) AdmitDefeat(session comm.IUserSession, req *pb.GameInviteAdmitDefeatReq) (errdata *pb.ErrorData) { + var ( + err error + ) + if errdata = this.AdmitDefeatCheck(session, req); errdata != nil { + return + } + switch req.Gtype { + case 1: + + case 2: + if err = this.module.caninerabbit.AdmitDefeat(req.Roomid, session.GetUserId()); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + break + case 3: + if err = this.module.dcolor.AdmitDefeat(req.Roomid, session.GetUserId()); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + break + case 4: + if err = this.module.catchBugs.AdmitDefeat(req.Roomid, session.GetUserId()); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + break + } + session.SendMsg(string(this.module.GetType()), "admitdefeat", &pb.GameInviteAdmitDefeatResp{}) + return +} diff --git a/pb/gameinvite_msg.pb.go b/pb/gameinvite_msg.pb.go index 7053b255a..670743dfc 100644 --- a/pb/gameinvite_msg.pb.go +++ b/pb/gameinvite_msg.pb.go @@ -417,6 +417,101 @@ func (x *GameInviteQiecuonotifyPush) GetRules() string { return "" } +//游戏邀请 认输请求 +type GameInviteAdmitDefeatReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Gtype int32 `protobuf:"varint,1,opt,name=gtype,proto3" json:"gtype"` //游戏类型 + Roomid string `protobuf:"bytes,2,opt,name=roomid,proto3" json:"roomid"` //房间号 +} + +func (x *GameInviteAdmitDefeatReq) Reset() { + *x = GameInviteAdmitDefeatReq{} + if protoimpl.UnsafeEnabled { + mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GameInviteAdmitDefeatReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GameInviteAdmitDefeatReq) ProtoMessage() {} + +func (x *GameInviteAdmitDefeatReq) ProtoReflect() protoreflect.Message { + mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[7] + 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 GameInviteAdmitDefeatReq.ProtoReflect.Descriptor instead. +func (*GameInviteAdmitDefeatReq) Descriptor() ([]byte, []int) { + return file_gameinvite_gameinvite_msg_proto_rawDescGZIP(), []int{7} +} + +func (x *GameInviteAdmitDefeatReq) GetGtype() int32 { + if x != nil { + return x.Gtype + } + return 0 +} + +func (x *GameInviteAdmitDefeatReq) GetRoomid() string { + if x != nil { + return x.Roomid + } + return "" +} + +//游戏邀请 认输请求 回应 +type GameInviteAdmitDefeatResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GameInviteAdmitDefeatResp) Reset() { + *x = GameInviteAdmitDefeatResp{} + if protoimpl.UnsafeEnabled { + mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GameInviteAdmitDefeatResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GameInviteAdmitDefeatResp) ProtoMessage() {} + +func (x *GameInviteAdmitDefeatResp) ProtoReflect() protoreflect.Message { + mi := &file_gameinvite_gameinvite_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 GameInviteAdmitDefeatResp.ProtoReflect.Descriptor instead. +func (*GameInviteAdmitDefeatResp) Descriptor() ([]byte, []int) { + return file_gameinvite_gameinvite_msg_proto_rawDescGZIP(), []int{8} +} + //游戏邀请离线请求 type RPC_GameInviteOfflineReq struct { state protoimpl.MessageState @@ -431,7 +526,7 @@ type RPC_GameInviteOfflineReq struct { func (x *RPC_GameInviteOfflineReq) Reset() { *x = RPC_GameInviteOfflineReq{} if protoimpl.UnsafeEnabled { - mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[7] + mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -444,7 +539,7 @@ func (x *RPC_GameInviteOfflineReq) String() string { func (*RPC_GameInviteOfflineReq) ProtoMessage() {} func (x *RPC_GameInviteOfflineReq) ProtoReflect() protoreflect.Message { - mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[7] + mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -457,7 +552,7 @@ func (x *RPC_GameInviteOfflineReq) ProtoReflect() protoreflect.Message { // Deprecated: Use RPC_GameInviteOfflineReq.ProtoReflect.Descriptor instead. func (*RPC_GameInviteOfflineReq) Descriptor() ([]byte, []int) { - return file_gameinvite_gameinvite_msg_proto_rawDescGZIP(), []int{7} + return file_gameinvite_gameinvite_msg_proto_rawDescGZIP(), []int{9} } func (x *RPC_GameInviteOfflineReq) GetGtype() int32 { @@ -491,7 +586,7 @@ type RPC_GameInviteOfflineResp struct { func (x *RPC_GameInviteOfflineResp) Reset() { *x = RPC_GameInviteOfflineResp{} if protoimpl.UnsafeEnabled { - mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[8] + mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -504,7 +599,7 @@ func (x *RPC_GameInviteOfflineResp) String() string { func (*RPC_GameInviteOfflineResp) ProtoMessage() {} func (x *RPC_GameInviteOfflineResp) ProtoReflect() protoreflect.Message { - mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[8] + mi := &file_gameinvite_gameinvite_msg_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -517,7 +612,7 @@ func (x *RPC_GameInviteOfflineResp) ProtoReflect() protoreflect.Message { // Deprecated: Use RPC_GameInviteOfflineResp.ProtoReflect.Descriptor instead. func (*RPC_GameInviteOfflineResp) Descriptor() ([]byte, []int) { - return file_gameinvite_gameinvite_msg_proto_rawDescGZIP(), []int{8} + return file_gameinvite_gameinvite_msg_proto_rawDescGZIP(), []int{10} } var File_gameinvite_gameinvite_msg_proto protoreflect.FileDescriptor @@ -558,16 +653,22 @@ var file_gameinvite_gameinvite_msg_proto_rawDesc = []byte{ 0x74, 0x69, 0x66, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x72, - 0x75, 0x6c, 0x65, 0x73, 0x22, 0x60, 0x0a, 0x18, 0x52, 0x50, 0x43, 0x5f, 0x47, 0x61, 0x6d, 0x65, - 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x6c, 0x65, 0x73, 0x22, 0x48, 0x0a, 0x18, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x76, 0x69, + 0x74, 0x65, 0x41, 0x64, 0x6d, 0x69, 0x74, 0x44, 0x65, 0x66, 0x65, 0x61, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x12, 0x16, - 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x6f, 0x66, 0x66, 0x75, 0x69, 0x64, 0x22, 0x1b, 0x0a, 0x19, 0x52, 0x50, 0x43, 0x5f, 0x47, 0x61, - 0x6d, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x22, 0x1b, + 0x0a, 0x19, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x41, 0x64, 0x6d, 0x69, + 0x74, 0x44, 0x65, 0x66, 0x65, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x60, 0x0a, 0x18, 0x52, + 0x50, 0x43, 0x5f, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4f, 0x66, 0x66, + 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, + 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x75, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x75, 0x69, 0x64, 0x22, 0x1b, 0x0a, + 0x19, 0x52, 0x50, 0x43, 0x5f, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4f, + 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -582,7 +683,7 @@ func file_gameinvite_gameinvite_msg_proto_rawDescGZIP() []byte { return file_gameinvite_gameinvite_msg_proto_rawDescData } -var file_gameinvite_gameinvite_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_gameinvite_gameinvite_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_gameinvite_gameinvite_msg_proto_goTypes = []interface{}{ (*GameInviteQiecuoReq)(nil), // 0: GameInviteQiecuoReq (*GameInviteQiecuoResp)(nil), // 1: GameInviteQiecuoResp @@ -591,17 +692,19 @@ var file_gameinvite_gameinvite_msg_proto_goTypes = []interface{}{ (*GameInviteRefuseReq)(nil), // 4: GameInviteRefuseReq (*GameInviteRefuseResp)(nil), // 5: GameInviteRefuseResp (*GameInviteQiecuonotifyPush)(nil), // 6: GameInviteQiecuonotifyPush - (*RPC_GameInviteOfflineReq)(nil), // 7: RPC_GameInviteOfflineReq - (*RPC_GameInviteOfflineResp)(nil), // 8: RPC_GameInviteOfflineResp - (*BaseUserInfo)(nil), // 9: BaseUserInfo + (*GameInviteAdmitDefeatReq)(nil), // 7: GameInviteAdmitDefeatReq + (*GameInviteAdmitDefeatResp)(nil), // 8: GameInviteAdmitDefeatResp + (*RPC_GameInviteOfflineReq)(nil), // 9: RPC_GameInviteOfflineReq + (*RPC_GameInviteOfflineResp)(nil), // 10: RPC_GameInviteOfflineResp + (*BaseUserInfo)(nil), // 11: BaseUserInfo } var file_gameinvite_gameinvite_msg_proto_depIdxs = []int32{ - 9, // 0: GameInviteQiecuonotifyPush.user:type_name -> BaseUserInfo - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 11, // 0: GameInviteQiecuonotifyPush.user:type_name -> BaseUserInfo + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_gameinvite_gameinvite_msg_proto_init() } @@ -696,7 +799,7 @@ func file_gameinvite_gameinvite_msg_proto_init() { } } file_gameinvite_gameinvite_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RPC_GameInviteOfflineReq); i { + switch v := v.(*GameInviteAdmitDefeatReq); i { case 0: return &v.state case 1: @@ -708,6 +811,30 @@ func file_gameinvite_gameinvite_msg_proto_init() { } } file_gameinvite_gameinvite_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GameInviteAdmitDefeatResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gameinvite_gameinvite_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RPC_GameInviteOfflineReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_gameinvite_gameinvite_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RPC_GameInviteOfflineResp); i { case 0: return &v.state @@ -726,7 +853,7 @@ func file_gameinvite_gameinvite_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_gameinvite_gameinvite_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 9, + NumMessages: 11, NumExtensions: 0, NumServices: 0, },