From 76de1d72455980347aad2d51c1908efe30e2a5e6 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 14 Jul 2022 14:19:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- modules/mgolog/core.go | 8 --- modules/mgolog/db_comp.go | 18 ++--- modules/modulebase.go | 12 ++-- modules/story/api_challenge.go | 8 ++- modules/user/module.go | 7 ++ pb/errorcode.pb.go | 40 ++++++----- pb/forum_db.pb.go | 61 ++++++++++++++++ pb/forum_msg.pb.go | 61 ++++++++++++++++ pb/proto/errorcode.proto | 1 + pb/proto/user/user_msg.proto | 6 ++ pb/user_msg.pb.go | 128 +++++++++++++++++++++++++++------ 12 files changed, 289 insertions(+), 63 deletions(-) create mode 100644 pb/forum_db.pb.go create mode 100644 pb/forum_msg.pb.go diff --git a/go.mod b/go.mod index dcf8ab70c..1e76dec98 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/hashicorp/consul/api v1.12.0 github.com/json-iterator/go v1.1.12 github.com/mitchellh/hashstructure v1.1.0 + github.com/modern-go/reflect2 v1.0.2 github.com/nacos-group/nacos-sdk-go v1.0.8 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 @@ -95,7 +96,6 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/philhofer/fwd v1.1.1 // indirect diff --git a/modules/mgolog/core.go b/modules/mgolog/core.go index 56bc17551..4cb2501b6 100644 --- a/modules/mgolog/core.go +++ b/modules/mgolog/core.go @@ -1,9 +1,5 @@ package mgolog -import ( - "go_dreamfactory/lego/core" -) - const ( WriteMaxNum uint32 = 1000 //一次性最处理条数 ErrorMaxNum uint32 = 5 // 数据库操作最大失败次数 @@ -13,7 +9,3 @@ const ( var ( ErrorLogCount = make(map[string]uint32, 0) ) - -const ( - DB_ModelTable core.SqlTable = "model_log" -) diff --git a/modules/mgolog/db_comp.go b/modules/mgolog/db_comp.go index 858810e0e..0dd434bb1 100644 --- a/modules/mgolog/db_comp.go +++ b/modules/mgolog/db_comp.go @@ -22,7 +22,7 @@ type DB_Comp struct { func (this *DB_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.MCompModel.Init(service, module, comp, options) this.task = make(chan string, TaskMaxNum) - + this.TableName = "model_log" return } @@ -60,12 +60,12 @@ func (this *DB_Comp) PushUserTask(uid string) { func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { var _data *mongo.Cursor if uid == "" { - _data, err = this.DB.Find(DB_ModelTable, bson.M{}, options.Find().SetLimit(int64(WriteMaxNum))) + _data, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{}, options.Find().SetLimit(int64(WriteMaxNum))) if err != nil { return err } } else { - _data, err = this.DB.Find(DB_ModelTable, bson.M{"uid": uid}, options.Find()) + _data, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}, options.Find()) if err != nil { return err } @@ -97,7 +97,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { ErrorLogCount[data.ID]++ if ErrorLogCount[data.ID] >= ErrorMaxNum { // 实在是写失败了那就删除吧 log.Errorf("insert db err max num %s db err:%v", data.ID, err) - _, err = this.DB.DeleteOne(DB_ModelTable, bson.M{"_id": data.ID}) + _, err = this.DB.DeleteOne(core.SqlTable(this.TableName), bson.M{"_id": data.ID}) if err != nil { log.Errorf("insert %s db err:%+v", data.ID, err) } @@ -125,7 +125,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { ErrorLogCount[data.ID]++ if ErrorLogCount[data.ID] >= ErrorMaxNum { // 实在是写失败了那就删除吧 log.Errorf("del db err max num %s db err:%v", data.ID, err) - _, err = this.DB.DeleteOne(DB_ModelTable, bson.M{"_id": data.ID}) + _, err = this.DB.DeleteOne(core.SqlTable(this.TableName), bson.M{"_id": data.ID}) if err != nil { log.Errorf("insert %s db err:%+v", data.ID, err) } @@ -154,7 +154,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { ErrorLogCount[data.ID]++ if ErrorLogCount[data.ID] >= ErrorMaxNum { // 超过一定次数写失败了那就删除吧 log.Errorf("update db err max num %s db err:%v", data.ID, err) - _, err = this.DB.DeleteOne(DB_ModelTable, bson.M{"_id": data.ID}) + _, err = this.DB.DeleteOne(core.SqlTable(this.TableName), bson.M{"_id": data.ID}) if err != nil { log.Errorf("insert %s db err:%+v", data.ID, err) } @@ -166,7 +166,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { } if len(_delID) > 0 { - _, err = this.DB.DeleteMany(DB_ModelTable, bson.M{"_id": bson.M{"$in": _delID}}, options.Delete()) // 批量删除已处理的数据 + _, err = this.DB.DeleteMany(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": _delID}}, options.Delete()) // 批量删除已处理的数据 if err != nil { log.Errorf("del err %v", err) } @@ -178,7 +178,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { // 写入日志数据 func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { - _, err = this.DB.InsertOne(DB_ModelTable, data) + _, err = this.DB.InsertOne(core.SqlTable(this.TableName), data) if err != nil { log.Errorf("insert model db err %v", err) } @@ -188,7 +188,7 @@ func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { // 查询 当前日志列表还有没有处理完条数 func (this *DB_Comp) Model_TotalCount() int { - _data, err := this.DB.Find("DB_ModelTable", bson.M{}) + _data, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}) if err == nil { return _data.RemainingBatchLength() } diff --git a/modules/modulebase.go b/modules/modulebase.go index 52b611ccc..c1dd67e52 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -221,16 +221,20 @@ func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn) (code pb.Er } for _, v := range res { if v.A == comm.AttrType { //用户属性资源 - this.ModuleUser.AddAttributeValue(uid, v.T, v.N) + code = this.ModuleUser.AddAttributeValue(uid, v.T, v.N) + } else if v.A == comm.ItemType { //道具资源 resID, _ = strconv.Atoi(v.T) - this.ModuleItems.AddItem(source, uid, int32(resID), v.N) + code = this.ModuleItems.AddItem(source, uid, int32(resID), v.N) } else if v.A == comm.HeroType { //卡片资源 resID, _ = strconv.Atoi(v.T) - this.ModuleHero.CreateHero(uid, int32(resID), v.N) + err := this.ModuleHero.CreateHero(uid, int32(resID), v.N) + if err != nil { + code = pb.ErrorCode_HeroMaxCount + } } else if v.A == comm.EquipmentType { resID, _ = strconv.Atoi(v.T) - this.ModuleEquipment.AddNewEquipments(source, uid, map[int32]uint32{int32(resID): uint32(v.N)}) + code = this.ModuleEquipment.AddNewEquipments(source, uid, map[int32]uint32{int32(resID): uint32(v.N)}) } } return diff --git a/modules/story/api_challenge.go b/modules/story/api_challenge.go index 9af8faae7..da543d6db 100644 --- a/modules/story/api_challenge.go +++ b/modules/story/api_challenge.go @@ -2,6 +2,7 @@ package story import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/redis" "go_dreamfactory/pb" "sort" @@ -30,7 +31,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge return // 参数校验失败直接返回 } list, err := this.module.modelStory.getStoryList(session.GetUserId()) - if err != nil { + if err != nil && err != redis.RedisNil { code = pb.ErrorCode_DBError return } @@ -60,7 +61,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge _data.Id = primitive.NewObjectID().Hex() _data.ChapterId = int32(req.ChapterId) _mData := make(map[string]interface{}, 0) + _data.Uid = session.GetUserId() _mData[_data.Id] = _data + this.module.modelStory.addNewChapter(session.GetUserId(), _mData) curChapter = _data //curChapter.StoryId = chaptConfig.Fubendata[0] // 第一次挑战 @@ -94,6 +97,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge "branchID": curChapter.BranchID, } err = this.module.modelStory.modifyStoryData(session.GetUserId(), curChapter.Id, update) + } else { + code = pb.ErrorCode_ReqParameterError + return } // 发奖 (奖励数据还没配置,后续补充) session.SendMsg(string(this.module.GetType()), StoryChallengeResp, &pb.StoryChallengeResp{Data: curChapter}) diff --git a/modules/user/module.go b/modules/user/module.go index 69731a1b0..623d1c972 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -121,5 +121,12 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb log.Errorf("AddAttributeValue err:%v", err) code = pb.ErrorCode_DBError } + data := &pb.UserResChangePush{} + var _cache = &pb.CacheUser{} + err := this.modelUser.MCompModel.Get(uid, _cache) + if err != nil { + this.SendMsgToUser(string(this.GetType()), "addres", data, _cache) + } + return } diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index de79ceab6..1810a18bd 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -83,6 +83,7 @@ const ( ErrorCode_HeroEquipUpdate ErrorCode = 1311 // 更新装备失败 ErrorCode_HeroMaxAwaken ErrorCode = 1312 // 达到最大觉醒等级 ErrorCode_HeroIsLock ErrorCode = 1313 // 英雄被锁定不能被消耗 + ErrorCode_HeroMaxCount ErrorCode = 1314 // 英雄达到最大数量 // equipment ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器 ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限 @@ -158,6 +159,7 @@ var ( 1311: "HeroEquipUpdate", 1312: "HeroMaxAwaken", 1313: "HeroIsLock", + 1314: "HeroMaxCount", 1400: "EquipmentOnFoundEquipment", 1401: "EquipmentLvlimitReached", 1500: "StoryNotFindChapter", @@ -227,6 +229,7 @@ var ( "HeroEquipUpdate": 1311, "HeroMaxAwaken": 1312, "HeroIsLock": 1313, + "HeroMaxCount": 1314, "EquipmentOnFoundEquipment": 1400, "EquipmentLvlimitReached": 1401, "StoryNotFindChapter": 1500, @@ -272,7 +275,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xf4, 0x0a, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0x87, 0x0b, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -344,23 +347,24 @@ var file_errorcode_proto_rawDesc = []byte{ 0x45, 0x71, 0x75, 0x69, 0x70, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x10, 0x9f, 0x0a, 0x12, 0x12, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x41, 0x77, 0x61, 0x6b, 0x65, 0x6e, 0x10, 0xa0, 0x0a, 0x12, 0x0f, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x73, 0x4c, 0x6f, 0x63, 0x6b, - 0x10, 0xa1, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, - 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, - 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, - 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, - 0x0a, 0x12, 0x18, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x6f, 0x74, 0x46, 0x69, 0x6e, - 0x64, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x10, 0xdc, 0x0b, 0x12, 0x12, 0x0a, 0x0d, 0x53, - 0x74, 0x6f, 0x72, 0x79, 0x49, 0x44, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0xdd, 0x0b, 0x12, - 0x0d, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc0, 0x0c, 0x12, 0x0e, - 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x65, 0x74, 0x10, 0xc1, 0x0c, 0x12, 0x0f, - 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x10, 0xc2, 0x0c, 0x12, - 0x11, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x10, - 0xc3, 0x0c, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, - 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc6, 0x0c, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x41, - 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0xc4, 0x0c, 0x12, - 0x17, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x65, - 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xc5, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x10, 0xa1, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x10, 0xa2, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, + 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, + 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, + 0x64, 0x10, 0xf9, 0x0a, 0x12, 0x18, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x6f, 0x74, + 0x46, 0x69, 0x6e, 0x64, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x10, 0xdc, 0x0b, 0x12, 0x12, + 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x44, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, + 0xdd, 0x0b, 0x12, 0x0d, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc0, + 0x0c, 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x65, 0x74, 0x10, 0xc1, + 0x0c, 0x12, 0x0f, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x10, + 0xc2, 0x0c, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x64, 0x10, 0xc3, 0x0c, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, + 0x69, 0x76, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc6, 0x0c, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, + 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x10, + 0xc4, 0x0c, 0x12, 0x17, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, + 0x4e, 0x6f, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xc5, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/forum_db.pb.go b/pb/forum_db.pb.go new file mode 100644 index 000000000..fd88ace8b --- /dev/null +++ b/pb/forum_db.pb.go @@ -0,0 +1,61 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: forum/forum_db.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_forum_forum_db_proto protoreflect.FileDescriptor + +var file_forum_forum_db_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x2f, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x64, 0x62, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_forum_forum_db_proto_goTypes = []interface{}{} +var file_forum_forum_db_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_forum_forum_db_proto_init() } +func file_forum_forum_db_proto_init() { + if File_forum_forum_db_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_forum_forum_db_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_forum_forum_db_proto_goTypes, + DependencyIndexes: file_forum_forum_db_proto_depIdxs, + }.Build() + File_forum_forum_db_proto = out.File + file_forum_forum_db_proto_rawDesc = nil + file_forum_forum_db_proto_goTypes = nil + file_forum_forum_db_proto_depIdxs = nil +} diff --git a/pb/forum_msg.pb.go b/pb/forum_msg.pb.go new file mode 100644 index 000000000..253e5ff1c --- /dev/null +++ b/pb/forum_msg.pb.go @@ -0,0 +1,61 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: forum/forum_msg.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_forum_forum_msg_proto protoreflect.FileDescriptor + +var file_forum_forum_msg_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x2f, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x6d, 0x73, + 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_forum_forum_msg_proto_goTypes = []interface{}{} +var file_forum_forum_msg_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_forum_forum_msg_proto_init() } +func file_forum_forum_msg_proto_init() { + if File_forum_forum_msg_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_forum_forum_msg_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_forum_forum_msg_proto_goTypes, + DependencyIndexes: file_forum_forum_msg_proto_depIdxs, + }.Build() + File_forum_forum_msg_proto = out.File + file_forum_forum_msg_proto_rawDesc = nil + file_forum_forum_msg_proto_goTypes = nil + file_forum_forum_msg_proto_depIdxs = nil +} diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index 9f8b44fb9..19ad83a53 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -66,6 +66,7 @@ enum ErrorCode { HeroEquipUpdate = 1311; // 更新装备失败 HeroMaxAwaken = 1312; // 达到最大觉醒等级 HeroIsLock = 1313; // 英雄被锁定不能被消耗 + HeroMaxCount = 1314; // 英雄达到最大数量 // equipment EquipmentOnFoundEquipment = 1400; // 未找到武器 diff --git a/pb/proto/user/user_msg.proto b/pb/proto/user/user_msg.proto index 221e358e0..d7d5afec1 100644 --- a/pb/proto/user/user_msg.proto +++ b/pb/proto/user/user_msg.proto @@ -39,3 +39,9 @@ message UserAddResResp { UserAssets res = 1; //资源类型 } +// 玩家资源变更推送 +message UserResChangePush{ + int32 changeType = 1; // 变化类型 0 增加 1 减少 + int32 value = 2; + string resName = 3; // 资源名称 +} diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index 4115f7259..60c31b13c 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -461,6 +461,70 @@ func (x *UserAddResResp) GetRes() *UserAssets { return nil } +// 玩家资源变更推送 +type UserResChangePush struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ChangeType int32 `protobuf:"varint,1,opt,name=changeType,proto3" json:"changeType"` // 变化类型 0 增加 1 减少 + Value int32 `protobuf:"varint,2,opt,name=value,proto3" json:"value"` + ResName string `protobuf:"bytes,3,opt,name=resName,proto3" json:"resName"` // 资源名称 +} + +func (x *UserResChangePush) Reset() { + *x = UserResChangePush{} + if protoimpl.UnsafeEnabled { + mi := &file_user_user_msg_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserResChangePush) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserResChangePush) ProtoMessage() {} + +func (x *UserResChangePush) ProtoReflect() protoreflect.Message { + mi := &file_user_user_msg_proto_msgTypes[9] + 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 UserResChangePush.ProtoReflect.Descriptor instead. +func (*UserResChangePush) Descriptor() ([]byte, []int) { + return file_user_user_msg_proto_rawDescGZIP(), []int{9} +} + +func (x *UserResChangePush) GetChangeType() int32 { + if x != nil { + return x.ChangeType + } + return 0 +} + +func (x *UserResChangePush) GetValue() int32 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *UserResChangePush) GetResName() string { + if x != nil { + return x.ResName + } + return "" +} + var File_user_user_msg_proto protoreflect.FileDescriptor var file_user_user_msg_proto_rawDesc = []byte{ @@ -496,8 +560,15 @@ var file_user_user_msg_proto_rawDesc = []byte{ 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x2f, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x72, 0x65, 0x73, 0x22, 0x63, 0x0a, + 0x11, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75, + 0x73, 0x68, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x73, 0x4e, 0x61, + 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -512,28 +583,29 @@ func file_user_user_msg_proto_rawDescGZIP() []byte { return file_user_user_msg_proto_rawDescData } -var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_user_user_msg_proto_goTypes = []interface{}{ - (*UserLoginReq)(nil), // 0: UserLoginReq - (*UserLoginResp)(nil), // 1: UserLoginResp - (*UserRegisterReq)(nil), // 2: UserRegisterReq - (*UserRegisterResp)(nil), // 3: UserRegisterResp - (*UserLoadResp)(nil), // 4: UserLoadResp - (*UserCreateReq)(nil), // 5: UserCreateReq - (*UserCreateResp)(nil), // 6: UserCreateResp - (*UserAddResReq)(nil), // 7: UserAddResReq - (*UserAddResResp)(nil), // 8: UserAddResResp - (*DBUser)(nil), // 9: DBUser - (ErrorCode)(0), // 10: ErrorCode - (*CacheUser)(nil), // 11: CacheUser - (*UserAssets)(nil), // 12: UserAssets + (*UserLoginReq)(nil), // 0: UserLoginReq + (*UserLoginResp)(nil), // 1: UserLoginResp + (*UserRegisterReq)(nil), // 2: UserRegisterReq + (*UserRegisterResp)(nil), // 3: UserRegisterResp + (*UserLoadResp)(nil), // 4: UserLoadResp + (*UserCreateReq)(nil), // 5: UserCreateReq + (*UserCreateResp)(nil), // 6: UserCreateResp + (*UserAddResReq)(nil), // 7: UserAddResReq + (*UserAddResResp)(nil), // 8: UserAddResResp + (*UserResChangePush)(nil), // 9: UserResChangePush + (*DBUser)(nil), // 10: DBUser + (ErrorCode)(0), // 11: ErrorCode + (*CacheUser)(nil), // 12: CacheUser + (*UserAssets)(nil), // 13: UserAssets } var file_user_user_msg_proto_depIdxs = []int32{ - 9, // 0: UserLoginResp.data:type_name -> DBUser - 10, // 1: UserRegisterResp.Code:type_name -> ErrorCode - 11, // 2: UserLoadResp.data:type_name -> CacheUser - 12, // 3: UserAddResReq.res:type_name -> UserAssets - 12, // 4: UserAddResResp.res:type_name -> UserAssets + 10, // 0: UserLoginResp.data:type_name -> DBUser + 11, // 1: UserRegisterResp.Code:type_name -> ErrorCode + 12, // 2: UserLoadResp.data:type_name -> CacheUser + 13, // 3: UserAddResReq.res:type_name -> UserAssets + 13, // 4: UserAddResResp.res:type_name -> UserAssets 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 @@ -658,6 +730,18 @@ func file_user_user_msg_proto_init() { return nil } } + file_user_user_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserResChangePush); 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{ @@ -665,7 +749,7 @@ func file_user_user_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_user_user_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 9, + NumMessages: 10, NumExtensions: 0, NumServices: 0, },