From f631f2254f997d5a6b83f0db6080a06cdf26f07a Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Mon, 25 Apr 2022 15:11:14 +0800 Subject: [PATCH] feat: 增加背包系统,以及背包系统的通知。 --- cmd/gameserver/action/GmAction.go | 5 ++--- cmd/gameserver/service/agent.go | 1 + cmd/gameserver/service/gm.go | 4 ++-- common/components/icompontents.go | 2 ++ common/utils.go | 17 ++++++----------- models/role.go | 54 +++++++++++++++++++++++++++++++++--------------------- models/rolePlugin.go | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ models/role_test.go | 21 ++++++++++++++++++++- models/schema.go | 9 +++++++++ pb/game.pb.go | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- pb/models.pb.go | 49 +++++++++++++++++++++++++++++-------------------- pb/protocode.pb.go | 11 ++++++++--- protos | 2 +- 13 files changed, 308 insertions(+), 79 deletions(-) create mode 100644 models/rolePlugin.go diff --git a/cmd/gameserver/action/GmAction.go b/cmd/gameserver/action/GmAction.go index 6b4fbf4..c7e514d 100644 --- a/cmd/gameserver/action/GmAction.go +++ b/cmd/gameserver/action/GmAction.go @@ -1,7 +1,6 @@ package action import ( - "pro2d/common/components" "pro2d/common/logger" "pro2d/models" "strconv" @@ -10,9 +9,9 @@ import ( type GmAction struct { } -func (gm *GmAction) AddExp(conn components.IConnection, role *models.RoleModel, properties map[string]interface{}) int { +func (gm *GmAction) AddExp(role *models.RoleModel, properties map[string]interface{}) int { logger.Debug(properties) exp, _ := strconv.Atoi(properties["exp"].(string)) - role.IncrPropertyChan(conn, "exp", int64(exp)) + role.IncrPropertyChan("exp", int64(exp)) return 0 } diff --git a/cmd/gameserver/service/agent.go b/cmd/gameserver/service/agent.go index ac9eef0..c9a1860 100644 --- a/cmd/gameserver/service/agent.go +++ b/cmd/gameserver/service/agent.go @@ -37,6 +37,7 @@ func NewAgent(s components.IServer) *Agent { func (c *Agent) SetSchema(schema components.ISchema) { c.Role = schema.(*models.RoleModel) + c.Role.SetConn(c) c.Server.GetConnManage().AddRID(c.Role.Role.Id, c.IConnection.GetID()) } diff --git a/cmd/gameserver/service/gm.go b/cmd/gameserver/service/gm.go index 00c671a..e3519ec 100644 --- a/cmd/gameserver/service/gm.go +++ b/cmd/gameserver/service/gm.go @@ -66,8 +66,8 @@ func (s *GmServer) HandlerFuncObj(tvl, obj reflect.Value) gin.HandlerFunc { } //func start - v := tvl.Call([]reflect.Value{obj, reflect.ValueOf(conn), reflect.ValueOf(role), reflect.ValueOf(properties)}) - role.SaveRoleDataChan(conn, 0) + v := tvl.Call([]reflect.Value{obj, reflect.ValueOf(role), reflect.ValueOf(properties)}) + role.SaveRoleDataChan(0) if len(v) != 1 { c.JSON(http.StatusNotFound, gin.H{"code": -100, "message": "request param len is error"}) diff --git a/common/components/icompontents.go b/common/components/icompontents.go index afb1304..345997b 100644 --- a/common/components/icompontents.go +++ b/common/components/icompontents.go @@ -143,6 +143,8 @@ type ( GetSchema() interface{} GetSchemaName() string UpdateSchema(interface{}) + SetConn(conn IConnection) + GetConn() IConnection Load() error Create() error diff --git a/common/utils.go b/common/utils.go index 2c2d7bf..73cb614 100644 --- a/common/utils.go +++ b/common/utils.go @@ -1,6 +1,7 @@ package common import ( + "bytes" "crypto/md5" "encoding/hex" "math/rand" @@ -42,25 +43,19 @@ func RandomName(name [][]string) string { idx1 := rand.Intn(len(name[0])) idx2 := rand.Intn(len(name[1])) - var builder strings.Builder - builder.WriteString(name[0][idx1]) - builder.WriteString(name[1][idx2]) - return builder.String() + return name[0][idx1] + name[1][idx2] } //英文字符串,第一个字符大写 func FirstCharToUpper(key string) string { first := strings.ToUpper(key[0:1]) - str := strings.Builder{} - str.WriteString(first) - str.WriteString(key[1:]) - return str.String() + return first + key[1:] } func RandomCode() string { - str := strings.Builder{} - for i:=0; i<6; i++ { + var str bytes.Buffer + for i := 0; i < 6; i++ { str.WriteString(strconv.Itoa(rand.Intn(9))) } return str.String() -} \ No newline at end of file +} diff --git a/models/role.go b/models/role.go index 0a6c386..09512b8 100644 --- a/models/role.go +++ b/models/role.go @@ -11,18 +11,21 @@ import ( "sync/atomic" ) +type BackPackItems map[string]uint32 + type RoleModel struct { components.ISchema Role *pb.Role Heros SchemaMap Teams SchemaMap Prop *PropModel + Items BackPackItems //背包 lastSaveTs int64 } func RoleExistByUid(uid string) *RoleModel { - data := &pb.Role{Uid: uid, Incres: make(map[string]int64)} + data := &pb.Role{Uid: uid, Incres: make(map[string]uint32)} if err := mongoproxy.FindOne(mongoproxy.GetCollName(data), mongoproxy.GetBsonM("uid", uid), data); err != nil { logger.Error("Role not exist err: %v", err) @@ -35,6 +38,7 @@ func RoleExistByUid(uid string) *RoleModel { Heros: make(SchemaMap), Teams: make(SchemaMap), Prop: new(PropModel), + Items: make(BackPackItems), } r.Load() r.LoadAll() @@ -42,17 +46,19 @@ func RoleExistByUid(uid string) *RoleModel { } func NewRole(id string) *RoleModel { - data := &pb.Role{Id: id, Incres: make(map[string]int64)} + data := &pb.Role{Id: id, Incres: make(map[string]uint32)} m := &RoleModel{ ISchema: NewSchema(id, data), Role: data, Heros: make(SchemaMap), Teams: make(SchemaMap), + Prop: new(PropModel), + Items: make(BackPackItems), } return m } -func (m *RoleModel) IncreByKey(key string, detal int64) int64 { +func (m *RoleModel) IncreByKey(key string, detal uint32) uint32 { v, ok := m.Role.Incres[key] if !ok { v = detal @@ -64,10 +70,10 @@ func (m *RoleModel) IncreByKey(key string, detal int64) int64 { return v } -func (m *RoleModel) IncreHearByKey(detal int64) string { +func (m *RoleModel) IncreHearByKey(detal uint32) string { return fmt.Sprintf("%s%04d", m.Role.Id, m.IncreByKey("hero", detal)) } -func (m *RoleModel) IncreTeamByKey(detal int64) string { +func (m *RoleModel) IncreTeamByKey(detal uint32) string { return fmt.Sprintf("%s%02d", m.Role.Id, m.IncreByKey("team", detal)) } @@ -148,16 +154,22 @@ func (m *RoleModel) LoadTeams() { } } +//加载背包数据到内存 +func (m *RoleModel) LoadItems() { + m.Items = m.StringToItems(m.Role.Items) +} + func (m *RoleModel) LoadAll() { m.LoadHero() m.LoadTeams() + m.LoadItems() } -func (m *RoleModel) UpdateProperty(conn components.IConnection, key string, val interface{}, notify bool) { - m.UpdateProperties(conn, map[string]interface{}{key: val}, notify) +func (m *RoleModel) UpdateProperty(key string, val interface{}, notify bool) { + m.UpdateProperties(map[string]interface{}{key: val}, notify) } -func (m *RoleModel) UpdateProperties(conn components.IConnection, property map[string]interface{}, notify bool) { +func (m *RoleModel) UpdateProperties(property map[string]interface{}, notify bool) { if len(property) < 1 { return } @@ -177,8 +189,8 @@ func (m *RoleModel) UpdateProperties(conn components.IConnection, property map[s logger.Error("id %s, err:", m.Role.Id, err) return } else { - if conn != nil && notify { - conn.Send(0, uint32(pb.ProtoCode_UpdateRolePropertyRsp), rsp) + if m.GetConn() != nil && notify { + m.GetConn().Send(0, uint32(pb.ProtoCode_UpdateRolePropertyRsp), rsp) } } } @@ -254,9 +266,9 @@ func (m *RoleModel) SaveRoleData(now int64) { } } -func (m *RoleModel) IncrPropertyChan(conn components.IConnection, key string, val int64) { - if conn != nil { - conn.CustomChan() <- func() { +func (m *RoleModel) IncrPropertyChan(key string, val int64) { + if m.GetConn() != nil { + m.GetConn().CustomChan() <- func() { m.IncrProperty(key, val) } } else { @@ -265,19 +277,19 @@ func (m *RoleModel) IncrPropertyChan(conn components.IConnection, key string, va } -func (m *RoleModel) UpdatePropertyChan(conn components.IConnection, key string, val interface{}, notify bool) { - if conn != nil { - conn.CustomChan() <- func() { - m.UpdateProperties(conn, map[string]interface{}{key: val}, notify) +func (m *RoleModel) UpdatePropertyChan(key string, val interface{}, notify bool) { + if m.GetConn() != nil { + m.GetConn().CustomChan() <- func() { + m.UpdateProperties(map[string]interface{}{key: val}, notify) } } else { - m.UpdateProperties(conn, map[string]interface{}{key: val}, notify) + m.UpdateProperties(map[string]interface{}{key: val}, notify) } } -func (m *RoleModel) SaveRoleDataChan(conn components.IConnection, now int64) { - if conn != nil { - conn.CustomChan() <- func() { +func (m *RoleModel) SaveRoleDataChan(now int64) { + if m.GetConn() != nil { + m.GetConn().CustomChan() <- func() { m.SaveRoleData(now) } } else { diff --git a/models/rolePlugin.go b/models/rolePlugin.go new file mode 100644 index 0000000..6ed4c49 --- /dev/null +++ b/models/rolePlugin.go @@ -0,0 +1,114 @@ +package models + +import ( + "bytes" + "fmt" + "github.com/golang/protobuf/proto" + "pro2d/common/logger" + "pro2d/pb" + "strconv" + "strings" +) + +//背包系统 +func (m *RoleModel) GetItemCount(key string) uint32 { + c, ok := m.Items[key] + if !ok { + c = 0 + } + return c +} + +func (m *RoleModel) CostItem(key string, count int32) bool { + if uint32(count) > m.GetItemCount(key) { + return false + } + return m.AddItem(key, -count) +} + +func (m *RoleModel) CostItems(params BackPackItems) bool { + for k, v := range params { + if v > m.GetItemCount(k) { + return false + } + + m.AddItem(k, -int32(v)) + } + return true +} + +func (m *RoleModel) AddItem(key string, count int32) bool { + c := m.GetItemCount(key) + + num := int32(c) + count + if num > 0 { + m.Items[key] = uint32(num) + } else { + delete(m.Items, key) + } + m.SetProperty("items", m.ItemsToString(m.Items)) + + rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: fmt.Sprintf("%s=%d", key, num)}) + if err != nil { + logger.Error(err.Error()) + return true + } + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp) + return true +} + +func (m *RoleModel) AddItems(params BackPackItems) bool { + tmp := make(BackPackItems) + for k, v := range params { + c := m.GetItemCount(k) + + num := c + v + if num > 0 { + m.Items[k] = num + tmp[k] = num + } else { + delete(m.Items, k) + } + } + + m.SetProperty("items", m.ItemsToString(m.Items)) + + rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: m.ItemsToString(tmp)}) + if err != nil { + logger.Error(err.Error()) + return true + } + + if m.GetConn() != nil { + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp) + } + + return true +} + +func (m *RoleModel) ItemsToString(params BackPackItems) string { + var items bytes.Buffer + for k, v := range params { + items.WriteString(k) + items.WriteString("=") + items.WriteString(fmt.Sprintf("%d", v)) + items.WriteString(" ") + } + return items.String() +} + +func (m *RoleModel) StringToItems(items string) BackPackItems { + backPack := make(BackPackItems) + for _, v := range strings.Split(items, " ") { + ii := strings.Split(v, "=") + if len(ii) < 2 { + continue + } + n, err := strconv.ParseUint(ii[1], 10, 32) + if err != nil { + continue + } + backPack[ii[0]] = uint32(n) + } + return backPack +} diff --git a/models/role_test.go b/models/role_test.go index 6d7be12..e6965ca 100644 --- a/models/role_test.go +++ b/models/role_test.go @@ -6,6 +6,8 @@ import ( "pro2d/common/db/mongoproxy" "pro2d/common/logger" "pro2d/pb" + "strconv" + "strings" "testing" ) @@ -79,7 +81,7 @@ func TestRoleModel_ProtoReflect(t *testing.T) { // "Id": "1", // "Device": "12312312312", //} - sch.UpdateProperty(nil, "Device", "123123123", false) + sch.UpdateProperty("Device", "123123123", false) fmt.Println(sch.Role) } @@ -120,4 +122,21 @@ func TestRoleModel_IncreByKey(t *testing.T) { //sch.Update() fmt.Printf("%03d\n", 3) + + ites := strings.SplitN("1=1 2=2 3=3", " ", -1) + fmt.Println(ites) + + items := make(BackPackItems) + for _, v := range ites { + ii := strings.Split(v, "=") + if len(ii) < 2 { + continue + } + n, err := strconv.ParseUint(ii[1], 10, 32) + if err != nil { + continue + } + items[ii[0]] = uint32(n) + } + fmt.Println(items) } diff --git a/models/schema.go b/models/schema.go index 73f6902..df987df 100644 --- a/models/schema.go +++ b/models/schema.go @@ -20,6 +20,7 @@ func WithSchemaDB(idb components.IDB) SchemaOption { type SchemaMap map[string]components.ISchema type Schema struct { + conn components.IConnection db components.IDB reflectValue *reflect.Value reflectIndex map[string]int @@ -124,6 +125,14 @@ func (s *Schema) UpdateSchema(schema interface{}) { } } +func (s *Schema) SetConn(conn components.IConnection) { + s.conn = conn +} + +func (s *Schema) GetConn() components.IConnection { + return s.conn +} + func (s *Schema) Load() error { return s.db.Load() } diff --git a/pb/game.pb.go b/pb/game.pb.go index 1643cdd..1f766ba 100644 --- a/pb/game.pb.go +++ b/pb/game.pb.go @@ -393,6 +393,54 @@ func (x *ChangeTeamReq) GetTeam() []*Team { return nil } +//ResponseCmd RoleUpdateItemsRsp +type RoleUpdateItemsRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items string `protobuf:"bytes,1,opt,name=items,proto3" json:"items,omitempty"` +} + +func (x *RoleUpdateItemsRsp) Reset() { + *x = RoleUpdateItemsRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_game_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoleUpdateItemsRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleUpdateItemsRsp) ProtoMessage() {} + +func (x *RoleUpdateItemsRsp) ProtoReflect() protoreflect.Message { + mi := &file_game_proto_msgTypes[7] + 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 RoleUpdateItemsRsp.ProtoReflect.Descriptor instead. +func (*RoleUpdateItemsRsp) Descriptor() ([]byte, []int) { + return file_game_proto_rawDescGZIP(), []int{7} +} + +func (x *RoleUpdateItemsRsp) GetItems() string { + if x != nil { + return x.Items + } + return "" +} + var File_game_proto protoreflect.FileDescriptor var file_game_proto_rawDesc = []byte{ @@ -424,8 +472,11 @@ var file_game_proto_rawDesc = []byte{ 0x65, 0x22, 0x31, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x04, - 0x74, 0x65, 0x61, 0x6d, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x61, 0x6d, 0x22, 0x2a, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, + 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, + 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -440,7 +491,7 @@ func file_game_proto_rawDescGZIP() []byte { return file_game_proto_rawDescData } -var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_game_proto_goTypes = []interface{}{ (*HeartReq)(nil), // 0: game.HeartReq (*HeartRsp)(nil), // 1: game.HeartRsp @@ -449,21 +500,22 @@ var file_game_proto_goTypes = []interface{}{ (*RoleRsp)(nil), // 4: game.RoleRsp (*UpdateRolePropertyRsp)(nil), // 5: game.UpdateRolePropertyRsp (*ChangeTeamReq)(nil), // 6: game.ChangeTeamReq - (*Role)(nil), // 7: models.Role - (*Hero)(nil), // 8: models.Hero - (*Team)(nil), // 9: models.Team + (*RoleUpdateItemsRsp)(nil), // 7: game.RoleUpdateItemsRsp + (*Role)(nil), // 8: models.Role + (*Hero)(nil), // 9: models.Hero + (*Team)(nil), // 10: models.Team } var file_game_proto_depIdxs = []int32{ - 7, // 0: game.RoleRsp.role:type_name -> models.Role - 8, // 1: game.RoleRsp.hero:type_name -> models.Hero - 9, // 2: game.RoleRsp.team:type_name -> models.Team - 7, // 3: game.UpdateRolePropertyRsp.role:type_name -> models.Role - 9, // 4: game.ChangeTeamReq.team:type_name -> models.Team - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 8, // 0: game.RoleRsp.role:type_name -> models.Role + 9, // 1: game.RoleRsp.hero:type_name -> models.Hero + 10, // 2: game.RoleRsp.team:type_name -> models.Team + 8, // 3: game.UpdateRolePropertyRsp.role:type_name -> models.Role + 10, // 4: game.ChangeTeamReq.team:type_name -> models.Team + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_game_proto_init() } @@ -557,6 +609,18 @@ func file_game_proto_init() { return nil } } + file_game_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoleUpdateItemsRsp); 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{ @@ -564,7 +628,7 @@ func file_game_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_game_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/models.pb.go b/pb/models.pb.go index f75498c..d65da17 100644 --- a/pb/models.pb.go +++ b/pb/models.pb.go @@ -451,18 +451,19 @@ type Role struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty" index:"unique"` // @inject_tag: index:"unique" - Device string `protobuf:"bytes,3,opt,name=device,proto3" json:"device,omitempty"` - Nick string `protobuf:"bytes,4,opt,name=nick,proto3" json:"nick,omitempty"` - Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"` - Exp int64 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"` - Hp int64 `protobuf:"varint,7,opt,name=hp,proto3" json:"hp,omitempty"` - HpMax int64 `protobuf:"varint,8,opt,name=hp_max,json=hpMax,proto3" json:"hp_max,omitempty"` - BuyR string `protobuf:"bytes,11,opt,name=buy_r,json=buyR,proto3" json:"buy_r,omitempty"` - PayR string `protobuf:"bytes,12,opt,name=pay_r,json=payR,proto3" json:"pay_r,omitempty"` - Del bool `protobuf:"varint,13,opt,name=del,proto3" json:"del,omitempty"` - Incres map[string]int64 `protobuf:"bytes,14,rep,name=incres,proto3" json:"incres,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty" index:"unique"` // @inject_tag: index:"unique" + Device string `protobuf:"bytes,3,opt,name=device,proto3" json:"device,omitempty"` + Nick string `protobuf:"bytes,4,opt,name=nick,proto3" json:"nick,omitempty"` + Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"` + Exp int64 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"` + Hp int64 `protobuf:"varint,7,opt,name=hp,proto3" json:"hp,omitempty"` + HpMax int64 `protobuf:"varint,8,opt,name=hp_max,json=hpMax,proto3" json:"hp_max,omitempty"` + BuyR string `protobuf:"bytes,11,opt,name=buy_r,json=buyR,proto3" json:"buy_r,omitempty"` + PayR string `protobuf:"bytes,12,opt,name=pay_r,json=payR,proto3" json:"pay_r,omitempty"` + Del bool `protobuf:"varint,13,opt,name=del,proto3" json:"del,omitempty"` + Incres map[string]uint32 `protobuf:"bytes,14,rep,name=incres,proto3" json:"incres,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + Items string `protobuf:"bytes,15,opt,name=items,proto3" json:"items,omitempty"` } func (x *Role) Reset() { @@ -574,13 +575,20 @@ func (x *Role) GetDel() bool { return false } -func (x *Role) GetIncres() map[string]int64 { +func (x *Role) GetIncres() map[string]uint32 { if x != nil { return x.Incres } return nil } +func (x *Role) GetItems() string { + if x != nil { + return x.Items + } + return "" +} + var File_models_proto protoreflect.FileDescriptor var file_models_proto_rawDesc = []byte{ @@ -624,7 +632,7 @@ var file_models_proto_rawDesc = []byte{ 0x65, 0x72, 0x6f, 0x49, 0x64, 0x33, 0x22, 0x2f, 0x0a, 0x09, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xcc, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, + 0x28, 0x03, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xe2, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 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, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, @@ -641,12 +649,13 @@ var file_models_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x64, 0x65, 0x6c, 0x12, 0x30, 0x0a, 0x06, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x2e, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x06, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x49, - 0x6e, 0x63, 0x72, 0x65, 0x73, 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, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x72, 0x79, 0x52, 0x06, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x69, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, + 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x73, 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, + 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0a, 0x5a, 0x08, + 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/protocode.pb.go b/pb/protocode.pb.go index bcc8481..5018f15 100644 --- a/pb/protocode.pb.go +++ b/pb/protocode.pb.go @@ -32,6 +32,7 @@ const ( ProtoCode_RoleRsp ProtoCode = 6 ProtoCode_UpdateRolePropertyRsp ProtoCode = 7 ProtoCode_ChangeTeamReq ProtoCode = 8 + ProtoCode_RoleUpdateItemsRsp ProtoCode = 9 ) // Enum value maps for ProtoCode. @@ -46,6 +47,7 @@ var ( 6: "RoleRsp", 7: "UpdateRolePropertyRsp", 8: "ChangeTeamReq", + 9: "RoleUpdateItemsRsp", } ProtoCode_value = map[string]int32{ "UNKNOWN": 0, @@ -57,6 +59,7 @@ var ( "RoleRsp": 6, "UpdateRolePropertyRsp": 7, "ChangeTeamReq": 8, + "RoleUpdateItemsRsp": 9, } ) @@ -91,7 +94,7 @@ var File_protocode_proto protoreflect.FileDescriptor var file_protocode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0x9a, 0x01, 0x0a, + 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0xb2, 0x01, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x73, 0x70, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x65, @@ -101,8 +104,10 @@ var file_protocode_proto_rawDesc = []byte{ 0x0a, 0x07, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x06, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x52, 0x73, 0x70, 0x10, 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, - 0x54, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x10, 0x08, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, - 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x54, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x10, 0x08, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, + 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x10, + 0x09, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protos b/protos index a102181..4d33c2f 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit a102181c13a87f14aa06dad30dfa4836b26e9f0b +Subproject commit 4d33c2f17e7228c02ce1898e1166ce46939a79f7 -- libgit2 0.21.2