From 72bb00422ea4abf3347e9ef991b83aa9a786ec8f Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 15 Mar 2023 15:15:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=8F=AF=E4=BB=A5=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/module.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/hero/module.go b/modules/hero/module.go index 6a0dce208..5f16f59f8 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -842,9 +842,10 @@ func (this *Hero) InRange(heroRecord *pb.DBHeroRecord, strPool []string, update func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid string, fulllvenr int32) (code pb.ErrorCode) { var ( - _hero *pb.DBHero - model *db.DBModel - err error + _hero *pb.DBHero + model *db.DBModel + err error + _heroMap map[string]interface{} ) if this.IsCross() { _hero = &pb.DBHero{} @@ -860,37 +861,36 @@ func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid string, return } } - - if _hero.Fulllvenr == 0 { + _heroMap = make(map[string]interface{}) + if fulllvenr == 0 && _hero.Fulllvenr != 0 { + _heroMap["fulllvenr"] = 0 + } else if _hero.Fulllvenr == 0 && fulllvenr != 0 { // 校验有没有满级 if _hero.Lv < this.configure.GetHeroMaxLv(_hero.Star) { code = pb.ErrorCode_HeroLvNoEnough // 必须满级 return } _hero.Fulllvenr = fulllvenr - _heroMap := map[string]interface{}{ - "fulllvenr": _hero.Fulllvenr, - } + _heroMap["fulllvenr"] = _hero.Fulllvenr - if this.IsCross() { - if model != nil { - if err := model.ChangeList(session.GetUserId(), heroOid, _heroMap); err != nil { - this.Errorf("err:%v", err) - code = pb.ErrorCode_DBError - return - } - } - } else { - if err := this.modelHero.ChangeList(session.GetUserId(), heroOid, _heroMap); err != nil { // 修改英雄信息 + } else { + code = pb.ErrorCode_HeroIsRegister + return + } + if this.IsCross() { + if model != nil { + if err := model.ChangeList(session.GetUserId(), heroOid, _heroMap); err != nil { this.Errorf("err:%v", err) code = pb.ErrorCode_DBError return } } - } else { - code = pb.ErrorCode_HeroIsRegister // 英雄已经注册过 - return + if err := this.modelHero.ChangeList(session.GetUserId(), heroOid, _heroMap); err != nil { // 修改英雄信息 + this.Errorf("err:%v", err) + code = pb.ErrorCode_DBError + return + } } return }