英雄可以取消注册

This commit is contained in:
meixiongfeng 2023-03-15 15:15:16 +08:00
parent e7d3d0ca7a
commit 72bb00422e

View File

@ -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
}