From 595d83581f1fc35c5e38342e5a608c03166b4645 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 20 Jul 2022 21:22:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=8F=98=E6=9B=B4=E6=B6=88=E6=81=AF=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_drawCard.go | 46 ++++++------- modules/hero/model_hero.go | 14 ++-- modules/hero/module.go | 11 ++- pb/hero_msg.pb.go | 129 ++++++++++++++++++++++++++--------- pb/proto/hero/hero_msg.proto | 5 ++ 5 files changed, 143 insertions(+), 62 deletions(-) diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index bf0e86e65..537cb72df 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -35,8 +35,8 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq ) szCards = make([]int32, 0) rsp := &pb.HeroDrawCardResp{} - curStar4Count = this.GetFloorStarData(req.DrawType, session.GetUserId(), 4) - curStar5Count = this.GetFloorStarData(req.DrawType, session.GetUserId(), 5) + //curStar4Count = this.GetFloorStarData(req.DrawType, session.GetUserId(), 4) + //curStar5Count = this.GetFloorStarData(req.DrawType, session.GetUserId(), 5) this.module.Debugf("当前4星抽卡没中次数:%d, 当前5星抽卡没中次数:%d", curStar4Count, curStar5Count) // 抽卡相关 @@ -83,12 +83,12 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq continue } if _getCardCfg.Star == 4 { // 当抽取到的英雄是4星的时候 清除 该类型的保底次数 - this.SetFloorStarData(req.DrawType, session.GetUserId(), 4) + //SetFloorStarData(req.DrawType, session.GetUserId(), 4) hitStar4 = 0 hitStar = 4 break } else if _getCardCfg.Star == 5 { // 当抽取到的英雄是5星的时候 清除 该类型的保底次数 - this.SetFloorStarData(req.DrawType, session.GetUserId(), 5) + //SetFloorStarData(req.DrawType, session.GetUserId(), 5) hitStar5 = 0 // 清0 hitStar = 5 break @@ -108,15 +108,15 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq } if hitStar != 0 { hitStar = 0 - this.ModifyFloorStarData(req.DrawType, session.GetUserId(), hitStar) // 重置该星级保底 + //ModifyFloorStarData(req.DrawType, session.GetUserId(), hitStar) // 重置该星级保底 } } if hitStar4 != 0 { - this.AddFloorStarData(req.DrawType, session.GetUserId(), 4, hitStar4) // 增加4星保底次数 + //AddFloorStarData(req.DrawType, session.GetUserId(), 4, hitStar4) // 增加4星保底次数 } if hitStar5 != 0 { - this.AddFloorStarData(req.DrawType, session.GetUserId(), 5, hitStar5) // 增加5星保底次数 + //AddFloorStarData(req.DrawType, session.GetUserId(), 5, hitStar5) // 增加5星保底次数 } //计算保底 @@ -130,24 +130,24 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq return } -// 获取当前卡牌类型保底次数 -func (this *apiComp) GetFloorStarData(drawType int32, uid string, star int32) (count int32) { - return -} +// // 获取当前卡牌类型保底次数 +// func GetFloorStarData(drawType int32, uid string, star int32) (count int32) { +// return +// } -// 清除保底信息(drawType 抽卡类型) -func (this *apiComp) SetFloorStarData(drawType int32, uid string, star int32) { - return -} +// // 清除保底信息(drawType 抽卡类型) +// func SetFloorStarData(drawType int32, uid string, star int32) { +// return +// } -// 当前没有抽中 增加保底次数 -func (this *apiComp) AddFloorStarData(drawType int32, uid string, star int32, count int32) { +// // 当前没有抽中 增加保底次数 +// func AddFloorStarData(drawType int32, uid string, star int32, count int32) { - return -} +// return +// } -// 当前有抽中 修改保底次数 -func (this *apiComp) ModifyFloorStarData(drawType int32, uid string, star int32) { +// // 当前有抽中 修改保底次数 +// func ModifyFloorStarData(drawType int32, uid string, star int32) { - return -} +// return +// } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index b54ecffeb..9a2d3d143 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -263,9 +263,9 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen } //设置装备 -func (this *ModelHero) setEquipment(hero *pb.DBHero) (err error) { +func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err error) { if len(hero.EquipID) == 0 { - return nil + return } update := make(map[string]interface{}) @@ -280,19 +280,21 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (err error) { } //创建新卡 - newHero, err := this.createOneHero(hero.Uid, hero.HeroID) + newHero, err = this.createOneHero(hero.Uid, hero.HeroID) if err != nil { this.moduleHero.Errorf("%v", err) - return err + return } newHero.EquipID = hero.EquipID hero = newHero - return this.modifyHeroData(newHero.Uid, newHero.Id, update) + this.modifyHeroData(newHero.Uid, newHero.Id, update) + return } else { update["equipID"] = hero.EquipID } - return this.modifyHeroData(hero.Uid, hero.Id, update) + this.modifyHeroData(hero.Uid, hero.Id, update) + return } //合并属性即属性值累加 diff --git a/modules/hero/module.go b/modules/hero/module.go index 64738ba1f..f400642ad 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -64,9 +64,17 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq return } - if err := this.modelHero.setEquipment(hero); err != nil { + if newHero, err := this.modelHero.setEquipment(hero); err != nil { code = pb.ErrorCode_HeroEquipUpdate return + } else { + list := make([]*pb.DBHero, 0) + if newHero != nil { + list = append(list, newHero) + } + + list = append(list, hero) + session.SendMsg("hero", "change", &pb.HeroChangePush{List: list}) } this.modelHero.setEquipProperty(hero, equip) @@ -75,6 +83,7 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq code = pb.ErrorCode_Unknown this.Errorf("PushHeroProperty err!") } + return } diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index 7de64ecf5..8475f2462 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -1632,6 +1632,54 @@ func (x *HeroDrawCardResp) GetHeroes() []int32 { return nil } +// 英雄变化推送 +type HeroChangePush struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []*DBHero `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` +} + +func (x *HeroChangePush) Reset() { + *x = HeroChangePush{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroChangePush) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroChangePush) ProtoMessage() {} + +func (x *HeroChangePush) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[31] + 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 HeroChangePush.ProtoReflect.Descriptor instead. +func (*HeroChangePush) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{31} +} + +func (x *HeroChangePush) GetList() []*DBHero { + if x != nil { + return x.List + } + return nil +} + var File_hero_hero_msg_proto protoreflect.FileDescriptor var file_hero_hero_msg_proto_rawDesc = []byte{ @@ -1787,8 +1835,11 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x64, 0x72, 0x61, 0x77, 0x54, 0x79, 0x70, 0x65, 0x22, 0x2a, 0x0a, 0x10, 0x48, 0x65, 0x72, 0x6f, 0x44, 0x72, 0x61, 0x77, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x22, 0x2d, 0x0a, 0x0e, 0x48, 0x65, + 0x72, 0x6f, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1b, 0x0a, 0x04, + 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, + 0x65, 0x72, 0x6f, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1803,7 +1854,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte { return file_hero_hero_msg_proto_rawDescData } -var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 35) +var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 36) var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroInfoReq)(nil), // 0: HeroInfoReq (*HeroInfoResp)(nil), // 1: HeroInfoResp @@ -1836,38 +1887,40 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroDelHeroPush)(nil), // 28: HeroDelHeroPush (*HeroDrawCardReq)(nil), // 29: HeroDrawCardReq (*HeroDrawCardResp)(nil), // 30: HeroDrawCardResp - nil, // 31: HeroStrengthenUplvReq.ExpCardsEntry - nil, // 32: HeroPropertyPush.PropertyEntry - nil, // 33: HeroPropertyPush.AddPropertyEntry - nil, // 34: HeroDelHeroPush.HerosEntry - (*DBHero)(nil), // 35: DBHero + (*HeroChangePush)(nil), // 31: HeroChangePush + nil, // 32: HeroStrengthenUplvReq.ExpCardsEntry + nil, // 33: HeroPropertyPush.PropertyEntry + nil, // 34: HeroPropertyPush.AddPropertyEntry + nil, // 35: HeroDelHeroPush.HerosEntry + (*DBHero)(nil), // 36: DBHero } var file_hero_hero_msg_proto_depIdxs = []int32{ - 35, // 0: HeroInfoResp.base:type_name -> DBHero - 35, // 1: HeroListResp.list:type_name -> DBHero - 31, // 2: HeroStrengthenUplvReq.expCards:type_name -> HeroStrengthenUplvReq.ExpCardsEntry - 35, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero + 36, // 0: HeroInfoResp.base:type_name -> DBHero + 36, // 1: HeroListResp.list:type_name -> DBHero + 32, // 2: HeroStrengthenUplvReq.expCards:type_name -> HeroStrengthenUplvReq.ExpCardsEntry + 36, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero 7, // 4: HeroStrengthenUpStarReq.hero:type_name -> CostCardData 7, // 5: HeroStrengthenUpStarReq.heroRace:type_name -> CostCardData - 35, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero - 35, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero - 35, // 8: HeroResonanceResp.hero:type_name -> DBHero - 35, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero - 35, // 10: HeroResonanceResetResp.hero:type_name -> DBHero - 35, // 11: HeroResonanceUseEnergyResp.hero:type_name -> DBHero - 35, // 12: HeroAwakenResp.hero:type_name -> DBHero - 35, // 13: HeroChoukaResp.heroes:type_name -> DBHero - 32, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry - 33, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry - 35, // 16: HeroLockResp.hero:type_name -> DBHero - 35, // 17: HeroAddNewHeroPush.hero:type_name -> DBHero - 35, // 18: HeroGetSpecifiedResp.hero:type_name -> DBHero - 34, // 19: HeroDelHeroPush.heros:type_name -> HeroDelHeroPush.HerosEntry - 20, // [20:20] is the sub-list for method output_type - 20, // [20:20] is the sub-list for method input_type - 20, // [20:20] is the sub-list for extension type_name - 20, // [20:20] is the sub-list for extension extendee - 0, // [0:20] is the sub-list for field type_name + 36, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero + 36, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero + 36, // 8: HeroResonanceResp.hero:type_name -> DBHero + 36, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero + 36, // 10: HeroResonanceResetResp.hero:type_name -> DBHero + 36, // 11: HeroResonanceUseEnergyResp.hero:type_name -> DBHero + 36, // 12: HeroAwakenResp.hero:type_name -> DBHero + 36, // 13: HeroChoukaResp.heroes:type_name -> DBHero + 33, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry + 34, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry + 36, // 16: HeroLockResp.hero:type_name -> DBHero + 36, // 17: HeroAddNewHeroPush.hero:type_name -> DBHero + 36, // 18: HeroGetSpecifiedResp.hero:type_name -> DBHero + 35, // 19: HeroDelHeroPush.heros:type_name -> HeroDelHeroPush.HerosEntry + 36, // 20: HeroChangePush.list:type_name -> DBHero + 21, // [21:21] is the sub-list for method output_type + 21, // [21:21] is the sub-list for method input_type + 21, // [21:21] is the sub-list for extension type_name + 21, // [21:21] is the sub-list for extension extendee + 0, // [0:21] is the sub-list for field type_name } func init() { file_hero_hero_msg_proto_init() } @@ -2249,6 +2302,18 @@ func file_hero_hero_msg_proto_init() { return nil } } + file_hero_hero_msg_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroChangePush); 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{ @@ -2256,7 +2321,7 @@ func file_hero_hero_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 35, + NumMessages: 36, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/proto/hero/hero_msg.proto b/pb/proto/hero/hero_msg.proto index fd2c3c066..d67875f60 100644 --- a/pb/proto/hero/hero_msg.proto +++ b/pb/proto/hero/hero_msg.proto @@ -152,4 +152,9 @@ message HeroDrawCardReq { message HeroDrawCardResp { repeated int32 heroes = 1; // 返回英雄的configID +} + +// 英雄变化推送 +message HeroChangePush{ + repeated DBHero list = 1; } \ No newline at end of file