Commit 4a502dd5e1b6addff80f1c09e66909f90a18cf8d
1 parent
07aebd7d
fix: game,account,gm的action添加godoc
Showing
18 changed files
with
199 additions
and
82 deletions
 
Show diff stats
Makefile
| ... | ... | @@ -12,7 +12,7 @@ gen: | 
| 12 | 12 | test: | 
| 13 | 13 | go run cmd/test/client.go | 
| 14 | 14 | http: | 
| 15 | - go run $(race) cmd/httpserver/http.go cmd/httpserver/AccountAction.go | |
| 15 | + go run $(race) cmd/httpserver/main.go | |
| 16 | 16 | |
| 17 | 17 | game: | 
| 18 | 18 | go run -race cmd/gameserver/*.go | 
| ... | ... | @@ -27,5 +27,8 @@ plugin: | 
| 27 | 27 | cd bin && rm -rf ./plugin*.so && cd - | 
| 28 | 28 | go build $(race) $(DEBUG) --buildmode=plugin -o bin/$(pname).so cmd/gameserver/plugin/*.go #--ldflags="-pluginpath=$(pname)" | 
| 29 | 29 | cd bin && ln -s $(pname).so plugin.so && cd - | 
| 30 | +doc: | |
| 31 | + godoc -http=:8980 -goroot="." -play | |
| 32 | + open localhost:8980/pkg/pro2d/cmd/gameserver/action/#pkg-index | |
| 30 | 33 | |
| 31 | -.PHONY: all build protos test cert plugin | |
| 32 | 34 | \ No newline at end of file | 
| 35 | +.PHONY: all build protos test cert plugin doc | |
| 33 | 36 | \ No newline at end of file | ... | ... | 
cmd/gameserver/action/GmAction.go
| 1 | +// GM系统API | |
| 1 | 2 | package action | 
| 2 | 3 | |
| 3 | 4 | import ( | 
| 4 | - "pro2d/common/logger" | |
| 5 | 5 | "pro2d/models" | 
| 6 | 6 | "pro2d/pb" | 
| 7 | 7 | "strconv" | 
| 8 | 8 | ) | 
| 9 | 9 | |
| 10 | -type GmAction struct { | |
| 11 | -} | |
| 10 | +type GmAction struct{} | |
| 11 | + | |
| 12 | +// GMParams GM系统API请求参数的基础类型 | |
| 13 | +type GMParams map[string]string | |
| 12 | 14 | |
| 13 | -func (gm *GmAction) AddExp(role *models.RoleModel, params ...interface{}) { | |
| 14 | - logger.Debug(params) | |
| 15 | - expIncrease, _ := strconv.Atoi(params[0].(string)) | |
| 15 | +/* | |
| 16 | +AddExp 增加经验 | |
| 17 | + exp 增加经验数量 | |
| 18 | +*/ | |
| 19 | +func (gm *GmAction) AddExp(role *models.RoleModel, params GMParams) { | |
| 20 | + expIncrease, _ := strconv.Atoi(params["exp"]) | |
| 16 | 21 | exp := role.IncrProperty("exp", int64(expIncrease)) | 
| 17 | 22 | role.UpdateProperty("exp", exp, true) | 
| 18 | 23 | } | 
| 19 | 24 | |
| 20 | -func (gm *GmAction) AddEquip(role *models.RoleModel, params ...interface{}) { | |
| 21 | - logger.Debug(params) | |
| 25 | +/* | |
| 26 | +AddEquip 添加装备 | |
| 27 | + id: 装备id | |
| 28 | +*/ | |
| 29 | +func (gm *GmAction) AddEquip(role *models.RoleModel, params GMParams) { | |
| 22 | 30 | //TODO 验证装备是否存在 | 
| 23 | 31 | |
| 24 | 32 | equip := &pb.Equipment{ | 
| 25 | 33 | Id: role.IncreEquipByKey(1), | 
| 26 | 34 | RoleId: role.Role.Id, | 
| 27 | - Type: params[0].(string), | |
| 35 | + Type: params["id"], | |
| 28 | 36 | Quality: 1, | 
| 29 | 37 | } | 
| 30 | 38 | role.AddEquip(equip) | 
| 31 | 39 | } | 
| 40 | + | |
| 41 | +/* | |
| 42 | +AddItem 添加物品 | |
| 43 | + id: 物品id | |
| 44 | + count: 物品数量 | |
| 45 | +*/ | |
| 46 | +func (gm *GmAction) AddItem(role *models.RoleModel, params GMParams) { | |
| 47 | + id := params["id"] | |
| 48 | + count, _ := strconv.Atoi(params["count"]) | |
| 49 | + role.AddItem(id, int32(count)) | |
| 50 | +} | |
| 51 | + | |
| 52 | +/* | |
| 53 | +UpdatePackLimit 更新背包限制 | |
| 54 | + clotheslimit: 服饰限制数 | |
| 55 | + weaponslimit: 武器限制数 | |
| 56 | + otherlimit: 其他限制数 | |
| 57 | +*/ | |
| 58 | +func (gm *GmAction) UpdatePackLimit(role *models.RoleModel, params GMParams) { | |
| 59 | + update := make(map[string]interface{}, 3) | |
| 60 | + c, ok := params["clotheslimit"] | |
| 61 | + if ok { | |
| 62 | + update["clotheslimit"], _ = strconv.Atoi(c) | |
| 63 | + } | |
| 64 | + w := params["weaponslimit"] | |
| 65 | + if ok { | |
| 66 | + update["weaponslimit"], _ = strconv.Atoi(w) | |
| 67 | + } | |
| 68 | + o := params["otherlimit"] | |
| 69 | + if ok { | |
| 70 | + update["otherlimit"], _ = strconv.Atoi(o) | |
| 71 | + } | |
| 72 | + role.UpdateProperties(update, true) | |
| 73 | +} | ... | ... | 
cmd/gameserver/action/RoleAction.go
| 1 | +// Package action 游戏服角色相关操作 | |
| 1 | 2 | package action | 
| 2 | 3 | |
| 3 | 4 | import ( | 
| ... | ... | @@ -12,11 +13,13 @@ import ( | 
| 12 | 13 | "pro2d/pb" | 
| 13 | 14 | ) | 
| 14 | 15 | |
| 16 | +// HeartRpc 心跳请求 | |
| 15 | 17 | func HeartRpc(role *models.RoleModel, msg components.IMessage) (int32, interface{}) { | 
| 16 | 18 | //msg.Conn.SetLastHeartCheckTime() | 
| 17 | 19 | return 0, nil | 
| 18 | 20 | } | 
| 19 | 21 | |
| 22 | +// getRandomName 随机名字 | |
| 20 | 23 | func getRandomName() string { | 
| 21 | 24 | name := "" | 
| 22 | 25 | for { | 
| ... | ... | @@ -36,6 +39,11 @@ func getRandomName() string { | 
| 36 | 39 | return name | 
| 37 | 40 | } | 
| 38 | 41 | |
| 42 | +/* | |
| 43 | +CreateRpc 创建角色请求 | |
| 44 | + 1: proto解析错误 | |
| 45 | + 2: 角色不存在 | |
| 46 | +*/ | |
| 39 | 47 | func CreateRpc(role1 *models.RoleModel, msg components.IMessage) (int32, interface{}) { | 
| 40 | 48 | req := pb.CreateReq{} | 
| 41 | 49 | if err := proto.Unmarshal(msg.GetData(), &req); err != nil { | 
| ... | ... | @@ -63,6 +71,7 @@ func CreateRpc(role1 *models.RoleModel, msg components.IMessage) (int32, interfa | 
| 63 | 71 | return 0, nil | 
| 64 | 72 | } | 
| 65 | 73 | |
| 74 | +// ChangeTeamRpc 阵容变换 | |
| 66 | 75 | func ChangeTeamRpc(role *models.RoleModel, msg components.IMessage) (int32, interface{}) { | 
| 67 | 76 | req := pb.ChangeTeamReq{} | 
| 68 | 77 | if err := proto.Unmarshal(msg.GetData(), &req); err != nil { | 
| ... | ... | @@ -74,6 +83,10 @@ func ChangeTeamRpc(role *models.RoleModel, msg components.IMessage) (int32, inte | 
| 74 | 83 | return 0, nil | 
| 75 | 84 | } | 
| 76 | 85 | |
| 86 | +/* | |
| 87 | +HeroEquipReferRpc 穿戴/脱 装备 | |
| 88 | + 2: 装备不存在 | |
| 89 | +*/ | |
| 77 | 90 | func HeroEquipReferRpc(role *models.RoleModel, msg components.IMessage) (int32, interface{}) { | 
| 78 | 91 | req := pb.HeroEquipReferReq{} | 
| 79 | 92 | if err := proto.Unmarshal(msg.GetData(), &req); err != nil { | 
| ... | ... | @@ -118,6 +131,10 @@ func HeroEquipReferRpc(role *models.RoleModel, msg components.IMessage) (int32, | 
| 118 | 131 | return 0, nil | 
| 119 | 132 | } | 
| 120 | 133 | |
| 134 | +/* | |
| 135 | +RoleClearItemsRpc 删除物品 | |
| 136 | + 2 删除失败 | |
| 137 | +*/ | |
| 121 | 138 | func RoleClearItemsRpc(role *models.RoleModel, msg components.IMessage) (int32, interface{}) { | 
| 122 | 139 | req := pb.RoleClearItemsReq{} | 
| 123 | 140 | if err := proto.Unmarshal(msg.GetData(), &req); err != nil { | 
| ... | ... | @@ -132,6 +149,10 @@ func RoleClearItemsRpc(role *models.RoleModel, msg components.IMessage) (int32, | 
| 132 | 149 | return 0, nil | 
| 133 | 150 | } | 
| 134 | 151 | |
| 152 | +/* | |
| 153 | +EquipmentDelRpc 删除装备 | |
| 154 | + 2 删除失败 | |
| 155 | +*/ | |
| 135 | 156 | func EquipmentDelRpc(role *models.RoleModel, msg components.IMessage) (int32, interface{}) { | 
| 136 | 157 | req := pb.EquipmentDelReq{} | 
| 137 | 158 | if err := proto.Unmarshal(msg.GetData(), &req); err != nil { | ... | ... | 
cmd/gameserver/plugin/plugin.go
cmd/gameserver/service/agent.go
| ... | ... | @@ -58,6 +58,9 @@ func (c *Agent) OnConnection(conn components.IConnection) { | 
| 58 | 58 | c.IConnection = conn | 
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | +/*OnLoginQuery 登录请求 | |
| 62 | +2 角色不存在 | |
| 63 | +*/ | |
| 61 | 64 | func (c *Agent) OnLoginQuery(msg components.IMessage) (int32, proto.Message) { | 
| 62 | 65 | //logger.Debug("11111111cmd: %v, msg: %s", msg.GetHeader().GetMsgID(), msg.GetData()) | 
| 63 | 66 | req := pb.LoginReq{} | ... | ... | 
cmd/gameserver/service/gm.go
| ... | ... | @@ -5,6 +5,7 @@ import ( | 
| 5 | 5 | "net/http" | 
| 6 | 6 | "pro2d/cmd/gameserver/action" | 
| 7 | 7 | "pro2d/common/components" | 
| 8 | + "pro2d/common/logger" | |
| 8 | 9 | "pro2d/models" | 
| 9 | 10 | "reflect" | 
| 10 | 11 | ) | 
| ... | ... | @@ -25,19 +26,20 @@ func (s *GmServer) HandlerFuncObj(tvl, obj reflect.Value) gin.HandlerFunc { | 
| 25 | 26 | return func(c *gin.Context) { | 
| 26 | 27 | var roleId string | 
| 27 | 28 | var ok bool | 
| 28 | - properties := make([]interface{}, 2) | |
| 29 | + properties := make(map[string]string, 2) | |
| 29 | 30 | //请求类型,以及 format 参数 | 
| 30 | 31 | if c.Request.Method == "POST" { | 
| 31 | 32 | c.Request.ParseForm() | 
| 32 | - for _, v := range c.Request.PostForm { | |
| 33 | - properties = append(properties, v[0]) | |
| 33 | + for k, v := range c.Request.PostForm { | |
| 34 | + properties[k] = v[0] | |
| 34 | 35 | } | 
| 35 | 36 | roleId, ok = c.GetPostForm("role_id") | 
| 36 | 37 | |
| 37 | 38 | } else if c.Request.Method == "GET" { | 
| 38 | 39 | roleId, ok = c.GetQuery("role_id") | 
| 39 | - for _, v := range c.Request.URL.Query() { | |
| 40 | - properties = append(properties, v[0]) | |
| 40 | + logger.Debug(c.Request.URL.Query()) | |
| 41 | + for k, v := range c.Request.URL.Query() { | |
| 42 | + properties[k] = v[0] | |
| 41 | 43 | } | 
| 42 | 44 | } else { | 
| 43 | 45 | c.JSON(http.StatusOK, gin.H{"code": -101, "message": "not support method"}) | 
| ... | ... | @@ -53,6 +55,7 @@ func (s *GmServer) HandlerFuncObj(tvl, obj reflect.Value) gin.HandlerFunc { | 
| 53 | 55 | conn := s.Server.GetConnManage().GetConnByRID(roleId) | 
| 54 | 56 | var role *models.RoleModel | 
| 55 | 57 | callback := func() { | 
| 58 | + logger.Debug(properties) | |
| 56 | 59 | tvl.Call([]reflect.Value{obj, reflect.ValueOf(role), reflect.ValueOf(properties)}) | 
| 57 | 60 | role.SaveRoleData(0) | 
| 58 | 61 | } | ... | ... | 
cmd/httpserver/AccountAction.go renamed to cmd/httpserver/action/AccountAction.go
| 1 | -package main | |
| 1 | +// Account 账号系统API | |
| 2 | +package action | |
| 2 | 3 | |
| 3 | 4 | import ( | 
| 4 | 5 | "fmt" | 
| 5 | 6 | "github.com/garyburd/redigo/redis" | 
| 6 | 7 | "github.com/gin-gonic/gin" | 
| 8 | + "pro2d/cmd/httpserver/service" | |
| 7 | 9 | "pro2d/common" | 
| 8 | 10 | "pro2d/common/db/redisproxy" | 
| 9 | 11 | "pro2d/common/etcd" | 
| ... | ... | @@ -14,9 +16,16 @@ import ( | 
| 14 | 16 | ) | 
| 15 | 17 | |
| 16 | 18 | type AccountAction struct { | 
| 17 | - HttpServer *AccountServer | |
| 19 | + HttpServer *service.AccountServer | |
| 18 | 20 | } | 
| 19 | 21 | |
| 22 | +/*Register 账号注册 | |
| 23 | +2 验证码转化为string错误 | |
| 24 | +3 验证码错误 | |
| 25 | +4 手机号已存在,不用重复注册 | |
| 26 | +5 uid get error | |
| 27 | +6 mongo create error | |
| 28 | +*/ | |
| 20 | 29 | func (h *AccountAction) Register(c *gin.Context) (int, interface{}) { | 
| 21 | 30 | var register pb.Register | 
| 22 | 31 | if err := c.ShouldBindJSON(®ister); err != nil { | 
| ... | ... | @@ -55,6 +64,10 @@ func (h *AccountAction) Register(c *gin.Context) (int, interface{}) { | 
| 55 | 64 | return 0, "success" | 
| 56 | 65 | } | 
| 57 | 66 | |
| 67 | +/*Login 登录 | |
| 68 | +2 账号不存在 | |
| 69 | +3 密码错误 | |
| 70 | +*/ | |
| 58 | 71 | func (h *AccountAction) Login(c *gin.Context) (int, interface{}) { | 
| 59 | 72 | var login pb.Account | 
| 60 | 73 | if err := c.ShouldBindJSON(&login); err != nil { | 
| ... | ... | @@ -62,7 +75,7 @@ func (h *AccountAction) Login(c *gin.Context) (int, interface{}) { | 
| 62 | 75 | } | 
| 63 | 76 | account := models.NewAccount(login.Phone) | 
| 64 | 77 | if err := account.Load(); err != nil { | 
| 65 | - return 2, err.Error() | |
| 78 | + return 2, "account not exists" | |
| 66 | 79 | } | 
| 67 | 80 | |
| 68 | 81 | if common.Md5V(login.Password) != account.Password { | 
| ... | ... | @@ -84,6 +97,10 @@ func (h *AccountAction) Login(c *gin.Context) (int, interface{}) { | 
| 84 | 97 | return 0, rsp | 
| 85 | 98 | } | 
| 86 | 99 | |
| 100 | +/*Sms 发短信 | |
| 101 | +2 发送太频繁 | |
| 102 | +3 发送失败 | |
| 103 | +*/ | |
| 87 | 104 | func (h *AccountAction) Sms(c *gin.Context) (int, interface{}) { | 
| 88 | 105 | phone, ok := c.GetQuery("phone") | 
| 89 | 106 | if !ok { | ... | ... | 
cmd/httpserver/http.go renamed to cmd/httpserver/service/http.go
| 1 | -package main | |
| 1 | +package service | |
| 2 | 2 | |
| 3 | 3 | import ( | 
| 4 | 4 | "fmt" | 
| 5 | 5 | "math/rand" | 
| 6 | - "os" | |
| 7 | - "os/signal" | |
| 8 | 6 | "pro2d/common" | 
| 9 | 7 | "pro2d/common/components" | 
| 10 | 8 | "pro2d/common/db/mongoproxy" | 
| 11 | 9 | "pro2d/common/db/redisproxy" | 
| 12 | 10 | "pro2d/common/etcd" | 
| 13 | - "pro2d/common/logger" | |
| 14 | 11 | "pro2d/models" | 
| 15 | - "syscall" | |
| 16 | 12 | "time" | 
| 17 | 13 | ) | 
| 18 | 14 | |
| ... | ... | @@ -70,25 +66,3 @@ func (s *AccountServer) Stop() { | 
| 70 | 66 | s.IHttp.Stop() | 
| 71 | 67 | etcd.CloseEtcd() | 
| 72 | 68 | } | 
| 73 | - | |
| 74 | -func main() { | |
| 75 | - err := make(chan error) | |
| 76 | - stopChan := make(chan os.Signal) | |
| 77 | - signal.Notify(stopChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) | |
| 78 | - | |
| 79 | - common.GlobalSconf = common.GlobalConf.AccountConf | |
| 80 | - | |
| 81 | - web := NewAccountServer("v1", fmt.Sprintf(":%d", common.GlobalSconf.Port)) | |
| 82 | - web.BindHandler(&AccountAction{HttpServer: web}) | |
| 83 | - go func() { | |
| 84 | - err <- web.Start() | |
| 85 | - }() | |
| 86 | - | |
| 87 | - select { | |
| 88 | - case e := <-err: | |
| 89 | - logger.Error("http server error: %v", e) | |
| 90 | - case <-stopChan: | |
| 91 | - logger.Debug("http stop") | |
| 92 | - web.Stop() | |
| 93 | - } | |
| 94 | -} | ... | ... | 
common/commonFunc.go
| ... | ... | @@ -6,6 +6,7 @@ import ( | 
| 6 | 6 | "fmt" | 
| 7 | 7 | "github.com/garyburd/redigo/redis" | 
| 8 | 8 | "pro2d/common/db/redisproxy" | 
| 9 | + "strconv" | |
| 9 | 10 | "strings" | 
| 10 | 11 | ) | 
| 11 | 12 | |
| ... | ... | @@ -54,7 +55,7 @@ func GetNextUId() (string, error) { | 
| 54 | 55 | |
| 55 | 56 | type IMapString map[string]interface{} | 
| 56 | 57 | |
| 57 | -func MapToString(params map[string]interface{}) string { | |
| 58 | +func MapToString(params IMapString) string { | |
| 58 | 59 | var items bytes.Buffer | 
| 59 | 60 | for k, v := range params { | 
| 60 | 61 | items.WriteString(k) | 
| ... | ... | @@ -65,14 +66,22 @@ func MapToString(params map[string]interface{}) string { | 
| 65 | 66 | return items.String() | 
| 66 | 67 | } | 
| 67 | 68 | |
| 68 | -func StringToMap(items string) map[string]interface{} { | |
| 69 | - backPack := make(map[string]interface{}) | |
| 69 | +func StringToMap(items string, num bool) IMapString { | |
| 70 | + backPack := make(map[string]interface{}, 10) | |
| 70 | 71 | for _, v := range strings.Split(items, " ") { | 
| 71 | 72 | ii := strings.Split(v, "=") | 
| 72 | 73 | if len(ii) < 2 { | 
| 73 | 74 | continue | 
| 74 | 75 | } | 
| 75 | - backPack[ii[0]] = ii[1] | |
| 76 | + if num { | |
| 77 | + c, err := strconv.Atoi(ii[1]) | |
| 78 | + if err != nil { | |
| 79 | + continue | |
| 80 | + } | |
| 81 | + backPack[ii[0]] = uint32(c) | |
| 82 | + } else { | |
| 83 | + backPack[ii[0]] = ii[1] | |
| 84 | + } | |
| 76 | 85 | } | 
| 77 | 86 | return backPack | 
| 78 | 87 | } | ... | ... | 
common/const.go
| ... | ... | @@ -52,11 +52,12 @@ require ( | 
| 52 | 52 | go.uber.org/atomic v1.7.0 // indirect | 
| 53 | 53 | go.uber.org/multierr v1.6.0 // indirect | 
| 54 | 54 | go.uber.org/zap v1.17.0 // indirect | 
| 55 | - golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f // indirect | |
| 56 | - golang.org/x/net v0.0.0-20220403103023-749bd193bc2b // indirect | |
| 55 | + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect | |
| 56 | + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect | |
| 57 | 57 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect | 
| 58 | - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect | |
| 58 | + golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect | |
| 59 | 59 | golang.org/x/text v0.3.7 // indirect | 
| 60 | + golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect | |
| 60 | 61 | google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect | 
| 61 | 62 | google.golang.org/grpc v1.38.0 // indirect | 
| 62 | 63 | gopkg.in/ini.v1 v1.66.4 // indirect | ... | ... | 
| ... | ... | @@ -242,8 +242,9 @@ golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPh | 
| 242 | 242 | golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | 
| 243 | 243 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | 
| 244 | 244 | golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | 
| 245 | -golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f h1:aZp0e2vLN4MToVqnjNEYEtrEA8RH8U8FN1CU7JgqsPU= | |
| 246 | 245 | golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= | 
| 246 | +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= | |
| 247 | +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | |
| 247 | 248 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | 
| 248 | 249 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | 
| 249 | 250 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= | 
| ... | ... | @@ -268,9 +269,10 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R | 
| 268 | 269 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | 
| 269 | 270 | golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | 
| 270 | 271 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | 
| 272 | +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | |
| 271 | 273 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= | 
| 272 | -golang.org/x/net v0.0.0-20220403103023-749bd193bc2b h1:vI32FkLJNAWtGD4BwkThwEy6XS7ZLLMHkSkYfF8M0W0= | |
| 273 | -golang.org/x/net v0.0.0-20220403103023-749bd193bc2b/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= | |
| 274 | +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= | |
| 275 | +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= | |
| 274 | 276 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | 
| 275 | 277 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | 
| 276 | 278 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | 
| ... | ... | @@ -305,8 +307,9 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w | 
| 305 | 307 | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 
| 306 | 308 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 
| 307 | 309 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 
| 308 | -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= | |
| 309 | 310 | golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 
| 311 | +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60= | |
| 312 | +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 310 | 313 | golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= | 
| 311 | 314 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | 
| 312 | 315 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | 
| ... | ... | @@ -332,8 +335,9 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= | 
| 332 | 335 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 
| 333 | 336 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 
| 334 | 337 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 
| 335 | -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= | |
| 336 | 338 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 
| 339 | +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U= | |
| 340 | +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |
| 337 | 341 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= | 
| 338 | 342 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= | 
| 339 | 343 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= | ... | ... | 
models/hero.go
| ... | ... | @@ -16,7 +16,7 @@ func NewHero(hero *pb.Hero) *HeroModel { | 
| 16 | 16 | m := &HeroModel{ | 
| 17 | 17 | ISchema: NewSchema(hero.Id, hero), | 
| 18 | 18 | Hero: hero, | 
| 19 | - Equipments: common.StringToMap(hero.Equipments), | |
| 19 | + Equipments: common.StringToMap(hero.Equipments, false), | |
| 20 | 20 | } | 
| 21 | 21 | return m | 
| 22 | 22 | } | ... | ... | 
models/role.go
| ... | ... | @@ -132,6 +132,9 @@ func (m *RoleModel) InitRole() { | 
| 132 | 132 | t4.Id = m.IncreTeamByKey(1) | 
| 133 | 133 | m.AddTeam(&t4) | 
| 134 | 134 | |
| 135 | + //init limit | |
| 136 | + m.UpdateProperties(map[string]interface{}{"clotheslimit": 100, "weaponslimit": 100, "otherlimit": 100}, false) | |
| 137 | + | |
| 135 | 138 | m.Update() | 
| 136 | 139 | } | 
| 137 | 140 | |
| ... | ... | @@ -161,7 +164,7 @@ func (m *RoleModel) LoadTeams() { | 
| 161 | 164 | |
| 162 | 165 | //加载背包数据到内存 | 
| 163 | 166 | func (m *RoleModel) LoadItems() { | 
| 164 | - m.Items = common.StringToMap(m.Role.Items) | |
| 167 | + m.Items = common.StringToMap(m.Role.Items, true) | |
| 165 | 168 | } | 
| 166 | 169 | |
| 167 | 170 | func (m *RoleModel) LoadEquipments() { | ... | ... | 
models/rolePlugin.go
pb/game.pb.go
| ... | ... | @@ -514,6 +514,7 @@ func (x *RoleUpdateItemsRsp) GetItems() string { | 
| 514 | 514 | return "" | 
| 515 | 515 | } | 
| 516 | 516 | |
| 517 | +//ResponseCmd RoleClearItemsReq | |
| 517 | 518 | type RoleClearItemsReq struct { | 
| 518 | 519 | state protoimpl.MessageState | 
| 519 | 520 | sizeCache protoimpl.SizeCache | 
| ... | ... | @@ -569,6 +570,7 @@ func (x *RoleClearItemsReq) GetCount() int32 { | 
| 569 | 570 | return 0 | 
| 570 | 571 | } | 
| 571 | 572 | |
| 573 | +//ResponseCmd EquipmentDelReq | |
| 572 | 574 | type EquipmentDelReq struct { | 
| 573 | 575 | state protoimpl.MessageState | 
| 574 | 576 | sizeCache protoimpl.SizeCache | ... | ... | 
pb/models.pb.go
| ... | ... | @@ -459,19 +459,22 @@ type Role struct { | 
| 459 | 459 | sizeCache protoimpl.SizeCache | 
| 460 | 460 | unknownFields protoimpl.UnknownFields | 
| 461 | 461 | |
| 462 | - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" | |
| 463 | - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty" index:"unique"` // @inject_tag: index:"unique" | |
| 464 | - Device string `protobuf:"bytes,3,opt,name=device,proto3" json:"device,omitempty"` | |
| 465 | - Nick string `protobuf:"bytes,4,opt,name=nick,proto3" json:"nick,omitempty"` | |
| 466 | - Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"` | |
| 467 | - Exp int64 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"` | |
| 468 | - Hp int64 `protobuf:"varint,7,opt,name=hp,proto3" json:"hp,omitempty"` | |
| 469 | - HpMax int64 `protobuf:"varint,8,opt,name=hp_max,json=hpMax,proto3" json:"hp_max,omitempty"` | |
| 470 | - BuyR string `protobuf:"bytes,11,opt,name=buy_r,json=buyR,proto3" json:"buy_r,omitempty"` | |
| 471 | - PayR string `protobuf:"bytes,12,opt,name=pay_r,json=payR,proto3" json:"pay_r,omitempty"` | |
| 472 | - Del bool `protobuf:"varint,13,opt,name=del,proto3" json:"del,omitempty"` | |
| 473 | - 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"` | |
| 474 | - Items string `protobuf:"bytes,15,opt,name=items,proto3" json:"items,omitempty"` //物品 "id=count id2=count2" | |
| 462 | + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" | |
| 463 | + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty" index:"unique"` // @inject_tag: index:"unique" | |
| 464 | + Device string `protobuf:"bytes,3,opt,name=device,proto3" json:"device,omitempty"` | |
| 465 | + Nick string `protobuf:"bytes,4,opt,name=nick,proto3" json:"nick,omitempty"` | |
| 466 | + Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"` | |
| 467 | + Exp int64 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"` | |
| 468 | + Hp int64 `protobuf:"varint,7,opt,name=hp,proto3" json:"hp,omitempty"` | |
| 469 | + HpMax int64 `protobuf:"varint,8,opt,name=hp_max,json=hpMax,proto3" json:"hp_max,omitempty"` | |
| 470 | + BuyR string `protobuf:"bytes,11,opt,name=buy_r,json=buyR,proto3" json:"buy_r,omitempty"` | |
| 471 | + PayR string `protobuf:"bytes,12,opt,name=pay_r,json=payR,proto3" json:"pay_r,omitempty"` | |
| 472 | + Del bool `protobuf:"varint,13,opt,name=del,proto3" json:"del,omitempty"` | |
| 473 | + 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"` | |
| 474 | + Items string `protobuf:"bytes,15,opt,name=items,proto3" json:"items,omitempty"` //物品 "id=count id2=count2" | |
| 475 | + Clotheslimit uint32 `protobuf:"varint,16,opt,name=clotheslimit,proto3" json:"clotheslimit,omitempty"` | |
| 476 | + Weaponslimit uint32 `protobuf:"varint,17,opt,name=weaponslimit,proto3" json:"weaponslimit,omitempty"` | |
| 477 | + Otherlimit uint32 `protobuf:"varint,18,opt,name=otherlimit,proto3" json:"otherlimit,omitempty"` | |
| 475 | 478 | } | 
| 476 | 479 | |
| 477 | 480 | func (x *Role) Reset() { | 
| ... | ... | @@ -597,6 +600,27 @@ func (x *Role) GetItems() string { | 
| 597 | 600 | return "" | 
| 598 | 601 | } | 
| 599 | 602 | |
| 603 | +func (x *Role) GetClotheslimit() uint32 { | |
| 604 | + if x != nil { | |
| 605 | + return x.Clotheslimit | |
| 606 | + } | |
| 607 | + return 0 | |
| 608 | +} | |
| 609 | + | |
| 610 | +func (x *Role) GetWeaponslimit() uint32 { | |
| 611 | + if x != nil { | |
| 612 | + return x.Weaponslimit | |
| 613 | + } | |
| 614 | + return 0 | |
| 615 | +} | |
| 616 | + | |
| 617 | +func (x *Role) GetOtherlimit() uint32 { | |
| 618 | + if x != nil { | |
| 619 | + return x.Otherlimit | |
| 620 | + } | |
| 621 | + return 0 | |
| 622 | +} | |
| 623 | + | |
| 600 | 624 | var File_models_proto protoreflect.FileDescriptor | 
| 601 | 625 | |
| 602 | 626 | var file_models_proto_rawDesc = []byte{ | 
| ... | ... | @@ -642,7 +666,7 @@ var file_models_proto_rawDesc = []byte{ | 
| 642 | 666 | 0x49, 0x64, 0x33, 0x22, 0x2f, 0x0a, 0x09, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, | 
| 643 | 667 | 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, | 
| 644 | 668 | 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, | 
| 645 | - 0x03, 0x76, 0x61, 0x6c, 0x22, 0xe2, 0x02, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0e, 0x0a, | |
| 669 | + 0x03, 0x76, 0x61, 0x6c, 0x22, 0xca, 0x03, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0e, 0x0a, | |
| 646 | 670 | 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, | 
| 647 | 671 | 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, | 
| 648 | 672 | 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, | 
| ... | ... | @@ -660,12 +684,19 @@ var file_models_proto_rawDesc = []byte{ | 
| 660 | 684 | 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, | 
| 661 | 685 | 0x52, 0x6f, 0x6c, 0x65, 0x2e, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, | 
| 662 | 686 | 0x52, 0x06, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, | 
| 663 | - 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x1a, 0x39, | |
| 664 | - 0x0a, 0x0b, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, | |
| 665 | - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, | |
| 666 | - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, | |
| 667 | - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, | |
| 668 | - 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, | |
| 687 | + 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x22, | |
| 688 | + 0x0a, 0x0c, 0x63, 0x6c, 0x6f, 0x74, 0x68, 0x65, 0x73, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x10, | |
| 689 | + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x63, 0x6c, 0x6f, 0x74, 0x68, 0x65, 0x73, 0x6c, 0x69, 0x6d, | |
| 690 | + 0x69, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x77, 0x65, 0x61, 0x70, 0x6f, 0x6e, 0x73, 0x6c, 0x69, 0x6d, | |
| 691 | + 0x69, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x77, 0x65, 0x61, 0x70, 0x6f, 0x6e, | |
| 692 | + 0x73, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x6c, | |
| 693 | + 0x69, 0x6d, 0x69, 0x74, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6f, 0x74, 0x68, 0x65, | |
| 694 | + 0x72, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x1a, 0x39, 0x0a, 0x0b, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x73, | |
| 695 | + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, | |
| 696 | + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, | |
| 697 | + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, | |
| 698 | + 0x01, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, | |
| 699 | + 0x72, 0x6f, 0x74, 0x6f, 0x33, | |
| 669 | 700 | } | 
| 670 | 701 | |
| 671 | 702 | var ( | ... | ... |