diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index 3be943c87..b06d3199a 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -72,6 +72,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c } _heroMap := map[string]interface{}{ "normalSkill": _hero.NormalSkill, + "isOverlying": false, } // 保存数据 err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) @@ -89,7 +90,8 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c this.module.modelHero.mergeMainProperty(session.GetUserId(), _hero.Id, property) _heroMap := map[string]interface{}{ - "juexingLv": _hero.JuexingLv + 1, + "juexingLv": _hero.JuexingLv + 1, + "isOverlying": false, } // 保存数据 err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index f144698e3..a6eddcc5c 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -101,6 +101,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR _heroMap := map[string]interface{}{ "resonateNum": _hero.ResonateNum + 1, "distributionResonate": _hero.DistributionResonate + resonConfig.Energy, + "isOverlying": false, } err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { diff --git a/modules/hero/api_resonanceReset.go b/modules/hero/api_resonanceReset.go index 2dd4712f0..fcb26c1b9 100644 --- a/modules/hero/api_resonanceReset.go +++ b/modules/hero/api_resonanceReset.go @@ -71,6 +71,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson _heroMap := map[string]interface{}{ "DistributionResonate": _hero.ResonateNum * resonConfig.Energy, "Energy": _hero.Energy, + "isOverlying": false, } err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 diff --git a/modules/hero/api_resonanceSelect.go b/modules/hero/api_resonanceSelect.go index 93acfc744..78c2ef4a1 100644 --- a/modules/hero/api_resonanceSelect.go +++ b/modules/hero/api_resonanceSelect.go @@ -40,6 +40,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR _heroMap := map[string]interface{}{ "DistributionResonate": _hero.ResonateNum - req.UseEnergy, // 减没有分配的能量 "Energy": _hero.Energy, + "isOverlying": false, } err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 diff --git a/modules/hero/api_skillUp.go b/modules/hero/api_skillUp.go index 37fb690d4..41becac9b 100644 --- a/modules/hero/api_skillUp.go +++ b/modules/hero/api_skillUp.go @@ -116,6 +116,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt } _heroMap := map[string]interface{}{ "normalSkill": _hero.NormalSkill, + "isOverlying": false, } err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 if err1 != nil { diff --git a/modules/hero/api_specified.go b/modules/hero/api_specified.go new file mode 100644 index 000000000..6f89196f8 --- /dev/null +++ b/modules/hero/api_specified.go @@ -0,0 +1,47 @@ +package hero + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) GetSpecifiedCkeck(session comm.IUserSession, req *pb.HeroGetSpecifiedReq) (code pb.ErrorCode) { + if req.HeroCoinfigID == 0 { + code = pb.ErrorCode_ReqParameterError + return + } + + return +} + +/// 英雄锁定 +func (this *apiComp) GetSpecified(session comm.IUserSession, req *pb.HeroGetSpecifiedReq) (code pb.ErrorCode, data proto.Message) { + + code = this.GetSpecifiedCkeck(session, req) // check + if code != pb.ErrorCode_Success { + return + } + hero, err := this.module.modelHero.createOneHeroObj(session.GetUserId(), req.HeroCoinfigID, false) + if err != nil { + hero.Lv = req.Lv + hero.Star = req.Star + } + _heroMap := map[string]interface{}{ + "lv": hero.Lv, + "star": hero.Star, + "isOverlying": false, + } + // 保存数据 + err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), hero.Id, _heroMap) + if err1 != nil { + code = pb.ErrorCode_DBError + log.Errorf("GetSpecified failed:%v", err) + return + } + session.SendMsg(string(this.module.GetType()), "getspecified", &pb.HeroGetSpecifiedResp{Hero: hero}) + return +} diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 9327198e1..be2a36a21 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -104,6 +104,25 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32, bPush bool) (e return nil } +func (this *ModelHero) createOneHeroObj(uid string, heroCfgId int32, bPush bool) (hero *pb.DBHero, err error) { + hero = this.initHero(uid, heroCfgId) + if hero != nil { + if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil { + this.moduleHero.Errorf("%v", err) + return + } + } + // 创建英雄成功 向客户端推送数据 + if bPush { + if session, ok := this.moduleHero.GetUserSession(uid); ok { + session.SendMsg(string(this.moduleHero.GetType()), "addhero", &pb.AddNewHeroPush{Hero: hero}) + err = session.Push() + } + } + + return +} + //创建多个指定的英雄 heroCfgIds可填入多个英雄ID func (this *ModelHero) createMultiHero(uid string, bPush bool, heroCfgIds ...int32) error { heroes := this.moduleHero.modelHero.getHeroList(uid) @@ -161,6 +180,7 @@ func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err this.moduleHero.Errorf("%v", err) break } + this.moduleHero.Debugf("删除一张卡牌uid:%s,卡牌ID:%s", uid, heroId) } return } @@ -308,7 +328,8 @@ func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string func (this *ModelHero) HeroStarUp(session comm.IUserSession, hero *pb.DBHero) (code pb.ErrorCode) { _heroMap := map[string]interface{}{ - "star": hero.Star, + "star": hero.Star, + "isOverlying": false, } // 保存数据 err1 := this.modifyHeroData(session.GetUserId(), hero.Id, _heroMap) diff --git a/modules/hero/module.go b/modules/hero/module.go index 285edebe9..1335bd4b6 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -155,8 +155,9 @@ func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (code pb.Erro } update := map[string]interface{}{ - "lv": curLv, - "exp": curExp, + "lv": curLv, + "exp": curExp, + "isOverlying": false, } if err := this.modelHero.modifyHeroData(uid, heroId, update); err != nil { diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index 14a53512b..f43605359 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -1363,6 +1363,125 @@ func (x *AddNewHeroPush) GetHero() *DBHero { return nil } +// 测试用(获取指定星级等级的英雄) +type HeroGetSpecifiedReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HeroCoinfigID int32 `protobuf:"varint,1,opt,name=heroCoinfigID,proto3" json:"heroCoinfigID"` // 英雄配置ID + Amount int32 `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount"` // 数量 + Star int32 `protobuf:"varint,3,opt,name=star,proto3" json:"star"` // 星级 + Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv"` // 等级 +} + +func (x *HeroGetSpecifiedReq) Reset() { + *x = HeroGetSpecifiedReq{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroGetSpecifiedReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroGetSpecifiedReq) ProtoMessage() {} + +func (x *HeroGetSpecifiedReq) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[26] + 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 HeroGetSpecifiedReq.ProtoReflect.Descriptor instead. +func (*HeroGetSpecifiedReq) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{26} +} + +func (x *HeroGetSpecifiedReq) GetHeroCoinfigID() int32 { + if x != nil { + return x.HeroCoinfigID + } + return 0 +} + +func (x *HeroGetSpecifiedReq) GetAmount() int32 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *HeroGetSpecifiedReq) GetStar() int32 { + if x != nil { + return x.Star + } + return 0 +} + +func (x *HeroGetSpecifiedReq) GetLv() int32 { + if x != nil { + return x.Lv + } + return 0 +} + +type HeroGetSpecifiedResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Hero *DBHero `protobuf:"bytes,1,opt,name=hero,proto3" json:"hero"` // 英雄对象 +} + +func (x *HeroGetSpecifiedResp) Reset() { + *x = HeroGetSpecifiedResp{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroGetSpecifiedResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroGetSpecifiedResp) ProtoMessage() {} + +func (x *HeroGetSpecifiedResp) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[27] + 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 HeroGetSpecifiedResp.ProtoReflect.Descriptor instead. +func (*HeroGetSpecifiedResp) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{27} +} + +func (x *HeroGetSpecifiedResp) GetHero() *DBHero { + if x != nil { + return x.Hero + } + return nil +} + var File_hero_hero_msg_proto protoreflect.FileDescriptor var file_hero_hero_msg_proto_rawDesc = []byte{ @@ -1491,8 +1610,19 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x2d, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x4e, 0x65, 0x77, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, - 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, - 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x77, 0x0a, 0x13, 0x48, + 0x65, 0x72, 0x6f, 0x47, 0x65, 0x74, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x52, + 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x68, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x69, 0x6e, 0x66, 0x69, + 0x67, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x68, 0x65, 0x72, 0x6f, 0x43, + 0x6f, 0x69, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, + 0x73, 0x74, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x02, 0x6c, 0x76, 0x22, 0x33, 0x0a, 0x14, 0x48, 0x65, 0x72, 0x6f, 0x47, 0x65, 0x74, 0x53, + 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, + 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, + 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1507,7 +1637,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, 29) +var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 31) var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroInfoReq)(nil), // 0: HeroInfoReq (*HeroInfoResp)(nil), // 1: HeroInfoResp @@ -1535,35 +1665,38 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroLockReq)(nil), // 23: HeroLockReq (*HeroLockResp)(nil), // 24: HeroLockResp (*AddNewHeroPush)(nil), // 25: AddNewHeroPush - nil, // 26: HeroStrengthenUplvReq.ExpCardsEntry - nil, // 27: HeroProperty.PropertyEntry - nil, // 28: HeroProperty.AddPropertyEntry - (*DBHero)(nil), // 29: DBHero + (*HeroGetSpecifiedReq)(nil), // 26: HeroGetSpecifiedReq + (*HeroGetSpecifiedResp)(nil), // 27: HeroGetSpecifiedResp + nil, // 28: HeroStrengthenUplvReq.ExpCardsEntry + nil, // 29: HeroProperty.PropertyEntry + nil, // 30: HeroProperty.AddPropertyEntry + (*DBHero)(nil), // 31: DBHero } var file_hero_hero_msg_proto_depIdxs = []int32{ - 29, // 0: HeroInfoResp.base:type_name -> DBHero - 29, // 1: HeroListResp.list:type_name -> DBHero - 26, // 2: HeroStrengthenUplvReq.expCards:type_name -> HeroStrengthenUplvReq.ExpCardsEntry - 29, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero + 31, // 0: HeroInfoResp.base:type_name -> DBHero + 31, // 1: HeroListResp.list:type_name -> DBHero + 28, // 2: HeroStrengthenUplvReq.expCards:type_name -> HeroStrengthenUplvReq.ExpCardsEntry + 31, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero 7, // 4: HeroStrengthenUpStarReq.hero:type_name -> CostCardData 7, // 5: HeroStrengthenUpStarReq.heroRace:type_name -> CostCardData - 29, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero - 29, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero - 29, // 8: HeroResonanceResp.hero:type_name -> DBHero - 29, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero - 29, // 10: HeroResonanceResetResp.hero:type_name -> DBHero - 29, // 11: HeroResonanceUseEnergyResp.hero:type_name -> DBHero - 29, // 12: HeroAwakenResp.hero:type_name -> DBHero - 29, // 13: HeroChoukaResp.heroes:type_name -> DBHero - 27, // 14: HeroProperty.property:type_name -> HeroProperty.PropertyEntry - 28, // 15: HeroProperty.addProperty:type_name -> HeroProperty.AddPropertyEntry - 29, // 16: HeroLockResp.hero:type_name -> DBHero - 29, // 17: AddNewHeroPush.hero:type_name -> DBHero - 18, // [18:18] is the sub-list for method output_type - 18, // [18:18] is the sub-list for method input_type - 18, // [18:18] is the sub-list for extension type_name - 18, // [18:18] is the sub-list for extension extendee - 0, // [0:18] is the sub-list for field type_name + 31, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero + 31, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero + 31, // 8: HeroResonanceResp.hero:type_name -> DBHero + 31, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero + 31, // 10: HeroResonanceResetResp.hero:type_name -> DBHero + 31, // 11: HeroResonanceUseEnergyResp.hero:type_name -> DBHero + 31, // 12: HeroAwakenResp.hero:type_name -> DBHero + 31, // 13: HeroChoukaResp.heroes:type_name -> DBHero + 29, // 14: HeroProperty.property:type_name -> HeroProperty.PropertyEntry + 30, // 15: HeroProperty.addProperty:type_name -> HeroProperty.AddPropertyEntry + 31, // 16: HeroLockResp.hero:type_name -> DBHero + 31, // 17: AddNewHeroPush.hero:type_name -> DBHero + 31, // 18: HeroGetSpecifiedResp.hero:type_name -> DBHero + 19, // [19:19] is the sub-list for method output_type + 19, // [19:19] is the sub-list for method input_type + 19, // [19:19] is the sub-list for extension type_name + 19, // [19:19] is the sub-list for extension extendee + 0, // [0:19] is the sub-list for field type_name } func init() { file_hero_hero_msg_proto_init() } @@ -1885,6 +2018,30 @@ func file_hero_hero_msg_proto_init() { return nil } } + file_hero_hero_msg_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroGetSpecifiedReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hero_hero_msg_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroGetSpecifiedResp); 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{ @@ -1892,7 +2049,7 @@ func file_hero_hero_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 29, + NumMessages: 31, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/proto/hero/hero_msg.proto b/pb/proto/hero/hero_msg.proto index a8f9a9961..e98a25269 100644 --- a/pb/proto/hero/hero_msg.proto +++ b/pb/proto/hero/hero_msg.proto @@ -128,4 +128,16 @@ message HeroLockResp{ // 增加新英雄推送 message AddNewHeroPush{ DBHero hero = 1; // 英雄对象 +} + +// 测试用(获取指定星级等级的英雄) +message HeroGetSpecifiedReq{ + int32 heroCoinfigID = 1; // 英雄配置ID + int32 Amount = 2; // 数量 + int32 star = 3; // 星级 + int32 lv = 4; // 等级 +} + +message HeroGetSpecifiedResp{ + DBHero hero = 1; // 英雄对象 } \ No newline at end of file