diff --git a/comm/imodule.go b/comm/imodule.go index 84d2e4fad..e082762fb 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -154,7 +154,7 @@ type ( // 获取好友列表 GetFriendList(uid string) []string // 使用好友助战英雄 好友ID:friendId - UseAssistHero(uid, nickName, friendId string) error + UseAssistHero(uid, nickName, friendId string) (*pb.DBHero, error) } //聊天系统 diff --git a/modules/friend/api.go b/modules/friend/api.go index 4e586abfe..44b648231 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -7,23 +7,24 @@ import ( ) const ( - FriendSubTypeList = "list" - FriendSubTypeApply = "apply" - FriendSubTypeApplyList = "applylist" - FriendSubTypeAddBlack = "addblack" - FriendSubTypeDelBlack = "delblack" - FriendSubTypeBlacklist = "blacklist" - FriendSubTypeAgree = "agree" - FriendSubTypeRefuse = "refuse" - FriendSubTypeSearch = "search" - FriendSubTypeZan = "zan" - FriendSubTypeZanreceive = "zanreceive" - FriendSubTypeZanList = "zanlist" - FriendSubTypeRandList = "randlist" - FriendSubTypeAssistHero = "assisthero" - FriendSubTypeDel = "del" - FriendSubTypeAssistlist = "assistlist" - FriendSubTypeGetreward = "getreward" + FriendSubTypeList = "list" + FriendSubTypeApply = "apply" + FriendSubTypeApplyList = "applylist" + FriendSubTypeAddBlack = "addblack" + FriendSubTypeDelBlack = "delblack" + FriendSubTypeBlacklist = "blacklist" + FriendSubTypeAgree = "agree" + FriendSubTypeRefuse = "refuse" + FriendSubTypeSearch = "search" + FriendSubTypeZan = "zan" + FriendSubTypeZanreceive = "zanreceive" + FriendSubTypeZanList = "zanlist" + FriendSubTypeRandList = "randlist" + FriendSubTypeAssistHero = "assisthero" + FriendSubTypeDel = "del" + FriendSubTypeAssistlist = "assistlist" + FriendSubTypeGetreward = "getreward" + FriendSubTypeAssistHeroList = "assistherolist" ) type apiComp struct { diff --git a/modules/friend/api_croos_assistherolist.go b/modules/friend/api_croos_assistherolist.go new file mode 100644 index 000000000..81779992f --- /dev/null +++ b/modules/friend/api_croos_assistherolist.go @@ -0,0 +1,34 @@ +package friend + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +// 助战英雄列表 + +func (this *apiComp) AssistherolistCheck(session comm.IUserSession, req *pb.FriendAssistHeroListReq) (code pb.ErrorCode) { + return +} + +func (this *apiComp) Assistherolist(session comm.IUserSession, req *pb.FriendAssistHeroListReq) (code pb.ErrorCode, data proto.Message) { + + resp := &pb.FriendAssistHeroListResp{} + self := this.moduleFriend.modelFriend.GetFriend(session.GetUserId()) + + for _, fId := range self.FriendIds { + d := this.moduleFriend.modelFriend.GetFriend(fId) + resp.Friends = append(resp.Friends, &pb.FriendBase{ + HeroObjId: d.AssistHeroId, + }) + } + + err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeAssistHeroList, resp) + if err != nil { + code = pb.ErrorCode_SystemError + } + + return +} diff --git a/modules/friend/module.go b/modules/friend/module.go index 6a1017ec0..fd83055d6 100644 --- a/modules/friend/module.go +++ b/modules/friend/module.go @@ -78,7 +78,7 @@ func (this *Friend) GetFriendList(uid string) (uids []string) { } // 使用好友助战英雄 -func (this *Friend) UseAssistHero(uid, nickName, friendId string) error { +func (this *Friend) UseAssistHero(uid, nickName, friendId string) (*pb.DBHero, error) { //指定好友 friend := this.modelFriend.GetFriend(friendId) @@ -95,12 +95,8 @@ func (this *Friend) UseAssistHero(uid, nickName, friendId string) error { "zhuzhanScore": friend.ZhuzhanScore, "record": friend.Record, } - err := this.modelFriend.Change(friendId, update) - if err != nil { - return err - } - + return friend.Hero, this.modelFriend.Change(friendId, update) } } - return nil + return nil, nil } diff --git a/pb/friend_msg.pb.go b/pb/friend_msg.pb.go index 138822c2b..9883908e6 100644 --- a/pb/friend_msg.pb.go +++ b/pb/friend_msg.pb.go @@ -1866,6 +1866,92 @@ func (x *FriendGetrewardResp) GetReceived() int32 { return 0 } +// 助战英雄列表 +type FriendAssistHeroListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FriendAssistHeroListReq) Reset() { + *x = FriendAssistHeroListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_friend_msg_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAssistHeroListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAssistHeroListReq) ProtoMessage() {} + +func (x *FriendAssistHeroListReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_friend_msg_proto_msgTypes[37] + 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 FriendAssistHeroListReq.ProtoReflect.Descriptor instead. +func (*FriendAssistHeroListReq) Descriptor() ([]byte, []int) { + return file_friend_friend_msg_proto_rawDescGZIP(), []int{37} +} + +type FriendAssistHeroListResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Friends []*FriendBase `protobuf:"bytes,1,rep,name=friends,proto3" json:"friends"` //好友 +} + +func (x *FriendAssistHeroListResp) Reset() { + *x = FriendAssistHeroListResp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_friend_msg_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAssistHeroListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAssistHeroListResp) ProtoMessage() {} + +func (x *FriendAssistHeroListResp) ProtoReflect() protoreflect.Message { + mi := &file_friend_friend_msg_proto_msgTypes[38] + 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 FriendAssistHeroListResp.ProtoReflect.Descriptor instead. +func (*FriendAssistHeroListResp) Descriptor() ([]byte, []int) { + return file_friend_friend_msg_proto_rawDescGZIP(), []int{38} +} + +func (x *FriendAssistHeroListResp) GetFriends() []*FriendBase { + if x != nil { + return x.Friends + } + return nil +} + var File_friend_friend_msg_proto protoreflect.FileDescriptor var file_friend_friend_msg_proto_rawDesc = []byte{ @@ -2005,8 +2091,14 @@ var file_friend_friend_msg_proto_rawDesc = []byte{ 0x22, 0x31, 0x0a, 0x13, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x76, 0x65, 0x64, 0x22, 0x19, 0x0a, 0x17, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, + 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x41, + 0x0a, 0x18, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, + 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, 0x66, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -2021,46 +2113,48 @@ func file_friend_friend_msg_proto_rawDescGZIP() []byte { return file_friend_friend_msg_proto_rawDescData } -var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 37) +var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 39) var file_friend_friend_msg_proto_goTypes = []interface{}{ - (*FriendBase)(nil), // 0: FriendBase - (*FriendListReq)(nil), // 1: FriendListReq - (*FriendListResp)(nil), // 2: FriendListResp - (*FriendRandlistReq)(nil), // 3: FriendRandlistReq - (*FriendRandlistResp)(nil), // 4: FriendRandlistResp - (*FriendApplyReq)(nil), // 5: FriendApplyReq - (*FriendApplyResp)(nil), // 6: FriendApplyResp - (*FriendDelReq)(nil), // 7: FriendDelReq - (*FriendDelResp)(nil), // 8: FriendDelResp - (*FriendAgreeReq)(nil), // 9: FriendAgreeReq - (*FriendAgreeResp)(nil), // 10: FriendAgreeResp - (*FriendRefuseReq)(nil), // 11: FriendRefuseReq - (*FriendRefuseResp)(nil), // 12: FriendRefuseResp - (*FriendApplyListReq)(nil), // 13: FriendApplyListReq - (*FriendApplyListResp)(nil), // 14: FriendApplyListResp - (*FriendSearchReq)(nil), // 15: FriendSearchReq - (*FriendSearchResp)(nil), // 16: FriendSearchResp - (*FriendBlackListReq)(nil), // 17: FriendBlackListReq - (*FriendBlackListResp)(nil), // 18: FriendBlackListResp - (*FriendAddBlackReq)(nil), // 19: FriendAddBlackReq - (*FriendAddBlackResp)(nil), // 20: FriendAddBlackResp - (*FriendDelBlackReq)(nil), // 21: FriendDelBlackReq - (*FriendDelBlackResp)(nil), // 22: FriendDelBlackResp - (*FriendTotalReq)(nil), // 23: FriendTotalReq - (*FriendTotalResp)(nil), // 24: FriendTotalResp - (*FriendZanlistReq)(nil), // 25: FriendZanlistReq - (*FriendZanlistResp)(nil), // 26: FriendZanlistResp - (*FriendZanReq)(nil), // 27: FriendZanReq - (*FriendZanResp)(nil), // 28: FriendZanResp - (*FriendZanreceiveReq)(nil), // 29: FriendZanreceiveReq - (*FriendZanreceiveResp)(nil), // 30: FriendZanreceiveResp - (*FriendAssistheroReq)(nil), // 31: FriendAssistheroReq - (*FriendAssistheroResp)(nil), // 32: FriendAssistheroResp - (*FriendAssistlistReq)(nil), // 33: FriendAssistlistReq - (*FriendAssistlistResp)(nil), // 34: FriendAssistlistResp - (*FriendGetrewardReq)(nil), // 35: FriendGetrewardReq - (*FriendGetrewardResp)(nil), // 36: FriendGetrewardResp - (*ZhuZhanRecord)(nil), // 37: ZhuZhanRecord + (*FriendBase)(nil), // 0: FriendBase + (*FriendListReq)(nil), // 1: FriendListReq + (*FriendListResp)(nil), // 2: FriendListResp + (*FriendRandlistReq)(nil), // 3: FriendRandlistReq + (*FriendRandlistResp)(nil), // 4: FriendRandlistResp + (*FriendApplyReq)(nil), // 5: FriendApplyReq + (*FriendApplyResp)(nil), // 6: FriendApplyResp + (*FriendDelReq)(nil), // 7: FriendDelReq + (*FriendDelResp)(nil), // 8: FriendDelResp + (*FriendAgreeReq)(nil), // 9: FriendAgreeReq + (*FriendAgreeResp)(nil), // 10: FriendAgreeResp + (*FriendRefuseReq)(nil), // 11: FriendRefuseReq + (*FriendRefuseResp)(nil), // 12: FriendRefuseResp + (*FriendApplyListReq)(nil), // 13: FriendApplyListReq + (*FriendApplyListResp)(nil), // 14: FriendApplyListResp + (*FriendSearchReq)(nil), // 15: FriendSearchReq + (*FriendSearchResp)(nil), // 16: FriendSearchResp + (*FriendBlackListReq)(nil), // 17: FriendBlackListReq + (*FriendBlackListResp)(nil), // 18: FriendBlackListResp + (*FriendAddBlackReq)(nil), // 19: FriendAddBlackReq + (*FriendAddBlackResp)(nil), // 20: FriendAddBlackResp + (*FriendDelBlackReq)(nil), // 21: FriendDelBlackReq + (*FriendDelBlackResp)(nil), // 22: FriendDelBlackResp + (*FriendTotalReq)(nil), // 23: FriendTotalReq + (*FriendTotalResp)(nil), // 24: FriendTotalResp + (*FriendZanlistReq)(nil), // 25: FriendZanlistReq + (*FriendZanlistResp)(nil), // 26: FriendZanlistResp + (*FriendZanReq)(nil), // 27: FriendZanReq + (*FriendZanResp)(nil), // 28: FriendZanResp + (*FriendZanreceiveReq)(nil), // 29: FriendZanreceiveReq + (*FriendZanreceiveResp)(nil), // 30: FriendZanreceiveResp + (*FriendAssistheroReq)(nil), // 31: FriendAssistheroReq + (*FriendAssistheroResp)(nil), // 32: FriendAssistheroResp + (*FriendAssistlistReq)(nil), // 33: FriendAssistlistReq + (*FriendAssistlistResp)(nil), // 34: FriendAssistlistResp + (*FriendGetrewardReq)(nil), // 35: FriendGetrewardReq + (*FriendGetrewardResp)(nil), // 36: FriendGetrewardResp + (*FriendAssistHeroListReq)(nil), // 37: FriendAssistHeroListReq + (*FriendAssistHeroListResp)(nil), // 38: FriendAssistHeroListResp + (*ZhuZhanRecord)(nil), // 39: ZhuZhanRecord } var file_friend_friend_msg_proto_depIdxs = []int32{ 0, // 0: FriendListResp.list:type_name -> FriendBase @@ -2070,12 +2164,13 @@ var file_friend_friend_msg_proto_depIdxs = []int32{ 0, // 4: FriendBlackListResp.friends:type_name -> FriendBase 0, // 5: FriendZanlistResp.list:type_name -> FriendBase 0, // 6: FriendAssistlistResp.list:type_name -> FriendBase - 37, // 7: FriendAssistlistResp.record:type_name -> ZhuZhanRecord - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 39, // 7: FriendAssistlistResp.record:type_name -> ZhuZhanRecord + 0, // 8: FriendAssistHeroListResp.friends:type_name -> FriendBase + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_friend_friend_msg_proto_init() } @@ -2529,6 +2624,30 @@ func file_friend_friend_msg_proto_init() { return nil } } + file_friend_friend_msg_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAssistHeroListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_friend_msg_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAssistHeroListResp); 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{ @@ -2536,7 +2655,7 @@ func file_friend_friend_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_friend_friend_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 37, + NumMessages: 39, NumExtensions: 0, NumServices: 0, },