Commit f631f2254f997d5a6b83f0db6080a06cdf26f07a
1 parent
6bc4386a
feat: 增加背包系统,以及背包系统的通知。
Showing
13 changed files
with
308 additions
and
79 deletions
Show diff stats
cmd/gameserver/action/GmAction.go
1 | 1 | package action |
2 | 2 | |
3 | 3 | import ( |
4 | - "pro2d/common/components" | |
5 | 4 | "pro2d/common/logger" |
6 | 5 | "pro2d/models" |
7 | 6 | "strconv" |
... | ... | @@ -10,9 +9,9 @@ import ( |
10 | 9 | type GmAction struct { |
11 | 10 | } |
12 | 11 | |
13 | -func (gm *GmAction) AddExp(conn components.IConnection, role *models.RoleModel, properties map[string]interface{}) int { | |
12 | +func (gm *GmAction) AddExp(role *models.RoleModel, properties map[string]interface{}) int { | |
14 | 13 | logger.Debug(properties) |
15 | 14 | exp, _ := strconv.Atoi(properties["exp"].(string)) |
16 | - role.IncrPropertyChan(conn, "exp", int64(exp)) | |
15 | + role.IncrPropertyChan("exp", int64(exp)) | |
17 | 16 | return 0 |
18 | 17 | } | ... | ... |
cmd/gameserver/service/agent.go
... | ... | @@ -37,6 +37,7 @@ func NewAgent(s components.IServer) *Agent { |
37 | 37 | |
38 | 38 | func (c *Agent) SetSchema(schema components.ISchema) { |
39 | 39 | c.Role = schema.(*models.RoleModel) |
40 | + c.Role.SetConn(c) | |
40 | 41 | |
41 | 42 | c.Server.GetConnManage().AddRID(c.Role.Role.Id, c.IConnection.GetID()) |
42 | 43 | } | ... | ... |
cmd/gameserver/service/gm.go
... | ... | @@ -66,8 +66,8 @@ func (s *GmServer) HandlerFuncObj(tvl, obj reflect.Value) gin.HandlerFunc { |
66 | 66 | } |
67 | 67 | |
68 | 68 | //func start |
69 | - v := tvl.Call([]reflect.Value{obj, reflect.ValueOf(conn), reflect.ValueOf(role), reflect.ValueOf(properties)}) | |
70 | - role.SaveRoleDataChan(conn, 0) | |
69 | + v := tvl.Call([]reflect.Value{obj, reflect.ValueOf(role), reflect.ValueOf(properties)}) | |
70 | + role.SaveRoleDataChan(0) | |
71 | 71 | |
72 | 72 | if len(v) != 1 { |
73 | 73 | c.JSON(http.StatusNotFound, gin.H{"code": -100, "message": "request param len is error"}) | ... | ... |
common/components/icompontents.go
common/utils.go
1 | 1 | package common |
2 | 2 | |
3 | 3 | import ( |
4 | + "bytes" | |
4 | 5 | "crypto/md5" |
5 | 6 | "encoding/hex" |
6 | 7 | "math/rand" |
... | ... | @@ -42,25 +43,19 @@ func RandomName(name [][]string) string { |
42 | 43 | idx1 := rand.Intn(len(name[0])) |
43 | 44 | idx2 := rand.Intn(len(name[1])) |
44 | 45 | |
45 | - var builder strings.Builder | |
46 | - builder.WriteString(name[0][idx1]) | |
47 | - builder.WriteString(name[1][idx2]) | |
48 | - return builder.String() | |
46 | + return name[0][idx1] + name[1][idx2] | |
49 | 47 | } |
50 | 48 | |
51 | 49 | //英文字符串,第一个字符大写 |
52 | 50 | func FirstCharToUpper(key string) string { |
53 | 51 | first := strings.ToUpper(key[0:1]) |
54 | - str := strings.Builder{} | |
55 | - str.WriteString(first) | |
56 | - str.WriteString(key[1:]) | |
57 | - return str.String() | |
52 | + return first + key[1:] | |
58 | 53 | } |
59 | 54 | |
60 | 55 | func RandomCode() string { |
61 | - str := strings.Builder{} | |
62 | - for i:=0; i<6; i++ { | |
56 | + var str bytes.Buffer | |
57 | + for i := 0; i < 6; i++ { | |
63 | 58 | str.WriteString(strconv.Itoa(rand.Intn(9))) |
64 | 59 | } |
65 | 60 | return str.String() |
66 | -} | |
67 | 61 | \ No newline at end of file |
62 | +} | ... | ... |
models/role.go
... | ... | @@ -11,18 +11,21 @@ import ( |
11 | 11 | "sync/atomic" |
12 | 12 | ) |
13 | 13 | |
14 | +type BackPackItems map[string]uint32 | |
15 | + | |
14 | 16 | type RoleModel struct { |
15 | 17 | components.ISchema |
16 | 18 | Role *pb.Role |
17 | 19 | Heros SchemaMap |
18 | 20 | Teams SchemaMap |
19 | 21 | Prop *PropModel |
22 | + Items BackPackItems //背包 | |
20 | 23 | |
21 | 24 | lastSaveTs int64 |
22 | 25 | } |
23 | 26 | |
24 | 27 | func RoleExistByUid(uid string) *RoleModel { |
25 | - data := &pb.Role{Uid: uid, Incres: make(map[string]int64)} | |
28 | + data := &pb.Role{Uid: uid, Incres: make(map[string]uint32)} | |
26 | 29 | |
27 | 30 | if err := mongoproxy.FindOne(mongoproxy.GetCollName(data), mongoproxy.GetBsonM("uid", uid), data); err != nil { |
28 | 31 | logger.Error("Role not exist err: %v", err) |
... | ... | @@ -35,6 +38,7 @@ func RoleExistByUid(uid string) *RoleModel { |
35 | 38 | Heros: make(SchemaMap), |
36 | 39 | Teams: make(SchemaMap), |
37 | 40 | Prop: new(PropModel), |
41 | + Items: make(BackPackItems), | |
38 | 42 | } |
39 | 43 | r.Load() |
40 | 44 | r.LoadAll() |
... | ... | @@ -42,17 +46,19 @@ func RoleExistByUid(uid string) *RoleModel { |
42 | 46 | } |
43 | 47 | |
44 | 48 | func NewRole(id string) *RoleModel { |
45 | - data := &pb.Role{Id: id, Incres: make(map[string]int64)} | |
49 | + data := &pb.Role{Id: id, Incres: make(map[string]uint32)} | |
46 | 50 | m := &RoleModel{ |
47 | 51 | ISchema: NewSchema(id, data), |
48 | 52 | Role: data, |
49 | 53 | Heros: make(SchemaMap), |
50 | 54 | Teams: make(SchemaMap), |
55 | + Prop: new(PropModel), | |
56 | + Items: make(BackPackItems), | |
51 | 57 | } |
52 | 58 | return m |
53 | 59 | } |
54 | 60 | |
55 | -func (m *RoleModel) IncreByKey(key string, detal int64) int64 { | |
61 | +func (m *RoleModel) IncreByKey(key string, detal uint32) uint32 { | |
56 | 62 | v, ok := m.Role.Incres[key] |
57 | 63 | if !ok { |
58 | 64 | v = detal |
... | ... | @@ -64,10 +70,10 @@ func (m *RoleModel) IncreByKey(key string, detal int64) int64 { |
64 | 70 | return v |
65 | 71 | } |
66 | 72 | |
67 | -func (m *RoleModel) IncreHearByKey(detal int64) string { | |
73 | +func (m *RoleModel) IncreHearByKey(detal uint32) string { | |
68 | 74 | return fmt.Sprintf("%s%04d", m.Role.Id, m.IncreByKey("hero", detal)) |
69 | 75 | } |
70 | -func (m *RoleModel) IncreTeamByKey(detal int64) string { | |
76 | +func (m *RoleModel) IncreTeamByKey(detal uint32) string { | |
71 | 77 | return fmt.Sprintf("%s%02d", m.Role.Id, m.IncreByKey("team", detal)) |
72 | 78 | } |
73 | 79 | |
... | ... | @@ -148,16 +154,22 @@ func (m *RoleModel) LoadTeams() { |
148 | 154 | } |
149 | 155 | } |
150 | 156 | |
157 | +//加载背包数据到内存 | |
158 | +func (m *RoleModel) LoadItems() { | |
159 | + m.Items = m.StringToItems(m.Role.Items) | |
160 | +} | |
161 | + | |
151 | 162 | func (m *RoleModel) LoadAll() { |
152 | 163 | m.LoadHero() |
153 | 164 | m.LoadTeams() |
165 | + m.LoadItems() | |
154 | 166 | } |
155 | 167 | |
156 | -func (m *RoleModel) UpdateProperty(conn components.IConnection, key string, val interface{}, notify bool) { | |
157 | - m.UpdateProperties(conn, map[string]interface{}{key: val}, notify) | |
168 | +func (m *RoleModel) UpdateProperty(key string, val interface{}, notify bool) { | |
169 | + m.UpdateProperties(map[string]interface{}{key: val}, notify) | |
158 | 170 | } |
159 | 171 | |
160 | -func (m *RoleModel) UpdateProperties(conn components.IConnection, property map[string]interface{}, notify bool) { | |
172 | +func (m *RoleModel) UpdateProperties(property map[string]interface{}, notify bool) { | |
161 | 173 | if len(property) < 1 { |
162 | 174 | return |
163 | 175 | } |
... | ... | @@ -177,8 +189,8 @@ func (m *RoleModel) UpdateProperties(conn components.IConnection, property map[s |
177 | 189 | logger.Error("id %s, err:", m.Role.Id, err) |
178 | 190 | return |
179 | 191 | } else { |
180 | - if conn != nil && notify { | |
181 | - conn.Send(0, uint32(pb.ProtoCode_UpdateRolePropertyRsp), rsp) | |
192 | + if m.GetConn() != nil && notify { | |
193 | + m.GetConn().Send(0, uint32(pb.ProtoCode_UpdateRolePropertyRsp), rsp) | |
182 | 194 | } |
183 | 195 | } |
184 | 196 | } |
... | ... | @@ -254,9 +266,9 @@ func (m *RoleModel) SaveRoleData(now int64) { |
254 | 266 | } |
255 | 267 | } |
256 | 268 | |
257 | -func (m *RoleModel) IncrPropertyChan(conn components.IConnection, key string, val int64) { | |
258 | - if conn != nil { | |
259 | - conn.CustomChan() <- func() { | |
269 | +func (m *RoleModel) IncrPropertyChan(key string, val int64) { | |
270 | + if m.GetConn() != nil { | |
271 | + m.GetConn().CustomChan() <- func() { | |
260 | 272 | m.IncrProperty(key, val) |
261 | 273 | } |
262 | 274 | } else { |
... | ... | @@ -265,19 +277,19 @@ func (m *RoleModel) IncrPropertyChan(conn components.IConnection, key string, va |
265 | 277 | |
266 | 278 | } |
267 | 279 | |
268 | -func (m *RoleModel) UpdatePropertyChan(conn components.IConnection, key string, val interface{}, notify bool) { | |
269 | - if conn != nil { | |
270 | - conn.CustomChan() <- func() { | |
271 | - m.UpdateProperties(conn, map[string]interface{}{key: val}, notify) | |
280 | +func (m *RoleModel) UpdatePropertyChan(key string, val interface{}, notify bool) { | |
281 | + if m.GetConn() != nil { | |
282 | + m.GetConn().CustomChan() <- func() { | |
283 | + m.UpdateProperties(map[string]interface{}{key: val}, notify) | |
272 | 284 | } |
273 | 285 | } else { |
274 | - m.UpdateProperties(conn, map[string]interface{}{key: val}, notify) | |
286 | + m.UpdateProperties(map[string]interface{}{key: val}, notify) | |
275 | 287 | } |
276 | 288 | } |
277 | 289 | |
278 | -func (m *RoleModel) SaveRoleDataChan(conn components.IConnection, now int64) { | |
279 | - if conn != nil { | |
280 | - conn.CustomChan() <- func() { | |
290 | +func (m *RoleModel) SaveRoleDataChan(now int64) { | |
291 | + if m.GetConn() != nil { | |
292 | + m.GetConn().CustomChan() <- func() { | |
281 | 293 | m.SaveRoleData(now) |
282 | 294 | } |
283 | 295 | } else { | ... | ... |
... | ... | @@ -0,0 +1,114 @@ |
1 | +package models | |
2 | + | |
3 | +import ( | |
4 | + "bytes" | |
5 | + "fmt" | |
6 | + "github.com/golang/protobuf/proto" | |
7 | + "pro2d/common/logger" | |
8 | + "pro2d/pb" | |
9 | + "strconv" | |
10 | + "strings" | |
11 | +) | |
12 | + | |
13 | +//背包系统 | |
14 | +func (m *RoleModel) GetItemCount(key string) uint32 { | |
15 | + c, ok := m.Items[key] | |
16 | + if !ok { | |
17 | + c = 0 | |
18 | + } | |
19 | + return c | |
20 | +} | |
21 | + | |
22 | +func (m *RoleModel) CostItem(key string, count int32) bool { | |
23 | + if uint32(count) > m.GetItemCount(key) { | |
24 | + return false | |
25 | + } | |
26 | + return m.AddItem(key, -count) | |
27 | +} | |
28 | + | |
29 | +func (m *RoleModel) CostItems(params BackPackItems) bool { | |
30 | + for k, v := range params { | |
31 | + if v > m.GetItemCount(k) { | |
32 | + return false | |
33 | + } | |
34 | + | |
35 | + m.AddItem(k, -int32(v)) | |
36 | + } | |
37 | + return true | |
38 | +} | |
39 | + | |
40 | +func (m *RoleModel) AddItem(key string, count int32) bool { | |
41 | + c := m.GetItemCount(key) | |
42 | + | |
43 | + num := int32(c) + count | |
44 | + if num > 0 { | |
45 | + m.Items[key] = uint32(num) | |
46 | + } else { | |
47 | + delete(m.Items, key) | |
48 | + } | |
49 | + m.SetProperty("items", m.ItemsToString(m.Items)) | |
50 | + | |
51 | + rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: fmt.Sprintf("%s=%d", key, num)}) | |
52 | + if err != nil { | |
53 | + logger.Error(err.Error()) | |
54 | + return true | |
55 | + } | |
56 | + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp) | |
57 | + return true | |
58 | +} | |
59 | + | |
60 | +func (m *RoleModel) AddItems(params BackPackItems) bool { | |
61 | + tmp := make(BackPackItems) | |
62 | + for k, v := range params { | |
63 | + c := m.GetItemCount(k) | |
64 | + | |
65 | + num := c + v | |
66 | + if num > 0 { | |
67 | + m.Items[k] = num | |
68 | + tmp[k] = num | |
69 | + } else { | |
70 | + delete(m.Items, k) | |
71 | + } | |
72 | + } | |
73 | + | |
74 | + m.SetProperty("items", m.ItemsToString(m.Items)) | |
75 | + | |
76 | + rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: m.ItemsToString(tmp)}) | |
77 | + if err != nil { | |
78 | + logger.Error(err.Error()) | |
79 | + return true | |
80 | + } | |
81 | + | |
82 | + if m.GetConn() != nil { | |
83 | + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp) | |
84 | + } | |
85 | + | |
86 | + return true | |
87 | +} | |
88 | + | |
89 | +func (m *RoleModel) ItemsToString(params BackPackItems) string { | |
90 | + var items bytes.Buffer | |
91 | + for k, v := range params { | |
92 | + items.WriteString(k) | |
93 | + items.WriteString("=") | |
94 | + items.WriteString(fmt.Sprintf("%d", v)) | |
95 | + items.WriteString(" ") | |
96 | + } | |
97 | + return items.String() | |
98 | +} | |
99 | + | |
100 | +func (m *RoleModel) StringToItems(items string) BackPackItems { | |
101 | + backPack := make(BackPackItems) | |
102 | + for _, v := range strings.Split(items, " ") { | |
103 | + ii := strings.Split(v, "=") | |
104 | + if len(ii) < 2 { | |
105 | + continue | |
106 | + } | |
107 | + n, err := strconv.ParseUint(ii[1], 10, 32) | |
108 | + if err != nil { | |
109 | + continue | |
110 | + } | |
111 | + backPack[ii[0]] = uint32(n) | |
112 | + } | |
113 | + return backPack | |
114 | +} | ... | ... |
models/role_test.go
... | ... | @@ -6,6 +6,8 @@ import ( |
6 | 6 | "pro2d/common/db/mongoproxy" |
7 | 7 | "pro2d/common/logger" |
8 | 8 | "pro2d/pb" |
9 | + "strconv" | |
10 | + "strings" | |
9 | 11 | "testing" |
10 | 12 | ) |
11 | 13 | |
... | ... | @@ -79,7 +81,7 @@ func TestRoleModel_ProtoReflect(t *testing.T) { |
79 | 81 | // "Id": "1", |
80 | 82 | // "Device": "12312312312", |
81 | 83 | //} |
82 | - sch.UpdateProperty(nil, "Device", "123123123", false) | |
84 | + sch.UpdateProperty("Device", "123123123", false) | |
83 | 85 | fmt.Println(sch.Role) |
84 | 86 | } |
85 | 87 | |
... | ... | @@ -120,4 +122,21 @@ func TestRoleModel_IncreByKey(t *testing.T) { |
120 | 122 | //sch.Update() |
121 | 123 | |
122 | 124 | fmt.Printf("%03d\n", 3) |
125 | + | |
126 | + ites := strings.SplitN("1=1 2=2 3=3", " ", -1) | |
127 | + fmt.Println(ites) | |
128 | + | |
129 | + items := make(BackPackItems) | |
130 | + for _, v := range ites { | |
131 | + ii := strings.Split(v, "=") | |
132 | + if len(ii) < 2 { | |
133 | + continue | |
134 | + } | |
135 | + n, err := strconv.ParseUint(ii[1], 10, 32) | |
136 | + if err != nil { | |
137 | + continue | |
138 | + } | |
139 | + items[ii[0]] = uint32(n) | |
140 | + } | |
141 | + fmt.Println(items) | |
123 | 142 | } | ... | ... |
models/schema.go
... | ... | @@ -20,6 +20,7 @@ func WithSchemaDB(idb components.IDB) SchemaOption { |
20 | 20 | type SchemaMap map[string]components.ISchema |
21 | 21 | |
22 | 22 | type Schema struct { |
23 | + conn components.IConnection | |
23 | 24 | db components.IDB |
24 | 25 | reflectValue *reflect.Value |
25 | 26 | reflectIndex map[string]int |
... | ... | @@ -124,6 +125,14 @@ func (s *Schema) UpdateSchema(schema interface{}) { |
124 | 125 | } |
125 | 126 | } |
126 | 127 | |
128 | +func (s *Schema) SetConn(conn components.IConnection) { | |
129 | + s.conn = conn | |
130 | +} | |
131 | + | |
132 | +func (s *Schema) GetConn() components.IConnection { | |
133 | + return s.conn | |
134 | +} | |
135 | + | |
127 | 136 | func (s *Schema) Load() error { |
128 | 137 | return s.db.Load() |
129 | 138 | } | ... | ... |
pb/game.pb.go
... | ... | @@ -393,6 +393,54 @@ func (x *ChangeTeamReq) GetTeam() []*Team { |
393 | 393 | return nil |
394 | 394 | } |
395 | 395 | |
396 | +//ResponseCmd RoleUpdateItemsRsp | |
397 | +type RoleUpdateItemsRsp struct { | |
398 | + state protoimpl.MessageState | |
399 | + sizeCache protoimpl.SizeCache | |
400 | + unknownFields protoimpl.UnknownFields | |
401 | + | |
402 | + Items string `protobuf:"bytes,1,opt,name=items,proto3" json:"items,omitempty"` | |
403 | +} | |
404 | + | |
405 | +func (x *RoleUpdateItemsRsp) Reset() { | |
406 | + *x = RoleUpdateItemsRsp{} | |
407 | + if protoimpl.UnsafeEnabled { | |
408 | + mi := &file_game_proto_msgTypes[7] | |
409 | + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |
410 | + ms.StoreMessageInfo(mi) | |
411 | + } | |
412 | +} | |
413 | + | |
414 | +func (x *RoleUpdateItemsRsp) String() string { | |
415 | + return protoimpl.X.MessageStringOf(x) | |
416 | +} | |
417 | + | |
418 | +func (*RoleUpdateItemsRsp) ProtoMessage() {} | |
419 | + | |
420 | +func (x *RoleUpdateItemsRsp) ProtoReflect() protoreflect.Message { | |
421 | + mi := &file_game_proto_msgTypes[7] | |
422 | + if protoimpl.UnsafeEnabled && x != nil { | |
423 | + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) | |
424 | + if ms.LoadMessageInfo() == nil { | |
425 | + ms.StoreMessageInfo(mi) | |
426 | + } | |
427 | + return ms | |
428 | + } | |
429 | + return mi.MessageOf(x) | |
430 | +} | |
431 | + | |
432 | +// Deprecated: Use RoleUpdateItemsRsp.ProtoReflect.Descriptor instead. | |
433 | +func (*RoleUpdateItemsRsp) Descriptor() ([]byte, []int) { | |
434 | + return file_game_proto_rawDescGZIP(), []int{7} | |
435 | +} | |
436 | + | |
437 | +func (x *RoleUpdateItemsRsp) GetItems() string { | |
438 | + if x != nil { | |
439 | + return x.Items | |
440 | + } | |
441 | + return "" | |
442 | +} | |
443 | + | |
396 | 444 | var File_game_proto protoreflect.FileDescriptor |
397 | 445 | |
398 | 446 | var file_game_proto_rawDesc = []byte{ |
... | ... | @@ -424,8 +472,11 @@ var file_game_proto_rawDesc = []byte{ |
424 | 472 | 0x65, 0x22, 0x31, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, |
425 | 473 | 0x65, 0x71, 0x12, 0x20, 0x0a, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, |
426 | 474 | 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x04, |
427 | - 0x74, 0x65, 0x61, 0x6d, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, | |
428 | - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |
475 | + 0x74, 0x65, 0x61, 0x6d, 0x22, 0x2a, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, | |
476 | + 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, | |
477 | + 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, | |
478 | + 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, | |
479 | + 0x6f, 0x74, 0x6f, 0x33, | |
429 | 480 | } |
430 | 481 | |
431 | 482 | var ( |
... | ... | @@ -440,7 +491,7 @@ func file_game_proto_rawDescGZIP() []byte { |
440 | 491 | return file_game_proto_rawDescData |
441 | 492 | } |
442 | 493 | |
443 | -var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 7) | |
494 | +var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 8) | |
444 | 495 | var file_game_proto_goTypes = []interface{}{ |
445 | 496 | (*HeartReq)(nil), // 0: game.HeartReq |
446 | 497 | (*HeartRsp)(nil), // 1: game.HeartRsp |
... | ... | @@ -449,21 +500,22 @@ var file_game_proto_goTypes = []interface{}{ |
449 | 500 | (*RoleRsp)(nil), // 4: game.RoleRsp |
450 | 501 | (*UpdateRolePropertyRsp)(nil), // 5: game.UpdateRolePropertyRsp |
451 | 502 | (*ChangeTeamReq)(nil), // 6: game.ChangeTeamReq |
452 | - (*Role)(nil), // 7: models.Role | |
453 | - (*Hero)(nil), // 8: models.Hero | |
454 | - (*Team)(nil), // 9: models.Team | |
503 | + (*RoleUpdateItemsRsp)(nil), // 7: game.RoleUpdateItemsRsp | |
504 | + (*Role)(nil), // 8: models.Role | |
505 | + (*Hero)(nil), // 9: models.Hero | |
506 | + (*Team)(nil), // 10: models.Team | |
455 | 507 | } |
456 | 508 | var file_game_proto_depIdxs = []int32{ |
457 | - 7, // 0: game.RoleRsp.role:type_name -> models.Role | |
458 | - 8, // 1: game.RoleRsp.hero:type_name -> models.Hero | |
459 | - 9, // 2: game.RoleRsp.team:type_name -> models.Team | |
460 | - 7, // 3: game.UpdateRolePropertyRsp.role:type_name -> models.Role | |
461 | - 9, // 4: game.ChangeTeamReq.team:type_name -> models.Team | |
462 | - 5, // [5:5] is the sub-list for method output_type | |
463 | - 5, // [5:5] is the sub-list for method input_type | |
464 | - 5, // [5:5] is the sub-list for extension type_name | |
465 | - 5, // [5:5] is the sub-list for extension extendee | |
466 | - 0, // [0:5] is the sub-list for field type_name | |
509 | + 8, // 0: game.RoleRsp.role:type_name -> models.Role | |
510 | + 9, // 1: game.RoleRsp.hero:type_name -> models.Hero | |
511 | + 10, // 2: game.RoleRsp.team:type_name -> models.Team | |
512 | + 8, // 3: game.UpdateRolePropertyRsp.role:type_name -> models.Role | |
513 | + 10, // 4: game.ChangeTeamReq.team:type_name -> models.Team | |
514 | + 5, // [5:5] is the sub-list for method output_type | |
515 | + 5, // [5:5] is the sub-list for method input_type | |
516 | + 5, // [5:5] is the sub-list for extension type_name | |
517 | + 5, // [5:5] is the sub-list for extension extendee | |
518 | + 0, // [0:5] is the sub-list for field type_name | |
467 | 519 | } |
468 | 520 | |
469 | 521 | func init() { file_game_proto_init() } |
... | ... | @@ -557,6 +609,18 @@ func file_game_proto_init() { |
557 | 609 | return nil |
558 | 610 | } |
559 | 611 | } |
612 | + file_game_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { | |
613 | + switch v := v.(*RoleUpdateItemsRsp); i { | |
614 | + case 0: | |
615 | + return &v.state | |
616 | + case 1: | |
617 | + return &v.sizeCache | |
618 | + case 2: | |
619 | + return &v.unknownFields | |
620 | + default: | |
621 | + return nil | |
622 | + } | |
623 | + } | |
560 | 624 | } |
561 | 625 | type x struct{} |
562 | 626 | out := protoimpl.TypeBuilder{ |
... | ... | @@ -564,7 +628,7 @@ func file_game_proto_init() { |
564 | 628 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), |
565 | 629 | RawDescriptor: file_game_proto_rawDesc, |
566 | 630 | NumEnums: 0, |
567 | - NumMessages: 7, | |
631 | + NumMessages: 8, | |
568 | 632 | NumExtensions: 0, |
569 | 633 | NumServices: 0, |
570 | 634 | }, | ... | ... |
pb/models.pb.go
... | ... | @@ -451,18 +451,19 @@ type Role struct { |
451 | 451 | sizeCache protoimpl.SizeCache |
452 | 452 | unknownFields protoimpl.UnknownFields |
453 | 453 | |
454 | - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" | |
455 | - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty" index:"unique"` // @inject_tag: index:"unique" | |
456 | - Device string `protobuf:"bytes,3,opt,name=device,proto3" json:"device,omitempty"` | |
457 | - Nick string `protobuf:"bytes,4,opt,name=nick,proto3" json:"nick,omitempty"` | |
458 | - Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"` | |
459 | - Exp int64 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"` | |
460 | - Hp int64 `protobuf:"varint,7,opt,name=hp,proto3" json:"hp,omitempty"` | |
461 | - HpMax int64 `protobuf:"varint,8,opt,name=hp_max,json=hpMax,proto3" json:"hp_max,omitempty"` | |
462 | - BuyR string `protobuf:"bytes,11,opt,name=buy_r,json=buyR,proto3" json:"buy_r,omitempty"` | |
463 | - PayR string `protobuf:"bytes,12,opt,name=pay_r,json=payR,proto3" json:"pay_r,omitempty"` | |
464 | - Del bool `protobuf:"varint,13,opt,name=del,proto3" json:"del,omitempty"` | |
465 | - 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"` | |
454 | + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" | |
455 | + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty" index:"unique"` // @inject_tag: index:"unique" | |
456 | + Device string `protobuf:"bytes,3,opt,name=device,proto3" json:"device,omitempty"` | |
457 | + Nick string `protobuf:"bytes,4,opt,name=nick,proto3" json:"nick,omitempty"` | |
458 | + Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"` | |
459 | + Exp int64 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"` | |
460 | + Hp int64 `protobuf:"varint,7,opt,name=hp,proto3" json:"hp,omitempty"` | |
461 | + HpMax int64 `protobuf:"varint,8,opt,name=hp_max,json=hpMax,proto3" json:"hp_max,omitempty"` | |
462 | + BuyR string `protobuf:"bytes,11,opt,name=buy_r,json=buyR,proto3" json:"buy_r,omitempty"` | |
463 | + PayR string `protobuf:"bytes,12,opt,name=pay_r,json=payR,proto3" json:"pay_r,omitempty"` | |
464 | + Del bool `protobuf:"varint,13,opt,name=del,proto3" json:"del,omitempty"` | |
465 | + 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"` | |
466 | + Items string `protobuf:"bytes,15,opt,name=items,proto3" json:"items,omitempty"` | |
466 | 467 | } |
467 | 468 | |
468 | 469 | func (x *Role) Reset() { |
... | ... | @@ -574,13 +575,20 @@ func (x *Role) GetDel() bool { |
574 | 575 | return false |
575 | 576 | } |
576 | 577 | |
577 | -func (x *Role) GetIncres() map[string]int64 { | |
578 | +func (x *Role) GetIncres() map[string]uint32 { | |
578 | 579 | if x != nil { |
579 | 580 | return x.Incres |
580 | 581 | } |
581 | 582 | return nil |
582 | 583 | } |
583 | 584 | |
585 | +func (x *Role) GetItems() string { | |
586 | + if x != nil { | |
587 | + return x.Items | |
588 | + } | |
589 | + return "" | |
590 | +} | |
591 | + | |
584 | 592 | var File_models_proto protoreflect.FileDescriptor |
585 | 593 | |
586 | 594 | var file_models_proto_rawDesc = []byte{ |
... | ... | @@ -624,7 +632,7 @@ var file_models_proto_rawDesc = []byte{ |
624 | 632 | 0x65, 0x72, 0x6f, 0x49, 0x64, 0x33, 0x22, 0x2f, 0x0a, 0x09, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, |
625 | 633 | 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, |
626 | 634 | 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, |
627 | - 0x28, 0x03, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xcc, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, | |
635 | + 0x28, 0x03, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xe2, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, | |
628 | 636 | 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, |
629 | 637 | 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, |
630 | 638 | 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{ |
641 | 649 | 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x64, 0x65, 0x6c, 0x12, 0x30, 0x0a, 0x06, 0x69, 0x6e, 0x63, |
642 | 650 | 0x72, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x6f, 0x64, 0x65, |
643 | 651 | 0x6c, 0x73, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x2e, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x45, 0x6e, |
644 | - 0x74, 0x72, 0x79, 0x52, 0x06, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x49, | |
645 | - 0x6e, 0x63, 0x72, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, | |
646 | - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, | |
647 | - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, | |
648 | - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, | |
649 | - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |
652 | + 0x74, 0x72, 0x79, 0x52, 0x06, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x69, | |
653 | + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, | |
654 | + 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, | |
655 | + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, | |
656 | + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, | |
657 | + 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0a, 0x5a, 0x08, | |
658 | + 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |
650 | 659 | } |
651 | 660 | |
652 | 661 | var ( | ... | ... |
pb/protocode.pb.go
... | ... | @@ -32,6 +32,7 @@ const ( |
32 | 32 | ProtoCode_RoleRsp ProtoCode = 6 |
33 | 33 | ProtoCode_UpdateRolePropertyRsp ProtoCode = 7 |
34 | 34 | ProtoCode_ChangeTeamReq ProtoCode = 8 |
35 | + ProtoCode_RoleUpdateItemsRsp ProtoCode = 9 | |
35 | 36 | ) |
36 | 37 | |
37 | 38 | // Enum value maps for ProtoCode. |
... | ... | @@ -46,6 +47,7 @@ var ( |
46 | 47 | 6: "RoleRsp", |
47 | 48 | 7: "UpdateRolePropertyRsp", |
48 | 49 | 8: "ChangeTeamReq", |
50 | + 9: "RoleUpdateItemsRsp", | |
49 | 51 | } |
50 | 52 | ProtoCode_value = map[string]int32{ |
51 | 53 | "UNKNOWN": 0, |
... | ... | @@ -57,6 +59,7 @@ var ( |
57 | 59 | "RoleRsp": 6, |
58 | 60 | "UpdateRolePropertyRsp": 7, |
59 | 61 | "ChangeTeamReq": 8, |
62 | + "RoleUpdateItemsRsp": 9, | |
60 | 63 | } |
61 | 64 | ) |
62 | 65 | |
... | ... | @@ -91,7 +94,7 @@ var File_protocode_proto protoreflect.FileDescriptor |
91 | 94 | |
92 | 95 | var file_protocode_proto_rawDesc = []byte{ |
93 | 96 | 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, |
94 | - 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0x9a, 0x01, 0x0a, | |
97 | + 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0xb2, 0x01, 0x0a, | |
95 | 98 | 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, |
96 | 99 | 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, |
97 | 100 | 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{ |
101 | 104 | 0x0a, 0x07, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x06, 0x12, 0x19, 0x0a, 0x15, 0x55, |
102 | 105 | 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, |
103 | 106 | 0x79, 0x52, 0x73, 0x70, 0x10, 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, |
104 | - 0x54, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x10, 0x08, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, | |
105 | - 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |
107 | + 0x54, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x10, 0x08, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, | |
108 | + 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x10, | |
109 | + 0x09, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, | |
110 | + 0x72, 0x6f, 0x74, 0x6f, 0x33, | |
106 | 111 | } |
107 | 112 | |
108 | 113 | var ( | ... | ... |