diff --git a/comm/imodule.go b/comm/imodule.go index 75088af9f..3d7066158 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -175,7 +175,7 @@ type ( ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息 QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息 //QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息 - AddHeroFetterData(session IUserSession, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息 + AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息 } //月子秘境 IMoonFantasy interface { diff --git a/modules/hero/module.go b/modules/hero/module.go index 7059d88ae..ddd54c9bb 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -67,9 +67,9 @@ func (this *Hero) CreateHeroes(uid string, heroCfgId ...string) error { func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32, bPush bool) (code pb.ErrorCode) { _hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num) if err == nil { - this.moduleFetter.AddHeroFetterData(session, heroCfgId) - go func(uid string, heroCfgId string) { // 携程处理 图鉴数据 + go func(uid string, heroCfgId string) { // 携程处理 图鉴数据 + this.moduleFetter.AddHeroFetterData(uid, heroCfgId) if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil { initUpdate := map[string]interface{}{} sz := result.GetTujian() @@ -238,59 +238,17 @@ func (this *Hero) EventUserOffline(session comm.IUserSession) { // 批量创建多个英雄 func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (code pb.ErrorCode) { - changeHero := make([]*pb.DBHero, 0) for heroCfgId, num := range heros { if num == 0 { // 数量为0 不做处理 continue } - hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num) - if err != nil { - code = pb.ErrorCode_HeroCreate - continue - } - changeHero = append(changeHero, hero) - // 查品质 - cfg := this.configure.GetHeroConfig(heroCfgId) - if cfg != nil { - - this.ModuleRtask.SendToRtask(session, comm.Rtype30, 1, cfg.Color) - this.ModuleRtask.SendToRtask(session, comm.Rtype31, 1, cfg.Color) + if code = this.CreateRepeatHero(session, heroCfgId, num, bPush); code != pb.ErrorCode_Success { + this.Errorf("create hero %s failed", heroCfgId) } } - for k := range heros { - this.moduleFetter.AddHeroFetterData(session, k) - } - // 添加图鉴 - go func(uid string, heros map[string]int32) { // 携程处理 图鉴数据 - if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil { - initUpdate := map[string]interface{}{} - sz := result.GetTujian() - if len(sz) == 0 { - sz = make(map[string]int32, 0) - } - for k := range heros { - - if _, ok := result.GetTujian()[k]; !ok { - sz[k] = 0 - initUpdate["tujian"] = sz - } - } - if len(initUpdate) != 0 { - this.ModuleUser.ChangeUserExpand(uid, initUpdate) - } - } - }(session.GetUserId(), heros) - for k := range heros { // 任务统计 - this.ModuleRtask.SendToRtask(session, comm.Rtype1, utils.ToInt32(k)) - - } - - if bPush && len(changeHero) > 0 { //推送 - session.SendMsg("hero", "change", &pb.HeroChangePush{List: changeHero}) - } - return } + func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp int32) (code pb.ErrorCode) { var ( _hero *pb.DBHero diff --git a/modules/library/module.go b/modules/library/module.go index 83fb10b23..4052f1631 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -103,9 +103,9 @@ func (this *Library) GetHeroFetterList(uid string) []*pb.DBHeroFetter { } // 创建一条英雄羁绊信息 -func (this *Library) createHeroFetter(uid string, heroConfId string) (code pb.ErrorCode) { +func (this *Library) createHeroFetter(uid string, heroConfId string) (obj *pb.DBHeroFetter, code pb.ErrorCode) { this.modelFetter.getHeroFetterList(uid) - obj := &pb.DBHeroFetter{ + obj = &pb.DBHeroFetter{ Id: primitive.NewObjectID().Hex(), Uid: uid, Heroid: heroConfId, @@ -135,14 +135,17 @@ func (this *Library) QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter } // 创建一条羁绊信息 -func (this *Library) AddHeroFetterData(session comm.IUserSession, heroConfId string) (code pb.ErrorCode) { - uid := session.GetUserId() +func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) { // 推送 rsp := &pb.LibraryChangePush{} _data := this.QueryOneHeroFetter(uid, heroConfId) this.Debugf("%v", _data) if _data == nil { - this.createHeroFetter(uid, heroConfId) + objFetter, c := this.createHeroFetter(uid, heroConfId) + if c != pb.ErrorCode_Success { + code = c + this.Errorf("createHeroFetter failed:%v,uid:%s,heroid:%s", code, uid, heroConfId) + } _conf := this.configure.GetLibraryHero(heroConfId) if _conf != nil { szFid := _conf.Fid @@ -150,9 +153,10 @@ func (this *Library) AddHeroFetterData(session comm.IUserSession, heroConfId str // 查询是否存在这个羁绊对象 obj := this.GetLibraryListByFid(uid, fid) if obj == nil { // 没有羁绊信息 - this.createHeroFetter(uid, heroConfId) code, obj = this.CreateLibrary(uid, fid, heroConfId) - + if code != pb.ErrorCode_Success { + this.Errorf("CreateLibrary failed: %v,uid:%s,fid:%d", code, uid, fid) + } } else { // 羁绊信息中没有这个heroid 也需要加进来 for k, v := range obj.Hero { if v == 0 && k == heroConfId { @@ -175,8 +179,9 @@ func (this *Library) AddHeroFetterData(session comm.IUserSession, heroConfId str } rsp.Data = append(rsp.Data, obj) } - session.SendMsg(string(this.GetType()), LibraryChangePush, rsp) } + rsp.Fetter = append(rsp.Fetter, objFetter) + this.SendMsgToUser(string(this.GetType()), LibraryChangePush, rsp, uid) } return diff --git a/pb/library_msg.pb.go b/pb/library_msg.pb.go index 2c1403e8b..d13d53f65 100644 --- a/pb/library_msg.pb.go +++ b/pb/library_msg.pb.go @@ -610,7 +610,8 @@ type LibraryChangePush struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data []*DBLibrary `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` + Data []*DBLibrary `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` + Fetter []*DBHeroFetter `protobuf:"bytes,2,rep,name=fetter,proto3" json:"fetter"` // 羁绊详细信息 } func (x *LibraryChangePush) Reset() { @@ -652,6 +653,13 @@ func (x *LibraryChangePush) GetData() []*DBLibrary { return nil } +func (x *LibraryChangePush) GetFetter() []*DBHeroFetter { + if x != nil { + return x.Fetter + } + return nil +} + var File_library_library_msg_proto protoreflect.FileDescriptor var file_library_library_msg_proto_rawDesc = []byte{ @@ -707,11 +715,13 @@ var file_library_library_msg_proto_rawDesc = []byte{ 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x65, 0x74, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x22, 0x33, 0x0a, 0x11, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x43, 0x68, 0x61, 0x6e, + 0x61, 0x22, 0x5a, 0x0a, 0x11, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x25, 0x0a, 0x06, 0x66, 0x65, 0x74, 0x74, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x46, + 0x65, 0x74, 0x74, 0x65, 0x72, 0x52, 0x06, 0x66, 0x65, 0x74, 0x74, 0x65, 0x72, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -754,11 +764,12 @@ var file_library_library_msg_proto_depIdxs = []int32{ 15, // 5: LibraryUseGiftResp.data:type_name -> DBHeroFetter 14, // 6: LibraryActivationFetterResp.data:type_name -> DBLibrary 14, // 7: LibraryChangePush.data:type_name -> DBLibrary - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 15, // 8: LibraryChangePush.fetter:type_name -> DBHeroFetter + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_library_library_msg_proto_init() }