diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index 11831e987..53b9fc690 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -127,8 +127,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (e } } } - if this.module.configure.GetHeroTalentMaxLv(_hero.HeroID) == _l { - bManAwaken = true + if maxlv, err := this.module.configure.GetHeroTalentMaxLv(_hero.HeroID); err == nil { + if maxlv == _l { + bManAwaken = true + } } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype121, 1, cfg.Race)) if err != nil { // 达到满级觉醒 diff --git a/modules/hero/api_talentlearn.go b/modules/hero/api_talentlearn.go index ad3d27164..a14331c2c 100644 --- a/modules/hero/api_talentlearn.go +++ b/modules/hero/api_talentlearn.go @@ -215,22 +215,25 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe return } if heroObj.Lv == maxlv { - - if this.module.configure.GetHeroTalentMaxLv(heroObj.HeroID) == int32(len(talent.Talent)) { - tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype37, heroObj.HeroID, cfg.Color)) - tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype38, heroObj.HeroID)) - iHeroId, _ := strconv.Atoi(heroObj.HeroID) - tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype243, heroObj.HeroID, int32(iHeroId))) + if maxlv, e := this.module.configure.GetHeroTalentMaxLv(heroObj.HeroID); e == nil { + if maxlv == int32(len(talent.Talent)) { + tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype37, heroObj.HeroID, cfg.Color)) + tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype38, heroObj.HeroID)) + iHeroId, _ := strconv.Atoi(heroObj.HeroID) + tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype243, heroObj.HeroID, int32(iHeroId))) + } } } } // 满回响 - if this.module.configure.GetHeroTalentMaxLv(heroObj.HeroID) == int32(len(talent.Talent)) { - tasks = append(tasks, comm.GetBuriedParam(comm.Rtype128, 1, cfg.Race)) - if user, err := this.module.GetUserForSession(session); err == nil { - this.chat.SendSysChatToWorld(session, comm.ChatSystem10, heroObj, heroObj.Star, 0, user.Name, heroObj.HeroID) - } else { - this.module.Errorf("no found userdata uid:%s", session.GetUserId()) + if maxlv, e := this.module.configure.GetHeroTalentMaxLv(heroObj.HeroID); e == nil { + if maxlv == int32(len(talent.Talent)) { + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype128, 1, cfg.Race)) + if user, err := this.module.GetUserForSession(session); err == nil { + this.chat.SendSysChatToWorld(session, comm.ChatSystem10, heroObj, heroObj.Star, 0, user.Name, heroObj.HeroID) + } else { + this.module.Errorf("no found userdata uid:%s", session.GetUserId()) + } } } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype199, 1)) diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 74ef663cb..12b1cb046 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -73,8 +73,9 @@ type configureComp struct { cardPool map[string][]*cfg.GameCardPoolData // 限定英雄 - wish *Replace // 许愿英雄招募 - appoint *Replace // 限定英雄招募 + wish *Replace // 许愿英雄招募 + appoint *Replace // 限定英雄招募 + talentlv map[string]int32 // 天赋等级 } // 组件初始化接口 @@ -211,6 +212,24 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp } }) + configure.RegisterConfigure(hero_talent, cfg.NewGameHeroTalent, func() { + if v, err := this.GetConfigure(hero_talent); err == nil { + if _configure, ok := v.(*cfg.GameHeroTalent); ok { + this.hlock.Lock() + defer this.hlock.Unlock() + this.talentlv = make(map[string]int32) + for _, v := range _configure.GetDataList() { + this.talentlv[v.Hid] += 1 + } + + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_drawCard", v) + } + }) + + this.GetHeroTalentMaxLv("13001") return } func (this *configureComp) GetApportHeroReplaceConfig() *Replace { @@ -474,14 +493,19 @@ func (this *configureComp) GetHeroMaxLv(star int32) (maxlv int32, err error) { err = fmt.Errorf("GetHeroMaxLv err : star:%d", star) return } -func (this *configureComp) GetHeroTalentMaxLv(heroid string) (maxlv int32) { - if v, err := this.GetConfigure(hero_talentbox); err == nil { - if configure, ok := v.(*cfg.GameTalentBox); ok { - return int32(len(configure.GetDataList())) - } - } - return 0 +// 获取满共鸣的等级 +func (this *configureComp) GetHeroTalentMaxLv(heroid string) (maxlv int32, err error) { + var ( + ok bool + ) + this.hlock.RLock() + defer this.hlock.RUnlock() + if maxlv, ok = this.talentlv[heroid]; ok { + return + } + err = comm.NewNotFoundConfErr(moduleName, hero_talent, heroid) + return } // id: 1新手卡池 2 表示普通抽 3表示阵营1 4表示阵营2 ... diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 2bc035576..189a03d2d 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -725,11 +725,13 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, heros []*pb.DBHero, } } } - if this.module.configure.GetHeroTalentMaxLv(hero.HeroID) == _l { - tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype37, hero.HeroID, heroconf.Color)) - tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype38, hero.HeroID)) - iHeroId, _ := strconv.Atoi(hero.HeroID) - tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype243, hero.HeroID, int32(iHeroId))) + if maxlv, e := this.module.configure.GetHeroTalentMaxLv(hero.HeroID); e == nil { + if maxlv == _l { + tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype37, hero.HeroID, heroconf.Color)) + tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype38, hero.HeroID)) + iHeroId, _ := strconv.Atoi(hero.HeroID) + tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype243, hero.HeroID, int32(iHeroId))) + } } } }