From 6f40d053ff60c86b3e867d0143c12b27a419ead9 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 18 Jan 2024 16:40:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=80=E5=A4=A7=E6=98=9F?= =?UTF-8?q?=E7=BA=A7=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_awaken.go | 12 +++++++++++- modules/hero/api_strengthenUplv.go | 11 ++++++++++- modules/hero/api_talentlearn.go | 11 ++++++++++- modules/hero/configure_comp.go | 16 +++++++++------- modules/hero/model_hero.go | 20 ++++++++++++++++++-- modules/hero/module.go | 21 +++++++++++++++++++-- 6 files changed, 77 insertions(+), 14 deletions(-) diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index df8bcdfe1..c041cc335 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -1,6 +1,7 @@ package hero import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -129,7 +130,16 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (e } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype121, 1, cfg.Race)) if err != nil { // 达到满级觉醒 - if _hero.Lv == this.module.configure.GetHeroMaxLv(_hero.Star) && bManAwaken { + var maxlv int32 + if maxlv, err = this.module.configure.GetHeroMaxLv(_hero.Star); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: fmt.Sprintf("cid:%s id:%s err:%s", _hero.HeroID, _hero.Id, err.Error()), + } + return + } + if _hero.Lv == maxlv && bManAwaken { tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype37, _hero.HeroID, cfg.Color)) tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype38, _hero.HeroID)) tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype36, _hero.HeroID, cfg.Color, cfg.Job, cfg.Race, _hero.JuexingLv)) diff --git a/modules/hero/api_strengthenUplv.go b/modules/hero/api_strengthenUplv.go index 4dbc794d9..bb49e6643 100644 --- a/modules/hero/api_strengthenUplv.go +++ b/modules/hero/api_strengthenUplv.go @@ -30,6 +30,8 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren cost []*cfg.Gameatn // 消耗的道具 award []*cfg.Gameatn atno []*pb.UserAtno + maxlv int32 + err error ) if errdata = this.StrengthenUplvCheck(session, req); errdata != nil { return @@ -79,7 +81,14 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren return } // 校验当前能不能升级 - if _hero.Lv >= this.module.configure.GetHeroMaxLv(_hero.Star) { // 达到最大等级 + if maxlv, err = this.module.configure.GetHeroMaxLv(_hero.Star); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Message: fmt.Sprintf("cid:%s id:%s err:%s", _hero.HeroID, _hero.Id, err.Error()), + } + return + } + if _hero.Lv >= maxlv { // 达到最大等级 errdata = &pb.ErrorData{ Code: pb.ErrorCode_HeroMaxLv, Title: pb.ErrorCode_HeroMaxLv.ToString(), diff --git a/modules/hero/api_talentlearn.go b/modules/hero/api_talentlearn.go index 51b74a9df..459f7e592 100644 --- a/modules/hero/api_talentlearn.go +++ b/modules/hero/api_talentlearn.go @@ -204,7 +204,16 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe tasks = append(tasks, comm.GetBuriedParam(comm.Rtype40, 1, int32(len(talent.Talent)))) _, err = this.module.configure.GetHeroAwakenConfig(heroObj.HeroID, heroObj.JuexingLv+1) if err != nil { // 达到满级觉醒 - if heroObj.Lv == this.module.configure.GetHeroMaxLv(heroObj.Star) { + var maxlv int32 + if maxlv, err = this.module.configure.GetHeroMaxLv(heroObj.Star); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: fmt.Sprintf("cid:%s id:%s err:%s", heroObj.HeroID, heroObj.Id, err.Error()), + } + 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)) diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 4d407bfe7..3fcf8ac96 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -448,18 +448,20 @@ func (this *configureComp) GetHeroSkillCost(star int32) (cost []*cfg.Gameatn) { } // 获取英雄最大等级 -func (this *configureComp) GetHeroMaxLv(star int32) int32 { - - if v, err := this.GetConfigure(hero_stargrow); err == nil { +func (this *configureComp) GetHeroMaxLv(star int32) (maxlv int32, err error) { + var ( + v interface{} + ) + if v, err = this.GetConfigure(hero_stargrow); err == nil { if configure, ok := v.(*cfg.GameHeroStargrow); ok { if configure.Get(star) != nil { - return configure.Get(star).Maxlevel + maxlv = configure.Get(star).Maxlevel + return } } } - this.module.Errorf(" GetHeroMaxLv err : star:%d", star) - - return 1 + 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 { diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 8c3fd7cf3..ac3238e7c 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -3,6 +3,7 @@ package hero import ( "crypto/rand" "errors" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" @@ -431,7 +432,13 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, heros []*pb.DBHero, curLv = hero.Lv preLv = curLv var maxLv int32 // 校验等级达到上限 - maxLv = this.module.configure.GetHeroMaxLv(hero.Star) + if maxLv, err = this.module.configure.GetHeroMaxLv(hero.Star); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Message: fmt.Sprintf("cid:%s id:%s err:%s", hero.HeroID, hero.Id, err.Error()), + } + return + } // 校验玩家等级 if user, err = this.module.GetUserForSession(session); err != nil { errdata = &pb.ErrorData{ @@ -542,7 +549,16 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, heros []*pb.DBHero, //xx英雄满级、共鸣、觉醒至最高状态 nextAwaken, _ := this.module.configure.GetHeroAwakenConfig(hero.HeroID, hero.JuexingLv+1) if nextAwaken == nil { // 达到满级觉醒 - if hero.Lv == this.module.configure.GetHeroMaxLv(hero.Star) { + var maxlv int32 + if maxlv, err = this.module.configure.GetHeroMaxLv(hero.Star); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: fmt.Sprintf("cid:%s id:%s err:%s", hero.HeroID, hero.Id, err.Error()), + } + return + } + if hero.Lv == maxlv { var _l int32 talent, err := this.module.modelTalent.GetHerotalent(session.GetUserId()) if err == nil { diff --git a/modules/hero/module.go b/modules/hero/module.go index bfba63eef..25ccfe8b0 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -2,6 +2,7 @@ package hero import ( "context" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/event" @@ -433,7 +434,14 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession, bTalent bool) (errdat // 获取最大星级 maxStar = this.configure.GetHeroMaxStar(cid, v.Star) - maxLv := this.configure.GetHeroMaxLv(maxStar) // 最大等级 + maxLv, err := this.configure.GetHeroMaxLv(maxStar) + if err != nil { // 最大等级 + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: fmt.Sprintf("cid:%s err:%s", cid, err.Error()), + } + } maxJux := 1 // 最大觉醒等级 for i := 1; ; i++ { @@ -606,7 +614,16 @@ func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid []string _heroMap["fulllvenr"] = 0 } else if v.Fulllvenr == 0 && fulllvenr != 0 { // 校验有没有满级 - if v.Lv < this.configure.GetHeroMaxLv(v.Star) { + var maxlv int32 + if maxlv, err = this.configure.GetHeroMaxLv(v.Star); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: fmt.Sprintf("cid:%s id:%s err:%s", v.HeroID, v.Id, err.Error()), + } + return + } + if v.Lv < maxlv { errdata = &pb.ErrorData{ Code: pb.ErrorCode_HeroLvNoEnough, Title: pb.ErrorCode_HeroLvNoEnough.ToString(),