diff --git a/comm/const.go b/comm/const.go index c214f686a..d191deed3 100644 --- a/comm/const.go +++ b/comm/const.go @@ -181,3 +181,10 @@ const ( RaceHx int32 = 4 // 呼啸 RaceSy int32 = 5 // 闪耀 ) + +// 共鸣属性 +const ( + ResonanceHpPro = "hppro" + ResonanceAtkPro = "atkpro" + ResonanceDefPro = "defpro" +) diff --git a/modules/hero/api_resonanceSelect.go b/modules/hero/api_resonanceSelect.go index f86ec02a1..028e837ad 100644 --- a/modules/hero/api_resonanceSelect.go +++ b/modules/hero/api_resonanceSelect.go @@ -9,7 +9,7 @@ import ( //参数校验 func (this *apiComp) ResonanceUseEnergyCheck(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode) { - if len(req.HeroObjID) == 0 || req.UseEnergy <= 0 || req.UseType < 0 || req.UseType > 3 { + if len(req.HeroObjID) == 0 || req.UseEnergy <= 0 || (req.UseType != comm.ResonanceHpPro && req.UseType != comm.ResonanceAtkPro && req.UseType != comm.ResonanceDefPro) { code = pb.ErrorCode_ReqParameterError } diff --git a/modules/hero/hero_test.go b/modules/hero/hero_test.go index 8850efdf4..8ca0dc38a 100644 --- a/modules/hero/hero_test.go +++ b/modules/hero/hero_test.go @@ -56,12 +56,6 @@ func (this *TestService) InitSys() { } func TestMain(m *testing.M) { - sz := GetMap() - if len(sz) == 0 { - sz = make(map[int32]int32, 0) - } - - sz[2] = 2 hero := &pb.DBHero{} hero.Block = false hero.Lv = 12 @@ -90,8 +84,9 @@ func GetMap() map[int32]int32 { return nil } func CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) { - temp := *hero - newHero = &temp + newHero = new(pb.DBHero) + *newHero = *hero + newHero.Block = true newHero.Lv = 100 newHero.Id = primitive.NewObjectID().Hex() diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 94284f9c8..712570cd4 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -54,7 +54,7 @@ func (this *ModelHero) initHero(uid string, heroCfgId string) *pb.DBHero { EquipID: make([]string, 6), //初始装备 SameCount: 1, //默认叠加数量 AddProperty: make(map[string]int32), - Energy: make(map[int32]int32), + Energy: make(map[string]int32), Property: make(map[string]int32), } this.PropertyCompute(newHero) @@ -102,8 +102,8 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId string) (hero *pb.DBH // 克隆一个英雄 func (this *ModelHero) CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) { - temp := *hero - newHero = &temp + newHero = new(pb.DBHero) + *newHero = *hero newHero.Id = primitive.NewObjectID().Hex() this.AddList(newHero.Uid, newHero.Id, newHero) return @@ -274,11 +274,11 @@ func (this *ModelHero) setEnergyProperty(hero *pb.DBHero) { } EnergyProperty := make(map[string]int32) //副属性 for k, v := range hero.Energy { - if k == 1 { + if k == comm.ResonanceHpPro { EnergyProperty[comm.Hp] += int32(math.Floor((1.0 + float64(resonConfig.Hppro*v)/1000) * float64(hero.Property[comm.Hp]))) - } else if k == 2 { + } else if k == comm.ResonanceAtkPro { EnergyProperty[comm.Atk] += int32(math.Floor((1.0 + float64(resonConfig.Atkpro*v)/1000) * float64(hero.Property[comm.Atk]))) - } else if k == 3 { + } else if k == comm.ResonanceDefPro { EnergyProperty[comm.Def] += int32(math.Floor((1.0 + float64(resonConfig.Defpro*v)/1000) * float64(hero.Property[comm.Def]))) } } diff --git a/pb/hero_db.pb.go b/pb/hero_db.pb.go index 4e880bdd0..ae99436aa 100644 --- a/pb/hero_db.pb.go +++ b/pb/hero_db.pb.go @@ -98,12 +98,13 @@ type DBHero struct { EquipID []string `protobuf:"bytes,16,rep,name=equipID,proto3" json:"equipID" bson:"equipID"` //装备 objID ResonateNum int32 `protobuf:"varint,17,opt,name=resonateNum,proto3" json:"resonateNum" bson:"resonateNum"` //共鸣次数 DistributionResonate int32 `protobuf:"varint,18,opt,name=distributionResonate,proto3" json:"distributionResonate" bson:"distributionResonate"` //分配的共鸣能量 - Energy map[int32]int32 `protobuf:"bytes,19,rep,name=energy,proto3" json:"energy" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // @go_tags(`bson:"energy"`)能量分配到哪里[1,0] + Energy map[string]int32 `protobuf:"bytes,19,rep,name=energy,proto3" json:"energy" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // @go_tags(`bson:"energy"`)能量分配到哪里[hppro:0,atkpro:0,defpro:20] SameCount int32 `protobuf:"varint,20,opt,name=sameCount,proto3" json:"sameCount" bson:"sameCount"` // 卡片叠加数量 SuiteId int32 `protobuf:"varint,21,opt,name=suiteId,proto3" json:"suiteId" bson:"suiteId"` // 套装Id SuiteExtId int32 `protobuf:"varint,22,opt,name=suiteExtId,proto3" json:"suiteExtId"` // go_tags(`bson:"suiteExtId"`) 扩展套装Id IsOverlying bool `protobuf:"varint,23,opt,name=isOverlying,proto3" json:"isOverlying"` // go_tags(`bson:"isOverlying"`) 是否允许叠加 默认true EnergyProperty map[string]int32 `protobuf:"bytes,24,rep,name=energyProperty,proto3" json:"energyProperty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"energyProperty"` // + JuexProperty map[string]int32 `protobuf:"bytes,25,rep,name=JuexProperty,proto3" json:"JuexProperty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"energyProperty"` ////hp } func (x *DBHero) Reset() { @@ -264,7 +265,7 @@ func (x *DBHero) GetDistributionResonate() int32 { return 0 } -func (x *DBHero) GetEnergy() map[int32]int32 { +func (x *DBHero) GetEnergy() map[string]int32 { if x != nil { return x.Energy } @@ -306,6 +307,13 @@ func (x *DBHero) GetEnergyProperty() map[string]int32 { return nil } +func (x *DBHero) GetJuexProperty() map[string]int32 { + if x != nil { + return x.JuexProperty + } + return nil +} + type Floor struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -489,7 +497,7 @@ var file_hero_hero_db_proto_rawDesc = []byte{ 0x61, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x4c, 0x76, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x6b, - 0x69, 0x6c, 0x6c, 0x4c, 0x76, 0x22, 0x90, 0x08, 0x0a, 0x06, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, + 0x69, 0x6c, 0x6c, 0x4c, 0x76, 0x22, 0x90, 0x09, 0x0a, 0x06, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, @@ -538,19 +546,27 @@ var file_hero_hero_db_proto_rawDesc = []byte{ 0x67, 0x79, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x2e, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x65, - 0x6e, 0x65, 0x72, 0x67, 0x79, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x1a, 0x3b, 0x0a, - 0x0d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x64, - 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x39, 0x0a, 0x0b, 0x45, 0x6e, - 0x65, 0x72, 0x67, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x41, 0x0a, 0x13, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x50, + 0x6e, 0x65, 0x72, 0x67, 0x79, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x3d, 0x0a, + 0x0c, 0x4a, 0x75, 0x65, 0x78, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x19, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x2e, 0x4a, 0x75, 0x65, + 0x78, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, + 0x4a, 0x75, 0x65, 0x78, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x1a, 0x3b, 0x0a, 0x0d, + 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x64, 0x64, + 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x39, 0x0a, 0x0b, 0x45, 0x6e, 0x65, + 0x72, 0x67, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x41, 0x0a, 0x13, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x50, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3f, 0x0a, 0x11, 0x4a, 0x75, 0x65, 0x78, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, @@ -590,7 +606,7 @@ func file_hero_hero_db_proto_rawDescGZIP() []byte { return file_hero_hero_db_proto_rawDescData } -var file_hero_hero_db_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_hero_hero_db_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_hero_hero_db_proto_goTypes = []interface{}{ (*SkillData)(nil), // 0: SkillData (*DBHero)(nil), // 1: DBHero @@ -600,6 +616,7 @@ var file_hero_hero_db_proto_goTypes = []interface{}{ nil, // 5: DBHero.AddPropertyEntry nil, // 6: DBHero.EnergyEntry nil, // 7: DBHero.EnergyPropertyEntry + nil, // 8: DBHero.JuexPropertyEntry } var file_hero_hero_db_proto_depIdxs = []int32{ 0, // 0: DBHero.normalSkill:type_name -> SkillData @@ -607,16 +624,17 @@ var file_hero_hero_db_proto_depIdxs = []int32{ 5, // 2: DBHero.addProperty:type_name -> DBHero.AddPropertyEntry 6, // 3: DBHero.energy:type_name -> DBHero.EnergyEntry 7, // 4: DBHero.energyProperty:type_name -> DBHero.EnergyPropertyEntry - 2, // 5: DBHeroRecord.race0:type_name -> Floor - 2, // 6: DBHeroRecord.race1:type_name -> Floor - 2, // 7: DBHeroRecord.race2:type_name -> Floor - 2, // 8: DBHeroRecord.race3:type_name -> Floor - 2, // 9: DBHeroRecord.race4:type_name -> Floor - 10, // [10:10] is the sub-list for method output_type - 10, // [10:10] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 8, // 5: DBHero.JuexProperty:type_name -> DBHero.JuexPropertyEntry + 2, // 6: DBHeroRecord.race0:type_name -> Floor + 2, // 7: DBHeroRecord.race1:type_name -> Floor + 2, // 8: DBHeroRecord.race2:type_name -> Floor + 2, // 9: DBHeroRecord.race3:type_name -> Floor + 2, // 10: DBHeroRecord.race4:type_name -> Floor + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_hero_hero_db_proto_init() } @@ -680,7 +698,7 @@ func file_hero_hero_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_db_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index 258cb38f5..3ef12b4ae 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -916,7 +916,7 @@ type HeroResonanceUseEnergyReq struct { HeroObjID string `protobuf:"bytes,1,opt,name=heroObjID,proto3" json:"heroObjID"` // 英雄对象ID UseEnergy int32 `protobuf:"varint,2,opt,name=useEnergy,proto3" json:"useEnergy"` // 使用的能量点数 - UseType int32 `protobuf:"varint,3,opt,name=useType,proto3" json:"useType"` // 使用的类型 (攻击、血量、防御) + UseType string `protobuf:"bytes,3,opt,name=useType,proto3" json:"useType"` // 使用的类型 (攻击、血量、防御) } func (x *HeroResonanceUseEnergyReq) Reset() { @@ -965,11 +965,11 @@ func (x *HeroResonanceUseEnergyReq) GetUseEnergy() int32 { return 0 } -func (x *HeroResonanceUseEnergyReq) GetUseType() int32 { +func (x *HeroResonanceUseEnergyReq) GetUseType() string { if x != nil { return x.UseType } - return 0 + return "" } type HeroResonanceUseEnergyResp struct { @@ -1716,7 +1716,7 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x75, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x12, 0x18, 0x0a, - 0x07, 0x75, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, + 0x07, 0x75, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x39, 0x0a, 0x1a, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x55, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20,