跨服加英雄经验
This commit is contained in:
parent
139f47f7f2
commit
a7a8dce83d
@ -71,7 +71,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
return
|
||||
}
|
||||
// 执行升级逻辑
|
||||
_, code = this.module.modelHero.AddCardExp(session, _hero, addExp) // 加经验
|
||||
_, code = this.module.modelHero.AddCardExp(session, _hero, addExp, nil) // 加经验
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ func (this *ModelHero) cleanData(uid string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, exp int32) (curAddExp int32, code pb.ErrorCode) {
|
||||
func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, exp int32, model *db.DBModel) (curAddExp int32, code pb.ErrorCode) {
|
||||
var (
|
||||
preLv int32 //加经验之前的等级
|
||||
curExp int32 // 加经验之后的经验
|
||||
@ -559,10 +559,18 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
|
||||
update["talentProperty"] = hero.TalentProperty
|
||||
update["juexProperty"] = hero.JuexProperty
|
||||
}
|
||||
if err := this.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
|
||||
this.moduleHero.Errorf("add hero exp failed ChangeList %v", err)
|
||||
code = pb.ErrorCode_DBError
|
||||
if model != nil {
|
||||
if err := model.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
|
||||
this.moduleHero.Errorf("add hero exp failed ChangeList %v", err)
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
} else {
|
||||
if err := this.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
|
||||
this.moduleHero.Errorf("add hero exp failed ChangeList %v", err)
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
}
|
||||
|
||||
if curLv-preLv > 0 { // 升级了 统计任务
|
||||
// 推送
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype147, utils.ToInt32(hero.HeroID), curLv-preLv)
|
||||
|
@ -302,14 +302,27 @@ func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp in
|
||||
if heroObjID == "" {
|
||||
return
|
||||
}
|
||||
_hero, code = this.GetHeroByObjID(session.GetUserId(), heroObjID)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if this.IsCross() {
|
||||
if model, err := this.GetDBModuleByUid(session.GetUserId(), this.modelHero.TableName, this.modelHero.Expired); err == nil {
|
||||
if err := model.GetListObj(session.GetUserId(), heroObjID, _hero); err != nil {
|
||||
this.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
curAddExp, code = this.modelHero.AddCardExp(session, _hero, exp, model)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_hero, code = this.GetHeroByObjID(session.GetUserId(), heroObjID)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
curAddExp, code = this.modelHero.AddCardExp(session, _hero, exp)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
curAddExp, code = this.modelHero.AddCardExp(session, _hero, exp, nil)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
}
|
||||
_changeHero = append(_changeHero, _hero) // 升级后的英雄 hero id 不变
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user