英雄 天赋增加英雄等级校验
This commit is contained in:
parent
72e9f12905
commit
dca0850ff3
@ -26,6 +26,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
err error
|
||||
chanegCard []*pb.DBHero // 推送属性变化
|
||||
res []*cfg.Gameatn // 学习天赋需要消耗的道具
|
||||
hero *pb.DBHero
|
||||
)
|
||||
|
||||
chanegCard = make([]*pb.DBHero, 0)
|
||||
@ -41,8 +42,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
}
|
||||
return
|
||||
}
|
||||
this.module.Debugf("%v", talent)
|
||||
|
||||
this.module.Debugf("TalentLearn:%v", talent)
|
||||
} else {
|
||||
if req.Heroid == "" { // 英雄id不能为空
|
||||
errdata = &pb.ErrorData{
|
||||
@ -66,6 +66,12 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
talent, err = this.module.modelTalent.CreateHeroTalent(session.GetUserId(), req.Heroid)
|
||||
if err != nil {
|
||||
this.module.Errorf("create talent data failed:%v", err)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,19 +85,26 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
}
|
||||
return
|
||||
}
|
||||
user := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
if user != nil {
|
||||
hero = this.module.QueryHeroByConfId(session.GetUserId(), talent.HeroId)
|
||||
if hero == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 校验玩家等级
|
||||
if talentConf.Condition > user.Lv { // 等级不满足
|
||||
if talentConf.Condition > hero.Lv { // 等级不满足
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserLvNoEnough,
|
||||
Title: pb.ErrorCode_UserLvNoEnough.ToString(),
|
||||
Message: fmt.Sprintf("等级不满足要求:curLv = %d,lv = %d", user.Lv, talentConf.Condition),
|
||||
Message: fmt.Sprintf("英雄等级不满足要求:curLv = %d,lv = %d", hero.Lv, talentConf.Condition),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 校验
|
||||
if len(talentConf.Before) == 1 && talentConf.Before[0] == 0 { // 前置解锁技能为0
|
||||
@ -160,13 +173,8 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
}
|
||||
|
||||
// 同步修改属性
|
||||
heroList := this.module.GetHeroList(session.GetUserId())
|
||||
for _, v := range heroList {
|
||||
if v.HeroID == talent.HeroId { // 找到对应的英雄ID
|
||||
this.module.modelHero.setTalentProperty(v, talentConf)
|
||||
chanegCard = append(chanegCard, v) // 添加推送属性变化信息
|
||||
}
|
||||
}
|
||||
this.module.modelHero.setTalentProperty(hero, talentConf)
|
||||
chanegCard = append(chanegCard, hero) // 添加推送属性变化信息
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard})
|
||||
session.SendMsg(string(this.module.GetType()), HeroTalentLearnResp, &pb.HeroTalentLearnResp{
|
||||
|
Loading…
Reference in New Issue
Block a user