属性推送

This commit is contained in:
zhaocy 2022-06-29 17:58:06 +08:00
parent 7378905273
commit a2b4c91aff
3 changed files with 142 additions and 22 deletions

View File

@ -218,3 +218,16 @@ func (this *ModelHero) PropertyCompute(uid, heroId string) map[int32]int32 {
comm.PropertyDef: int32(math.Floor(def)), comm.PropertyDef: int32(math.Floor(def)),
} }
} }
//推送用户指定英雄属性
func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string) (err error) {
m := this.PropertyCompute(session.GetUserId(), heroId)
update := map[string]interface{}{
"property": m,
}
if err = this.ChangeList(session.GetUserId(), heroId, update); err != nil {
return
}
return session.SendMsg("push", "property", &pb.HeroProperty{Property: m})
}

View File

@ -1170,6 +1170,70 @@ func (x *HeroChoukaResp) GetHeroes() []*DBHero {
return nil return nil
} }
//英雄属性推送
type HeroProperty struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
HeroId string `protobuf:"bytes,1,opt,name=heroId,proto3" json:"heroId"` //英雄唯一ID
Property map[int32]int32 `protobuf:"bytes,2,rep,name=property,proto3" json:"property" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //基础属性
AddProperty map[int32]int32 `protobuf:"bytes,3,rep,name=addProperty,proto3" json:"addProperty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //附加属性
}
func (x *HeroProperty) Reset() {
*x = HeroProperty{}
if protoimpl.UnsafeEnabled {
mi := &file_hero_hero_msg_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HeroProperty) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HeroProperty) ProtoMessage() {}
func (x *HeroProperty) ProtoReflect() protoreflect.Message {
mi := &file_hero_hero_msg_proto_msgTypes[22]
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 HeroProperty.ProtoReflect.Descriptor instead.
func (*HeroProperty) Descriptor() ([]byte, []int) {
return file_hero_hero_msg_proto_rawDescGZIP(), []int{22}
}
func (x *HeroProperty) GetHeroId() string {
if x != nil {
return x.HeroId
}
return ""
}
func (x *HeroProperty) GetProperty() map[int32]int32 {
if x != nil {
return x.Property
}
return nil
}
func (x *HeroProperty) GetAddProperty() map[int32]int32 {
if x != nil {
return x.AddProperty
}
return nil
}
var File_hero_hero_msg_proto protoreflect.FileDescriptor var File_hero_hero_msg_proto protoreflect.FileDescriptor
var file_hero_hero_msg_proto_rawDesc = []byte{ var file_hero_hero_msg_proto_rawDesc = []byte{
@ -1272,8 +1336,27 @@ var file_hero_hero_msg_proto_rawDesc = []byte{
0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x22, 0x34, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x22, 0x34, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68,
0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f,
0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42,
0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x22, 0xa4, 0x02, 0x0a,
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x16, 0x0a,
0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68,
0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74,
0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x65, 0x72,
0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72,
0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74,
0x79, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79,
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x65, 0x72, 0x6f,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70,
0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x64, 0x64, 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, 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, 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, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }
var ( var (
@ -1288,7 +1371,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte {
return file_hero_hero_msg_proto_rawDescData return file_hero_hero_msg_proto_rawDescData
} }
var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 22) var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 25)
var file_hero_hero_msg_proto_goTypes = []interface{}{ var file_hero_hero_msg_proto_goTypes = []interface{}{
(*HeroInfoReq)(nil), // 0: pb.HeroInfoReq (*HeroInfoReq)(nil), // 0: pb.HeroInfoReq
(*HeroInfoRsp)(nil), // 1: pb.HeroInfoRsp (*HeroInfoRsp)(nil), // 1: pb.HeroInfoRsp
@ -1312,28 +1395,33 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{
(*HeroJuexingResp)(nil), // 19: pb.HeroJuexingResp (*HeroJuexingResp)(nil), // 19: pb.HeroJuexingResp
(*HeroChoukaReq)(nil), // 20: pb.HeroChoukaReq (*HeroChoukaReq)(nil), // 20: pb.HeroChoukaReq
(*HeroChoukaResp)(nil), // 21: pb.HeroChoukaResp (*HeroChoukaResp)(nil), // 21: pb.HeroChoukaResp
(*DBHero)(nil), // 22: pb.DBHero (*HeroProperty)(nil), // 22: pb.HeroProperty
nil, // 23: pb.HeroProperty.PropertyEntry
nil, // 24: pb.HeroProperty.AddPropertyEntry
(*DBHero)(nil), // 25: pb.DBHero
} }
var file_hero_hero_msg_proto_depIdxs = []int32{ var file_hero_hero_msg_proto_depIdxs = []int32{
22, // 0: pb.HeroInfoRsp.base:type_name -> pb.DBHero 25, // 0: pb.HeroInfoRsp.base:type_name -> pb.DBHero
22, // 1: pb.HeroListRsp.list:type_name -> pb.DBHero 25, // 1: pb.HeroListRsp.list:type_name -> pb.DBHero
22, // 2: pb.HeroStrengthenUplvResp.hero:type_name -> pb.DBHero 25, // 2: pb.HeroStrengthenUplvResp.hero:type_name -> pb.DBHero
7, // 3: pb.HeroStrengthenUpStarReq.hero:type_name -> pb.CostCardData 7, // 3: pb.HeroStrengthenUpStarReq.hero:type_name -> pb.CostCardData
7, // 4: pb.HeroStrengthenUpStarReq.heroRace:type_name -> pb.CostCardData 7, // 4: pb.HeroStrengthenUpStarReq.heroRace:type_name -> pb.CostCardData
22, // 5: pb.HeroStrengthenUpStarResp.hero:type_name -> pb.DBHero 25, // 5: pb.HeroStrengthenUpStarResp.hero:type_name -> pb.DBHero
22, // 6: pb.HeroStrengthenUpSkillResp.hero:type_name -> pb.DBHero 25, // 6: pb.HeroStrengthenUpSkillResp.hero:type_name -> pb.DBHero
22, // 7: pb.HeroGongmingResp.hero:type_name -> pb.DBHero 25, // 7: pb.HeroGongmingResp.hero:type_name -> pb.DBHero
22, // 8: pb.HeroGongmingResp.upStarCard:type_name -> pb.DBHero 25, // 8: pb.HeroGongmingResp.upStarCard:type_name -> pb.DBHero
22, // 9: pb.HeroGongmingResetResp.hero:type_name -> pb.DBHero 25, // 9: pb.HeroGongmingResetResp.hero:type_name -> pb.DBHero
22, // 10: pb.HeroGongmingUseEnergyResp.hero:type_name -> pb.DBHero 25, // 10: pb.HeroGongmingUseEnergyResp.hero:type_name -> pb.DBHero
4, // 11: pb.HeroJuexingReq.costItmes:type_name -> pb.ItemData 4, // 11: pb.HeroJuexingReq.costItmes:type_name -> pb.ItemData
22, // 12: pb.HeroJuexingResp.hero:type_name -> pb.DBHero 25, // 12: pb.HeroJuexingResp.hero:type_name -> pb.DBHero
22, // 13: pb.HeroChoukaResp.heroes:type_name -> pb.DBHero 25, // 13: pb.HeroChoukaResp.heroes:type_name -> pb.DBHero
14, // [14:14] is the sub-list for method output_type 23, // 14: pb.HeroProperty.property:type_name -> pb.HeroProperty.PropertyEntry
14, // [14:14] is the sub-list for method input_type 24, // 15: pb.HeroProperty.addProperty:type_name -> pb.HeroProperty.AddPropertyEntry
14, // [14:14] is the sub-list for extension type_name 16, // [16:16] is the sub-list for method output_type
14, // [14:14] is the sub-list for extension extendee 16, // [16:16] is the sub-list for method input_type
0, // [0:14] is the sub-list for field type_name 16, // [16:16] is the sub-list for extension type_name
16, // [16:16] is the sub-list for extension extendee
0, // [0:16] is the sub-list for field type_name
} }
func init() { file_hero_hero_msg_proto_init() } func init() { file_hero_hero_msg_proto_init() }
@ -1607,6 +1695,18 @@ func file_hero_hero_msg_proto_init() {
return nil return nil
} }
} }
file_hero_hero_msg_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HeroProperty); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -1614,7 +1714,7 @@ func file_hero_hero_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_hero_hero_msg_proto_rawDesc, RawDescriptor: file_hero_hero_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 22, NumMessages: 25,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -111,3 +111,10 @@ message HeroJuexingResp {
message HeroChoukaReq {} message HeroChoukaReq {}
message HeroChoukaResp { repeated DBHero heroes = 1; } message HeroChoukaResp { repeated DBHero heroes = 1; }
//
message HeroProperty {
string heroId = 1; //ID
map<int32, int32> property = 2; //
map<int32, int32> addProperty = 3; //
}