From 024609c29b0ba295e7f191277e3af0a9bc3e1f49 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 21 Nov 2022 16:29:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8A=BD=E5=87=BA5=E6=98=9F=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E5=90=8EA=E6=AC=A1=E6=8A=BD=E5=A5=96=E5=86=85?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E5=86=8D=E6=8A=BD=E5=88=B05=E6=98=9F?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=EF=BC=88=E6=99=AE=E9=80=9A=E5=8D=A1=E6=B1=A0?= =?UTF-8?q?+=E9=98=B5=E8=90=A5=E5=8D=A1=E6=B1=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_drawCard.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index d91f3cca6..eed2c9110 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -108,6 +108,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq } } } else { // 所有阵营抽卡都走这里 + drawCount += req.DrawCount if req.DrawCount == 1 { switch req.DrawType { case 1: @@ -197,6 +198,12 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq if v, ok := _data[int32(star)]; ok { if int32(len(v)) > randomIndex { + if star == 5 { // 抽出5星英雄后A次抽奖内不会再抽到5星英雄(普通卡池+阵营卡池) + curDrawCount := drawCount - req.DrawCount + newID := this.module.ContinuousRestriction(session.GetUserId(), v[randomIndex].Id, curDrawCount+int32(index), strPool[index]) + szCards = append(szCards, newID) + continue + } szCards = append(szCards, v[randomIndex].Id) } } @@ -215,6 +222,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq return } for _, heroId := range szCards { + _mapAddHero[heroId]++ } code = this.module.CreateRepeatHeros(session, _mapAddHero, true) From fc006b444162f53e7505660096533a6e04ed7316 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 21 Nov 2022 16:29:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8A=BD=E5=87=BA5=E6=98=9F=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E5=90=8EA=E6=AC=A1=E6=8A=BD=E5=A5=96=E5=86=85?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E5=86=8D=E6=8A=BD=E5=88=B05=E6=98=9F?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=EF=BC=88=E6=99=AE=E9=80=9A=E5=8D=A1=E6=B1=A0?= =?UTF-8?q?+=E9=98=B5=E8=90=A5=E5=8D=A1=E6=B1=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gourmet/comp_configure.go | 3 +- modules/hero/module.go | 52 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/modules/gourmet/comp_configure.go b/modules/gourmet/comp_configure.go index a7b965fe8..56a4fd781 100644 --- a/modules/gourmet/comp_configure.go +++ b/modules/gourmet/comp_configure.go @@ -10,8 +10,7 @@ import ( ) const ( - game_gourmet = "game_gourmet.json" - game_gourmetskill = "game_gourmetskill.json" + game_gourmet = "game_gourmet.json" ) ///配置管理基础组件 diff --git a/modules/hero/module.go b/modules/hero/module.go index 28dbd336e..b11a28491 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -457,6 +457,58 @@ func (this *Hero) NoLoginDay(uid string, day int32) { } } +// 连续抽卡最多连续出A个相同阵营的英雄(普通卡池) +/* +heroCid 抽到的5星英雄ID +drawCount 当前抽卡次数 +poll 当前卡池 +返回值 newCid不满足抽卡要求替换其他5星英雄 +*/ +func (this *Hero) ContinuousRestriction(uid string, heroCid string, drawCount int32, pool string) (newCid string) { + var ( + update map[string]interface{} + ) + record, err := this.modelRecord.GetHeroRecord(uid) + if err != nil { + return heroCid + } + for heroid, index := range record.Star5Hero { + if heroid == heroCid { + conf := this.configure.GetGlobalConf() //. + iMaxCOunt := conf.DrawCardContinuousRestrictionStar5 + if drawCount-index <= iMaxCOunt { // 连续n次还获得该英雄 直接替换其他英雄 + + _data := this.configure.GetPollByType(pool) + if _data == nil { + + return heroCid + } + sz := make([]int32, 0) + for _, v := range _data[5] { + sz = append(sz, v.Weight) + } + //randomIndex := this.modelHero.GetRandW(sz) + for i := 0; i < len(_data[5]); i++ { + if v, ok := _data[5]; ok { + if int32(len(v)) > int32(i) { + newCid = v[i].Id + if newCid == heroid { + continue + } + record.Star5Hero[heroid] = drawCount + update["star5Hero"] = record.Star5Hero + this.modelRecord.ChangeHeroRecord(uid, update) // 更新信息 + return + } + } + } + + } + } + } + return heroCid +} + // 检查充值和未登录天数之内抽卡是否抽中 func (this *Hero) CheckCondition(uid string) bool { var ( From b01e92ca669a39087bb8aed93c35d16969812bfb Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 21 Nov 2022 16:39:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8E=E5=A5=BD=E5=8F=8B=E7=9A=84=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/friend/api.go | 1 + modules/friend/api_cross_getrelation.go | 58 +++++++++ modules/friend/api_cross_list.go | 5 + pb/friend_msg.pb.go | 149 +++++++++++++++++++++++- 4 files changed, 207 insertions(+), 6 deletions(-) create mode 100644 modules/friend/api_cross_getrelation.go diff --git a/modules/friend/api.go b/modules/friend/api.go index c144c9f53..cb03888ea 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -26,6 +26,7 @@ const ( FriendSubTypeAssistlist = "assistlist" FriendSubTypeGetreward = "getreward" FriendSubTypeAssistHeroList = "assistherolist" + FriendSubTypeRelation = "getrelation" ) type apiComp struct { diff --git a/modules/friend/api_cross_getrelation.go b/modules/friend/api_cross_getrelation.go new file mode 100644 index 000000000..d37923f6e --- /dev/null +++ b/modules/friend/api_cross_getrelation.go @@ -0,0 +1,58 @@ +package friend + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/pb" + "go_dreamfactory/utils" + + "google.golang.org/protobuf/proto" +) + +// 获取好友关系 +func (this *apiComp) GetRelationCheck(session comm.IUserSession, req *pb.FriendGetRelationReq) (code pb.ErrorCode) { + if req.TargetUid == "" { + code = pb.ErrorCode_ReqParameterError + this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req}) + } + return +} + +func (this *apiComp) GetRelation(session comm.IUserSession, req *pb.FriendGetRelationReq) (code pb.ErrorCode, data proto.Message) { + if code = this.GetRelationCheck(session, req); code != pb.ErrorCode_Success { + return + } + + self := this.moduleFriend.modelFriend.GetFriend(session.GetUserId()) + if self == nil { + code = pb.ErrorCode_FriendSelfNoData + return + } + + target := this.moduleFriend.modelFriend.GetFriend(req.TargetUid) + if target == nil { + code = pb.ErrorCode_FriendTargetNoData + return + } + var status bool + + // 已申请目标玩家 + if _, ok := utils.Findx(target.ApplyIds, self.Uid); ok { + status = true + } + + //目标玩家已是好友 + if _, ok := utils.Findx(self.FriendIds, req.TargetUid); ok { + status = true + } + + resp := &pb.FriendGetRelationResp{ + TargetUid: req.TargetUid, + Status: status, + } + if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeRelation, resp); err != nil { + code = pb.ErrorCode_SystemError + return + } + return +} diff --git a/modules/friend/api_cross_list.go b/modules/friend/api_cross_list.go index f829f5007..98cff5bd8 100644 --- a/modules/friend/api_cross_list.go +++ b/modules/friend/api_cross_list.go @@ -45,6 +45,11 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (cod if target == nil { continue } + // 申请过的在线好友,设置申请状态 + if _, ok := utils.Findx(target.ApplyIds, self.Uid); ok { + base.IsApplied = true + } + if _, ok := utils.Findx(target.ZanIds, self.Uid); ok { base.IsZaned = true } diff --git a/pb/friend_msg.pb.go b/pb/friend_msg.pb.go index d242e8104..ff1a9722a 100644 --- a/pb/friend_msg.pb.go +++ b/pb/friend_msg.pb.go @@ -2008,6 +2008,109 @@ func (x *FriendAssistHeroListResp) GetFriends() []*FriendBase { return nil } +// 查询是否已申请目标玩家为好友或目标玩家是否已是好友 +type FriendGetRelationReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TargetUid string `protobuf:"bytes,1,opt,name=targetUid,proto3" json:"targetUid"` //目标玩家ID +} + +func (x *FriendGetRelationReq) Reset() { + *x = FriendGetRelationReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_friend_msg_proto_msgTypes[40] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendGetRelationReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendGetRelationReq) ProtoMessage() {} + +func (x *FriendGetRelationReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_friend_msg_proto_msgTypes[40] + 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 FriendGetRelationReq.ProtoReflect.Descriptor instead. +func (*FriendGetRelationReq) Descriptor() ([]byte, []int) { + return file_friend_friend_msg_proto_rawDescGZIP(), []int{40} +} + +func (x *FriendGetRelationReq) GetTargetUid() string { + if x != nil { + return x.TargetUid + } + return "" +} + +type FriendGetRelationResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TargetUid string `protobuf:"bytes,1,opt,name=targetUid,proto3" json:"targetUid"` + Status bool `protobuf:"varint,2,opt,name=status,proto3" json:"status"` //已是好友或已申请返回true +} + +func (x *FriendGetRelationResp) Reset() { + *x = FriendGetRelationResp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_friend_msg_proto_msgTypes[41] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendGetRelationResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendGetRelationResp) ProtoMessage() {} + +func (x *FriendGetRelationResp) ProtoReflect() protoreflect.Message { + mi := &file_friend_friend_msg_proto_msgTypes[41] + 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 FriendGetRelationResp.ProtoReflect.Descriptor instead. +func (*FriendGetRelationResp) Descriptor() ([]byte, []int) { + return file_friend_friend_msg_proto_rawDescGZIP(), []int{41} +} + +func (x *FriendGetRelationResp) GetTargetUid() string { + if x != nil { + return x.TargetUid + } + return "" +} + +func (x *FriendGetRelationResp) GetStatus() bool { + if x != nil { + return x.Status + } + return false +} + var File_friend_friend_msg_proto protoreflect.FileDescriptor var file_friend_friend_msg_proto_rawDesc = []byte{ @@ -2159,8 +2262,16 @@ var file_friend_friend_msg_proto_rawDesc = []byte{ 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, + 0x6e, 0x64, 0x73, 0x22, 0x34, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, + 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64, 0x22, 0x4d, 0x0a, 0x15, 0x46, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2175,7 +2286,7 @@ 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, 40) +var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 42) var file_friend_friend_msg_proto_goTypes = []interface{}{ (*FriendBase)(nil), // 0: FriendBase (*FriendListReq)(nil), // 1: FriendListReq @@ -2217,7 +2328,9 @@ var file_friend_friend_msg_proto_goTypes = []interface{}{ (*FriendAssistHeroUpdatePush)(nil), // 37: FriendAssistHeroUpdatePush (*FriendAssistHeroListReq)(nil), // 38: FriendAssistHeroListReq (*FriendAssistHeroListResp)(nil), // 39: FriendAssistHeroListResp - (*AssistRecord)(nil), // 40: AssistRecord + (*FriendGetRelationReq)(nil), // 40: FriendGetRelationReq + (*FriendGetRelationResp)(nil), // 41: FriendGetRelationResp + (*AssistRecord)(nil), // 42: AssistRecord } var file_friend_friend_msg_proto_depIdxs = []int32{ 0, // 0: FriendListResp.list:type_name -> FriendBase @@ -2227,7 +2340,7 @@ 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 - 40, // 7: FriendAssistlistResp.record:type_name -> AssistRecord + 42, // 7: FriendAssistlistResp.record:type_name -> AssistRecord 0, // 8: FriendAssistHeroUpdatePush.friend:type_name -> FriendBase 0, // 9: FriendAssistHeroListResp.friends:type_name -> FriendBase 10, // [10:10] is the sub-list for method output_type @@ -2724,6 +2837,30 @@ func file_friend_friend_msg_proto_init() { return nil } } + file_friend_friend_msg_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendGetRelationReq); 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[41].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendGetRelationResp); 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{ @@ -2731,7 +2868,7 @@ func file_friend_friend_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_friend_friend_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 40, + NumMessages: 42, NumExtensions: 0, NumServices: 0, },