diff --git a/comm/const.go b/comm/const.go index c32741ceb..3f52107d6 100644 --- a/comm/const.go +++ b/comm/const.go @@ -535,6 +535,12 @@ const ( Rtype138 TaskType = 138 //在线N分钟(从接到任务开始,记录玩家在线时间并记入进度) Rtype139 TaskType = 139 //通过融合获得指定英雄(从接到任务开始记录,通过融合获得指定英雄则任务完成) Rtype140 TaskType = 140 //关卡编辑器完成条件 + Rtype141 TaskType = 141 //成长任务接取抽卡 + Rtype142 TaskType = 142 //成长任务阵营接取抽卡 + Rtype143 TaskType = 143 //日常任务接取抽卡 + Rtype144 TaskType = 144 //日常任务阵营接取抽卡 + Rtype145 TaskType = 145 //周长任务接取抽卡 + Rtype146 TaskType = 146 //周长任务阵营接取抽卡 ) const ( diff --git a/comm/imodule.go b/comm/imodule.go index fa36a707f..f02827f01 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -45,7 +45,7 @@ type ( QueryHeroAmount(uId string, heroCfgId string) (amount uint32) //创建指定数量 - CreateRepeatHero(session IUserSession, heroCfgId string, num int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) + CreateRepeatHero(session IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) // 批量创建英雄 CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) // 获取英雄 diff --git a/modules/hero/api_fusion.go b/modules/hero/api_fusion.go index 8771dc1e1..0e87064e0 100644 --- a/modules/hero/api_fusion.go +++ b/modules/hero/api_fusion.go @@ -74,10 +74,11 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c } // 获得新卡 - if newHero, err := this.module.CreateRepeatHero(session, conf.Hero, 1, false); err == pb.ErrorCode_Success { - ChangeList = append(ChangeList, newHero) - session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: ChangeList}) - } else { + var new map[string]int32 + new = make(map[string]int32) + new[conf.Hero] = 1 + if _, err := this.module.CreateRepeatHeros(session, new, false); err != pb.ErrorCode_Success { + this.module.Errorf("err:%v,create hero:%s,uid,%ss", err, conf.Hero, session.GetUserId()) code = pb.ErrorCode_HeroCreate // 创建新英雄失败 } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 6aace33a9..00371d87c 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -836,9 +836,5 @@ func (this *ModelHero) resetTalentProperty(hero *pb.DBHero) { } } } - // _heroMap := make(map[string]interface{}, 0) - // _heroMap["talentProperty"] = hero.TalentProperty - // if err := this.ChangeList(hero.Uid, hero.Id, _heroMap); err != nil { - // this.moduleHero.Errorf("mergeenegryProperty err %v", err) - // } + } diff --git a/modules/hero/module.go b/modules/hero/module.go index c8137f047..8fd5dc640 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -71,7 +71,7 @@ func (this *Hero) Start() (err error) { } //创建单个叠加英雄 -func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) { +func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) { var err error hero, err = this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num) if err == nil { @@ -81,33 +81,6 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, } else { this.moduleFetter.AddHeroFetterData(session.GetUserId(), heroCfgId) } - heroConf := this.modelHero.moduleHero.configure.GetHeroConfig(heroCfgId) - if heroConf == nil { - return - } - - if result, err1 := this.ModuleUser.GetUserExpand(session.GetUserId()); err1 == nil { - initUpdate := map[string]interface{}{} - sz := result.GetTujian() - if len(sz) == 0 { - sz = make(map[string]int32, 0) - } - - if _, ok := result.GetTujian()[heroCfgId]; !ok { - if heroConf.Handbook == -1 { - sz[heroCfgId] = 0 - } else { - sz[heroCfgId] = 1 - } - - initUpdate["tujian"] = sz - this.ModuleUser.ChangeUserExpand(session.GetUserId(), initUpdate) - // 首次获得英雄 则推送 - session.SendMsg("hero", "firstget", &pb.HeroFirstGetPush{ - HeroId: heroCfgId, - }) - } - } //}(session.GetUserId(), heroCfgId) // 统计任务 this.ModuleRtask.SendToRtask(session, comm.Rtype1, utils.ToInt32(heroCfgId)) @@ -119,9 +92,6 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, this.ModuleRtask.SendToRtask(session, comm.Rtype31, 1, cfg.Color) } - if bPush { //推送 - session.SendMsg("hero", "change", &pb.HeroChangePush{List: []*pb.DBHero{hero}}) - } return } code = pb.ErrorCode_HeroCreate @@ -289,14 +259,52 @@ func (this *Hero) EventUserOffline(session comm.IUserSession) { // 批量创建多个英雄 func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) { + var ( + changeList []*pb.DBHero + firstGet []string + ) for heroCfgId, num := range heros { if num == 0 { // 数量为0 不做处理 continue } - if hero, code = this.CreateRepeatHero(session, heroCfgId, num, bPush); code != pb.ErrorCode_Success { + if hero, code = this.CreateRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success { this.Errorf("create hero %s failed", heroCfgId) + return } + if result, err1 := this.ModuleUser.GetUserExpand(session.GetUserId()); err1 == nil { + initUpdate := map[string]interface{}{} + sz := result.GetTujian() + if len(sz) == 0 { + sz = make(map[string]int32, 0) + } + + if _, ok := result.GetTujian()[heroCfgId]; !ok { + heroConf := this.modelHero.moduleHero.configure.GetHeroConfig(heroCfgId) + if heroConf != nil { + if heroConf.Handbook == -1 { + sz[heroCfgId] = 0 + } else { + sz[heroCfgId] = 1 + } + initUpdate["tujian"] = sz + this.ModuleUser.ChangeUserExpand(session.GetUserId(), initUpdate) + firstGet = append(firstGet, heroCfgId) + } + } + } + changeList = append(changeList, hero) } + + if bPush && len(changeList) > 0 { //推送 + session.SendMsg("hero", "change", &pb.HeroChangePush{List: changeList}) + } + // 首次获得英雄 则推送 + if len(firstGet) > 0 { + session.SendMsg("hero", "firstget", &pb.HeroFirstGetPush{ + HeroId: firstGet, + }) + } + return } diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index 76dba0441..6e46f151f 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -2190,7 +2190,7 @@ type HeroFirstGetPush struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - HeroId string `protobuf:"bytes,1,opt,name=heroId,proto3" json:"heroId"` //英雄id + HeroId []string `protobuf:"bytes,1,rep,name=heroId,proto3" json:"heroId"` //英雄id } func (x *HeroFirstGetPush) Reset() { @@ -2225,11 +2225,11 @@ func (*HeroFirstGetPush) Descriptor() ([]byte, []int) { return file_hero_hero_msg_proto_rawDescGZIP(), []int{41} } -func (x *HeroFirstGetPush) GetHeroId() string { +func (x *HeroFirstGetPush) GetHeroId() []string { if x != nil { return x.HeroId } - return "" + return nil } var File_hero_hero_msg_proto protoreflect.FileDescriptor @@ -2430,7 +2430,7 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x65, 0x6e, 0x62, 0x75, 0x79, 0x22, 0x2a, 0x0a, 0x10, 0x48, 0x65, 0x72, 0x6f, 0x46, 0x69, 0x72, 0x73, 0x74, 0x47, 0x65, 0x74, 0x50, 0x75, 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x03, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, }