英雄注册接口参数调整增加判断逻辑

This commit is contained in:
meixiongfeng 2023-02-28 11:26:58 +08:00
parent db211dfab2
commit 63d25e17ba
4 changed files with 25 additions and 18 deletions

View File

@ -94,7 +94,7 @@ type (
GetAllMaxHero(session IUserSession) (code pb.ErrorCode) GetAllMaxHero(session IUserSession) (code pb.ErrorCode)
// 教习登记 // 教习登记
RegisterInstructor(session IUserSession, heroCid string, registerId int32) (code pb.ErrorCode) RegisterInstructor(session IUserSession, heroOid string, registerId int32) (code pb.ErrorCode)
} }
//玩家 //玩家

View File

@ -798,24 +798,30 @@ func (this *Hero) InRange(heroRecord *pb.DBHeroRecord, strPool []string, update
return return
} }
func (this *Hero) RegisterInstructor(session comm.IUserSession, heroCid string, fulllvenr int32) (code pb.ErrorCode) { func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid string, fulllvenr int32) (code pb.ErrorCode) {
list := this.GetHeroList(session.GetUserId()) _hero, code := this.GetHeroByObjID(session.GetUserId(), heroOid)
for _, v := range list { if code != pb.ErrorCode_Success {
if v.HeroID == heroCid && v.Fulllvenr == 0 { return
v.Fulllvenr = fulllvenr
_heroMap := map[string]interface{}{
"fulllvenr": v.Fulllvenr,
} }
if err := this.modelHero.ChangeList(session.GetUserId(), v.Id, _heroMap); err != nil {
if _hero.Fulllvenr == 0 {
// 校验有没有满级
if _hero.Lv < _hero.Star*comm.HeroStarLvRatio {
code = pb.ErrorCode_HeroInsufficientLv // 必须满级
return
}
_hero.Fulllvenr = fulllvenr
_heroMap := map[string]interface{}{
"fulllvenr": _hero.Fulllvenr,
}
if err := this.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
return
} else { } else {
code = pb.ErrorCode_HeroIsRegister // 英雄已经注册过 code = pb.ErrorCode_HeroIsRegister // 英雄已经注册过
return return
} }
}
code = pb.ErrorCode_HeroNoExist // 英雄不存在
return return
} }

View File

@ -49,8 +49,8 @@ func (this *modelMail) MailQueryUserMail(uId string) (mail []*pb.DBMailData, err
} }
// 插入一封新的邮件 // 插入一封新的邮件
func (this *modelMail) MailInsertUserMail(mail *pb.DBMailData) (err error) {
func (this *modelMail) MailInsertUserMail(mail *pb.DBMailData) (err error) {
mail.ObjId = primitive.NewObjectID().Hex() mail.ObjId = primitive.NewObjectID().Hex()
mail.Check = false mail.Check = false
mail.Reward = true mail.Reward = true

View File

@ -132,6 +132,7 @@ const (
ErrorCode_HeroAlreadyKongFuStatus ErrorCode = 1324 // 已经是练功状态 ErrorCode_HeroAlreadyKongFuStatus ErrorCode = 1324 // 已经是练功状态
ErrorCode_HeroLvNoEnough ErrorCode = 1325 // 英雄等级不足 ErrorCode_HeroLvNoEnough ErrorCode = 1325 // 英雄等级不足
ErrorCode_HeroIsRegister ErrorCode = 1326 // 英雄已经登记过 ErrorCode_HeroIsRegister ErrorCode = 1326 // 英雄已经登记过
ErrorCode_HeroInsufficientLv ErrorCode = 1327 // 英雄等级不足
// equipment // equipment
ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器 ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器
ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限 ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限