From d756c4d933317aa7f21dad44044c4eb277231ab2 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 25 Aug 2023 11:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97=E5=9B=9E?= =?UTF-8?q?=E6=94=BE=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 3 + comm/imodule.go | 4 + modules/battlerecord/api.go | 29 ++++ modules/battlerecord/api_inquire.go | 39 +++++ modules/battlerecord/model.go | 106 ++++++++++++ modules/battlerecord/module.go | 77 +++++++++ modules/guildgve/api_challengefinish.go | 4 +- modules/guildgve/module.go | 5 + pb/activity_db.pb.go | 32 ++-- pb/battle_struct.pb.go | 53 +++--- pb/battlerecord_db.pb.go | 153 +++++++++++++++++ pb/battlerecord_msg.pb.go | 214 ++++++++++++++++++++++++ services/worker/main.go | 2 + 13 files changed, 684 insertions(+), 37 deletions(-) create mode 100644 modules/battlerecord/api.go create mode 100644 modules/battlerecord/api_inquire.go create mode 100644 modules/battlerecord/model.go create mode 100644 modules/battlerecord/module.go create mode 100644 pb/battlerecord_db.pb.go create mode 100644 pb/battlerecord_msg.pb.go diff --git a/comm/const.go b/comm/const.go index d7e616b27..4ce8c7df3 100644 --- a/comm/const.go +++ b/comm/const.go @@ -104,6 +104,7 @@ const ( ModulePushgiftbag core.M_Modules = "pushgiftbag" //推送礼包 ModulePuzzle core.M_Modules = "uigame" //小游戏 ModuleRobot core.M_Modules = "robot" //压测机器人 + ModuleBattleRecord core.M_Modules = "battlerecord" //战斗记录 ) // 数据表名定义处 @@ -356,6 +357,8 @@ const ( TableMainlineShop = "mainlineshop" TableMainlinetask = "mlinetask" + //战斗记录 + TableBattlerecord = "battlerecord" ) // RPC服务接口定义处 diff --git a/comm/imodule.go b/comm/imodule.go index cb886ab70..afbb3e41e 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -640,4 +640,8 @@ type ( IStonehenge interface { GmAddStoneEvent(uid string, eventid int32) } + //战斗记录模块 + IBattleRecord interface { + WrietBattleRecord(uid string, report *pb.BattleReport) + } ) diff --git a/modules/battlerecord/api.go b/modules/battlerecord/api.go new file mode 100644 index 000000000..f0fda4abd --- /dev/null +++ b/modules/battlerecord/api.go @@ -0,0 +1,29 @@ +package battlerecord + +import ( + "go_dreamfactory/modules" + + "go_dreamfactory/lego/base" + "go_dreamfactory/lego/core" +) + +/* +API +*/ +type apiComp struct { + modules.MCompGate + service base.IRPCXService + module *BattleRecord +} + +//组件初始化接口 +func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompGate.Init(service, module, comp, options) + this.module = module.(*BattleRecord) + return +} + +func (this *apiComp) Start() (err error) { + err = this.MCompGate.Start() + return +} diff --git a/modules/battlerecord/api_inquire.go b/modules/battlerecord/api_inquire.go new file mode 100644 index 000000000..bff746d1f --- /dev/null +++ b/modules/battlerecord/api_inquire.go @@ -0,0 +1,39 @@ +package battlerecord + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" +) + +//参数校验 +func (this *apiComp) InquireCheck(session comm.IUserSession, req *pb.BattleRecordInquireReq) (errdata *pb.ErrorData) { + if len(req.Bid) == 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + } + } + return +} + +///查询任务进度接口 +func (this *apiComp) Inquire(session comm.IUserSession, req *pb.BattleRecordInquireReq) (errdata *pb.ErrorData) { + var ( + record *pb.DBBattlePlayRecord + err error + ) + if errdata = this.InquireCheck(session, req); errdata != nil { + return + } + if record, err = this.module.model.inquire(req.Bid); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.String(), + Message: err.Error(), + } + return + } + + session.SendMsg(string(this.module.GetType()), "inquire", &pb.BattleRecordInquireResp{Record: record}) + return +} diff --git a/modules/battlerecord/model.go b/modules/battlerecord/model.go new file mode 100644 index 000000000..7061172a0 --- /dev/null +++ b/modules/battlerecord/model.go @@ -0,0 +1,106 @@ +package battlerecord + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/mgo" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + "go_dreamfactory/sys/db" + + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" +) + +type modelComp struct { + modules.MCompModel + module *BattleRecord +} + +func (this *modelComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.TableName = string(comm.TableBattlerecord) + err = this.MCompModel.Init(service, module, comp, options) + this.module = module.(*BattleRecord) + // uid 创建索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) + return +} + +func (this *modelComp) inquire(bid string) (result *pb.DBBattlePlayRecord, err error) { + result = &pb.DBBattlePlayRecord{} + if err = this.DBModel.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": bid}).Decode(result); err != nil { + this.module.Errorln(err) + return + } + return +} + +//插入记录 +func (this *modelComp) addRecord(result *pb.DBBattlePlayRecord) (err error) { + if _, err = this.DBModel.DB.InsertOne(core.SqlTable(this.TableName), result); err != nil { + this.module.Errorln(err) + return + } + return +} + +//获取记录模型对象 +func (this *modelComp) getrecordModel(uid string) (model *recordModel, err error) { + var m *db.DBModel + if db.IsCross() { + if m, err = this.module.GetDBModelByUid(uid, this.TableName); err != nil { + return + } + model = &recordModel{module: this.module, model: m} + } else { + model = &recordModel{module: this.module, model: this.DBModel} + } + return +} + +// 埋点专属模型 会封装特殊的数据转换接口 +type recordModel struct { + module *BattleRecord + model *db.DBModel +} + +// 获取用户全部的埋点数据 +func (this *recordModel) getUserBurieds(uid string) (results *pb.DBBuried, err error) { + results = &pb.DBBuried{} + if err = this.model.Get(uid, results); err != nil && err != mgo.MongodbNil { + this.module.Errorln(err) + return + } + if err == mgo.MongodbNil { + err = nil + results = &pb.DBBuried{ + Id: primitive.NewObjectID().Hex(), + Uid: uid, + Items: make(map[int32]*pb.DBBuriedItem), + } + err = this.model.Add(uid, results) + } + return +} + +func (this *recordModel) inquire(bid string) (result *pb.DBBattlePlayRecord, err error) { + result = &pb.DBBattlePlayRecord{} + if err = this.model.DB.FindOne(core.SqlTable(this.model.TableName), bson.M{"_id": bid}).Decode(result); err != nil { + this.module.Errorln(err) + return + } + return +} + +//插入记录 +func (this *recordModel) addRecord(result *pb.DBBattlePlayRecord) (err error) { + if _, err = this.model.DB.InsertOne(core.SqlTable(this.model.TableName), result); err != nil { + this.module.Errorln(err) + return + } + return +} diff --git a/modules/battlerecord/module.go b/modules/battlerecord/module.go new file mode 100644 index 000000000..820007871 --- /dev/null +++ b/modules/battlerecord/module.go @@ -0,0 +1,77 @@ +package battlerecord + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +/* +模块名:用户埋点完成条件触发系统 +模块描述:用户埋点数据中心管理模块 +开发人员:李伟 +*/ + +const moduleName = "埋点统计中心" + +type BattleRecord struct { + modules.ModuleBase + api *apiComp + model *modelComp +} + +func NewModule() core.IModule { + return &BattleRecord{} +} + +func (this *BattleRecord) GetType() core.M_Modules { + return comm.ModuleBattleRecord +} + +func (this *BattleRecord) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { + err = this.ModuleBase.Init(service, module, options) + return +} + +// 装备组件 +func (this *BattleRecord) OnInstallComp() { + this.ModuleBase.OnInstallComp() + + this.api = this.RegisterComp(new(apiComp)).(*apiComp) + this.model = this.RegisterComp(new(modelComp)).(*modelComp) +} + +func (this *BattleRecord) Start() (err error) { + err = this.ModuleBase.Start() + return +} + +//写入战斗记录 +func (this *BattleRecord) WrietBattleRecord(uid string, report *pb.BattleReport) { + var ( + result *pb.DBBattlePlayRecord + model *recordModel + data []byte + err error + ) + if data, err = proto.Marshal(report); err == nil { + this.Errorln(err) + return + } + result = &pb.DBBattlePlayRecord{ + Id: report.Info.Id, + Record: data, + } + if model, err = this.model.getrecordModel(uid); err != nil { + this.Errorln(err) + return + } + if err = model.addRecord(result); err != nil { + this.Errorln(err) + return + } + return +} diff --git a/modules/guildgve/api_challengefinish.go b/modules/guildgve/api_challengefinish.go index 71c31d1d7..86b4a9823 100644 --- a/modules/guildgve/api_challengefinish.go +++ b/modules/guildgve/api_challengefinish.go @@ -113,6 +113,7 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.GuildGve }, Formation: make([]*pb.DBSimpleHero, 0), Time: configure.Now().Unix(), + FightId: req.Report.Info.Id, FightTime: req.Report.Costtime, Rating: score.Id, Harm: req.Report.Harm, @@ -182,7 +183,8 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.GuildGve return } } - + //写入战斗记录 + go this.module.battlerecord.WrietBattleRecord(session.GetUserId(), req.Report) session.SendMsg(string(this.module.GetType()), "challengefinish", &pb.GuildGveChallengeFinishResp{ Guildid: req.Guildid, Boosid: req.Boosid, diff --git a/modules/guildgve/module.go b/modules/guildgve/module.go index 4072c1a38..d7ab80f0c 100644 --- a/modules/guildgve/module.go +++ b/modules/guildgve/module.go @@ -19,6 +19,7 @@ type GuildGve struct { sociaty comm.ISociaty mail comm.Imail battle comm.IBattle + battlerecord comm.IBattleRecord api *apiComp modelGuildGve *ModelUniongve modelUnionroulette *ModelUnionroulette @@ -54,6 +55,10 @@ func (this *GuildGve) Start() (err error) { return } this.battle = module.(comm.IBattle) + if module, err = this.service.GetModule(comm.ModuleBattleRecord); err != nil { + return + } + this.battlerecord = module.(comm.IBattleRecord) this.service.RegisterFunctionName(string(comm.Rpc_ModuleGuildBossSettlement), this.Rpc_ModuleGuildBossSettlement) return } diff --git a/pb/activity_db.pb.go b/pb/activity_db.pb.go index f9ce5ad5f..7a741fd34 100644 --- a/pb/activity_db.pb.go +++ b/pb/activity_db.pb.go @@ -32,6 +32,7 @@ const ( HdType_XSFundExp HdType = 6 //现时活动 经验基金 HdType_HdLevel HdType = 7 //开服等级活动 HdType_HdTypeSign HdType = 8 //七日签到 + HdType_HdTypeDraw HdType = 9 //圣桃招募 HdType_AddUpRecharge HdType = 10 //累计充值 HdType_ShopCenterPayPakcge HdType = 11 //活动中心限时礼包 HdType_SupplyWarOrder HdType = 12 //补给战令 @@ -56,6 +57,7 @@ var ( 6: "XSFundExp", 7: "HdLevel", 8: "HdTypeSign", + 9: "HdTypeDraw", 10: "AddUpRecharge", 11: "ShopCenterPayPakcge", 12: "SupplyWarOrder", @@ -76,6 +78,7 @@ var ( "XSFundExp": 6, "HdLevel": 7, "HdTypeSign": 8, + "HdTypeDraw": 9, "AddUpRecharge": 10, "ShopCenterPayPakcge": 11, "SupplyWarOrder": 12, @@ -223,12 +226,12 @@ type DBHuodong struct { unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Rtime int64 `protobuf:"varint,3,opt,name=rtime,proto3" json:"rtime"` // 活动修改时间 - Itype HdType `protobuf:"varint,4,opt,name=itype,proto3,enum=HdType" json:"itype"` - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name"` - Etime int64 `protobuf:"varint,6,opt,name=etime,proto3" json:"etime"` // 1680105599, - Stime int64 `protobuf:"varint,7,opt,name=stime,proto3" json:"stime"` // 1679414400, - Data *ActivityInfo `protobuf:"bytes,8,opt,name=data,proto3" json:"data"` // 活动详细数据 + Rtime int64 `protobuf:"varint,2,opt,name=rtime,proto3" json:"rtime"` // 活动修改时间 + Itype HdType `protobuf:"varint,3,opt,name=itype,proto3,enum=HdType" json:"itype"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name"` + Etime int64 `protobuf:"varint,5,opt,name=etime,proto3" json:"etime"` // 1680105599, + Stime int64 `protobuf:"varint,6,opt,name=stime,proto3" json:"stime"` // 1679414400, + Data *ActivityInfo `protobuf:"bytes,7,opt,name=data,proto3" json:"data"` // 活动详细数据 } func (x *DBHuodong) Reset() { @@ -414,14 +417,14 @@ var file_activity_activity_db_proto_rawDesc = []byte{ 0x03, 0x28, 0x0b, 0x32, 0x04, 0x2e, 0x41, 0x72, 0x72, 0x52, 0x05, 0x70, 0x72, 0x69, 0x7a, 0x65, 0x22, 0xb3, 0x01, 0x0a, 0x09, 0x44, 0x42, 0x48, 0x75, 0x6f, 0x64, 0x6f, 0x6e, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x72, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x05, 0x69, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, + 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x72, + 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x05, 0x69, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x07, 0x2e, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x69, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, 0x74, - 0x69, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, 0x74, + 0x69, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xe6, 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, @@ -438,7 +441,7 @@ var file_activity_activity_db_proto_rawDesc = []byte{ 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, - 0xcd, 0x02, 0x0a, 0x06, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x48, 0x64, + 0xdd, 0x02, 0x0a, 0x06, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x50, 0x61, 0x79, 0x10, 0x02, 0x12, 0x0f, 0x0a, @@ -448,7 +451,8 @@ var file_activity_activity_db_proto_rawDesc = []byte{ 0x75, 0x69, 0x74, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, 0x58, 0x53, 0x46, 0x75, 0x6e, 0x64, 0x45, 0x78, 0x70, 0x10, 0x06, 0x12, 0x0b, 0x0a, 0x07, 0x48, 0x64, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x10, 0x07, 0x12, 0x0e, 0x0a, 0x0a, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x10, - 0x08, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x55, 0x70, 0x52, 0x65, 0x63, 0x68, 0x61, 0x72, + 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x48, 0x64, 0x54, 0x79, 0x70, 0x65, 0x44, 0x72, 0x61, 0x77, 0x10, + 0x09, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x55, 0x70, 0x52, 0x65, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x0a, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x68, 0x6f, 0x70, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x50, 0x61, 0x79, 0x50, 0x61, 0x6b, 0x63, 0x67, 0x65, 0x10, 0x0b, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x57, 0x61, 0x72, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x10, diff --git a/pb/battle_struct.pb.go b/pb/battle_struct.pb.go index 3fa353230..68baaa583 100644 --- a/pb/battle_struct.pb.go +++ b/pb/battle_struct.pb.go @@ -24,30 +24,34 @@ type EffectTipsType int32 const ( EffectTipsType_Eff_Success EffectTipsType = 0 - EffectTipsType_Not_Success EffectTipsType = 1 //没有成功 - EffectTipsType_Immunity EffectTipsType = 2 //免疫 - EffectTipsType_Resist EffectTipsType = 3 //抵抗 - EffectTipsType_Not_Gain EffectTipsType = 4 //无法获得增益 - EffectTipsType_Not_Control EffectTipsType = 5 //免疫控制 - EffectTipsType_Not_Action EffectTipsType = 6 //无法行动 - EffectTipsType_Purification EffectTipsType = 7 //净化 - EffectTipsType_Disperse EffectTipsType = 8 //驱散 - EffectTipsType_Gain_round EffectTipsType = 9 //获得回合 + EffectTipsType_Not_Success EffectTipsType = 1 //没有成功 + EffectTipsType_Immunity EffectTipsType = 2 //免疫 + EffectTipsType_Resist EffectTipsType = 3 //抵抗 + EffectTipsType_Not_Gain EffectTipsType = 4 //无法获得增益 + EffectTipsType_Not_Control EffectTipsType = 5 //免疫控制 + EffectTipsType_Not_Action EffectTipsType = 6 //无法行动 + EffectTipsType_Purification EffectTipsType = 7 //净化 + EffectTipsType_Disperse EffectTipsType = 8 //驱散 + EffectTipsType_Gain_round EffectTipsType = 9 //获得回合 + EffectTipsType_Add_Operate EffectTipsType = 10 //增加行动值 + EffectTipsType_Sub_Operate EffectTipsType = 11 //减少行动值 ) // Enum value maps for EffectTipsType. var ( EffectTipsType_name = map[int32]string{ - 0: "Eff_Success", - 1: "Not_Success", - 2: "Immunity", - 3: "Resist", - 4: "Not_Gain", - 5: "Not_Control", - 6: "Not_Action", - 7: "Purification", - 8: "Disperse", - 9: "Gain_round", + 0: "Eff_Success", + 1: "Not_Success", + 2: "Immunity", + 3: "Resist", + 4: "Not_Gain", + 5: "Not_Control", + 6: "Not_Action", + 7: "Purification", + 8: "Disperse", + 9: "Gain_round", + 10: "Add_Operate", + 11: "Sub_Operate", } EffectTipsType_value = map[string]int32{ "Eff_Success": 0, @@ -60,6 +64,8 @@ var ( "Purification": 7, "Disperse": 8, "Gain_round": 9, + "Add_Operate": 10, + "Sub_Operate": 11, } ) @@ -1856,7 +1862,7 @@ var file_battle_battle_struct_proto_rawDesc = []byte{ 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x75, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x75, 0x72, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x2a, 0xab, 0x01, 0x0a, 0x0e, 0x45, 0x66, 0x66, 0x65, 0x63, 0x74, 0x54, 0x69, 0x70, 0x73, + 0x65, 0x2a, 0xcd, 0x01, 0x0a, 0x0e, 0x45, 0x66, 0x66, 0x65, 0x63, 0x74, 0x54, 0x69, 0x70, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x45, 0x66, 0x66, 0x5f, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x6f, 0x74, 0x5f, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x6d, 0x6d, 0x75, 0x6e, 0x69, @@ -1866,8 +1872,11 @@ var file_battle_battle_struct_proto_rawDesc = []byte{ 0x0e, 0x0a, 0x0a, 0x4e, 0x6f, 0x74, 0x5f, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x75, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x07, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x65, 0x10, 0x08, 0x12, - 0x0e, 0x0a, 0x0a, 0x47, 0x61, 0x69, 0x6e, 0x5f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0x09, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0e, 0x0a, 0x0a, 0x47, 0x61, 0x69, 0x6e, 0x5f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0x09, 0x12, + 0x0f, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x5f, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x65, 0x10, 0x0a, + 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x75, 0x62, 0x5f, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x65, 0x10, + 0x0b, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/pb/battlerecord_db.pb.go b/pb/battlerecord_db.pb.go new file mode 100644 index 000000000..94a295180 --- /dev/null +++ b/pb/battlerecord_db.pb.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: battlerecord/battlerecord_db.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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) +) + +//战斗记录 +type DBBattlePlayRecord struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //@go_tags(`bson:"_id"`)战斗id + Record []byte `protobuf:"bytes,5,opt,name=record,proto3" json:"record"` //BattleReport 的序列化数据 +} + +func (x *DBBattlePlayRecord) Reset() { + *x = DBBattlePlayRecord{} + if protoimpl.UnsafeEnabled { + mi := &file_battlerecord_battlerecord_db_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBBattlePlayRecord) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBBattlePlayRecord) ProtoMessage() {} + +func (x *DBBattlePlayRecord) ProtoReflect() protoreflect.Message { + mi := &file_battlerecord_battlerecord_db_proto_msgTypes[0] + 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 DBBattlePlayRecord.ProtoReflect.Descriptor instead. +func (*DBBattlePlayRecord) Descriptor() ([]byte, []int) { + return file_battlerecord_battlerecord_db_proto_rawDescGZIP(), []int{0} +} + +func (x *DBBattlePlayRecord) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBBattlePlayRecord) GetRecord() []byte { + if x != nil { + return x.Record + } + return nil +} + +var File_battlerecord_battlerecord_db_proto protoreflect.FileDescriptor + +var file_battlerecord_battlerecord_db_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2f, 0x62, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x64, 0x62, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3c, 0x0a, 0x12, 0x44, 0x42, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, + 0x50, 0x6c, 0x61, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, + 0x63, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_battlerecord_battlerecord_db_proto_rawDescOnce sync.Once + file_battlerecord_battlerecord_db_proto_rawDescData = file_battlerecord_battlerecord_db_proto_rawDesc +) + +func file_battlerecord_battlerecord_db_proto_rawDescGZIP() []byte { + file_battlerecord_battlerecord_db_proto_rawDescOnce.Do(func() { + file_battlerecord_battlerecord_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_battlerecord_battlerecord_db_proto_rawDescData) + }) + return file_battlerecord_battlerecord_db_proto_rawDescData +} + +var file_battlerecord_battlerecord_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_battlerecord_battlerecord_db_proto_goTypes = []interface{}{ + (*DBBattlePlayRecord)(nil), // 0: DBBattlePlayRecord +} +var file_battlerecord_battlerecord_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_battlerecord_battlerecord_db_proto_init() } +func file_battlerecord_battlerecord_db_proto_init() { + if File_battlerecord_battlerecord_db_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_battlerecord_battlerecord_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBBattlePlayRecord); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_battlerecord_battlerecord_db_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_battlerecord_battlerecord_db_proto_goTypes, + DependencyIndexes: file_battlerecord_battlerecord_db_proto_depIdxs, + MessageInfos: file_battlerecord_battlerecord_db_proto_msgTypes, + }.Build() + File_battlerecord_battlerecord_db_proto = out.File + file_battlerecord_battlerecord_db_proto_rawDesc = nil + file_battlerecord_battlerecord_db_proto_goTypes = nil + file_battlerecord_battlerecord_db_proto_depIdxs = nil +} diff --git a/pb/battlerecord_msg.pb.go b/pb/battlerecord_msg.pb.go new file mode 100644 index 000000000..ebb31899c --- /dev/null +++ b/pb/battlerecord_msg.pb.go @@ -0,0 +1,214 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: battlerecord/battlerecord_msg.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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) +) + +//战斗记录查询请求 +type BattleRecordInquireReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Bid string `protobuf:"bytes,1,opt,name=bid,proto3" json:"bid"` +} + +func (x *BattleRecordInquireReq) Reset() { + *x = BattleRecordInquireReq{} + if protoimpl.UnsafeEnabled { + mi := &file_battlerecord_battlerecord_msg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BattleRecordInquireReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BattleRecordInquireReq) ProtoMessage() {} + +func (x *BattleRecordInquireReq) ProtoReflect() protoreflect.Message { + mi := &file_battlerecord_battlerecord_msg_proto_msgTypes[0] + 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 BattleRecordInquireReq.ProtoReflect.Descriptor instead. +func (*BattleRecordInquireReq) Descriptor() ([]byte, []int) { + return file_battlerecord_battlerecord_msg_proto_rawDescGZIP(), []int{0} +} + +func (x *BattleRecordInquireReq) GetBid() string { + if x != nil { + return x.Bid + } + return "" +} + +//战斗记录查询请求 +type BattleRecordInquireResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Record *DBBattlePlayRecord `protobuf:"bytes,1,opt,name=record,proto3" json:"record"` +} + +func (x *BattleRecordInquireResp) Reset() { + *x = BattleRecordInquireResp{} + if protoimpl.UnsafeEnabled { + mi := &file_battlerecord_battlerecord_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BattleRecordInquireResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BattleRecordInquireResp) ProtoMessage() {} + +func (x *BattleRecordInquireResp) ProtoReflect() protoreflect.Message { + mi := &file_battlerecord_battlerecord_msg_proto_msgTypes[1] + 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 BattleRecordInquireResp.ProtoReflect.Descriptor instead. +func (*BattleRecordInquireResp) Descriptor() ([]byte, []int) { + return file_battlerecord_battlerecord_msg_proto_rawDescGZIP(), []int{1} +} + +func (x *BattleRecordInquireResp) GetRecord() *DBBattlePlayRecord { + if x != nil { + return x.Record + } + return nil +} + +var File_battlerecord_battlerecord_msg_proto protoreflect.FileDescriptor + +var file_battlerecord_battlerecord_msg_proto_rawDesc = []byte{ + 0x0a, 0x23, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2f, 0x62, + 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x6d, 0x73, 0x67, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x22, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, + 0x6f, 0x72, 0x64, 0x2f, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2a, 0x0a, 0x16, 0x42, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x49, 0x6e, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x62, 0x69, 0x64, 0x22, 0x46, 0x0a, 0x17, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x49, 0x6e, 0x71, 0x75, 0x69, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x2b, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x13, 0x2e, 0x44, 0x42, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_battlerecord_battlerecord_msg_proto_rawDescOnce sync.Once + file_battlerecord_battlerecord_msg_proto_rawDescData = file_battlerecord_battlerecord_msg_proto_rawDesc +) + +func file_battlerecord_battlerecord_msg_proto_rawDescGZIP() []byte { + file_battlerecord_battlerecord_msg_proto_rawDescOnce.Do(func() { + file_battlerecord_battlerecord_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_battlerecord_battlerecord_msg_proto_rawDescData) + }) + return file_battlerecord_battlerecord_msg_proto_rawDescData +} + +var file_battlerecord_battlerecord_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_battlerecord_battlerecord_msg_proto_goTypes = []interface{}{ + (*BattleRecordInquireReq)(nil), // 0: BattleRecordInquireReq + (*BattleRecordInquireResp)(nil), // 1: BattleRecordInquireResp + (*DBBattlePlayRecord)(nil), // 2: DBBattlePlayRecord +} +var file_battlerecord_battlerecord_msg_proto_depIdxs = []int32{ + 2, // 0: BattleRecordInquireResp.record:type_name -> DBBattlePlayRecord + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_battlerecord_battlerecord_msg_proto_init() } +func file_battlerecord_battlerecord_msg_proto_init() { + if File_battlerecord_battlerecord_msg_proto != nil { + return + } + file_battlerecord_battlerecord_db_proto_init() + if !protoimpl.UnsafeEnabled { + file_battlerecord_battlerecord_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BattleRecordInquireReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_battlerecord_battlerecord_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BattleRecordInquireResp); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_battlerecord_battlerecord_msg_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_battlerecord_battlerecord_msg_proto_goTypes, + DependencyIndexes: file_battlerecord_battlerecord_msg_proto_depIdxs, + MessageInfos: file_battlerecord_battlerecord_msg_proto_msgTypes, + }.Build() + File_battlerecord_battlerecord_msg_proto = out.File + file_battlerecord_battlerecord_msg_proto_rawDesc = nil + file_battlerecord_battlerecord_msg_proto_goTypes = nil + file_battlerecord_battlerecord_msg_proto_depIdxs = nil +} diff --git a/services/worker/main.go b/services/worker/main.go index 9520e364c..ec9e84f9d 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -9,6 +9,7 @@ import ( "go_dreamfactory/modules/arena" "go_dreamfactory/modules/atlas" "go_dreamfactory/modules/battle" + "go_dreamfactory/modules/battlerecord" "go_dreamfactory/modules/buried" "go_dreamfactory/modules/caravan" "go_dreamfactory/modules/chat" @@ -154,6 +155,7 @@ func main() { storyline.NewModule(), pushgiftbag.NewModule(), uigame.NewModule(), + battlerecord.NewModule(), ) }