属性计算优化
This commit is contained in:
parent
10fb331b52
commit
e06b0d8d31
@ -102,7 +102,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
}
|
||||
}
|
||||
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero) // 推送属性变化
|
||||
if err1 != nil {
|
||||
this.module.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
}
|
||||
}
|
||||
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero) // 推送属性变化
|
||||
if err1 != nil {
|
||||
this.module.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero) // 推送属性变化
|
||||
if err1 != nil {
|
||||
this.module.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR
|
||||
}
|
||||
this.module.modelHero.mergeMainProperty(session.GetUserId(), _hero, property)
|
||||
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero) // 推送属性变化
|
||||
if err1 != nil {
|
||||
this.module.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_costHero}})
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero) // 推送属性变化
|
||||
if err1 != nil {
|
||||
this.module.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
}
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero) // 推送属性变化
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_Unknown
|
||||
this.module.Errorf("PushHeroProperty err!")
|
||||
|
@ -178,7 +178,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
_changeHero = append(_changeHero, _costExpHero[k])
|
||||
}
|
||||
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero) // 推送属性变化
|
||||
if err1 != nil {
|
||||
this.module.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ func (this *ModelHero) initHero(uid string, heroCfgId string) *pb.DBHero {
|
||||
Energy: make(map[int32]int32),
|
||||
Property: make(map[string]int32),
|
||||
}
|
||||
newHero.Property = this.PropertyCompute(uid, newHero)
|
||||
this.initHeroSkill(newHero)
|
||||
return newHero
|
||||
}
|
||||
@ -363,11 +364,7 @@ func (this *ModelHero) mergeAddProperty(uid string, hero *pb.DBHero, data map[st
|
||||
|
||||
//属性计算 - 暂时放在modelHero里实现
|
||||
//英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数
|
||||
func (this *ModelHero) PropertyCompute(uid, heroId string) map[string]int32 {
|
||||
hero := this.getOneHero(uid, heroId)
|
||||
if hero == nil {
|
||||
return nil
|
||||
}
|
||||
func (this *ModelHero) PropertyCompute(uid string, hero *pb.DBHero) map[string]int32 {
|
||||
|
||||
//英雄等级基础属性levelup
|
||||
heroLvCfg := this.moduleHero.configure.GetHeroLv(hero.Lv)
|
||||
@ -421,14 +418,14 @@ func (this *ModelHero) PropertyCompute(uid, heroId string) map[string]int32 {
|
||||
}
|
||||
}
|
||||
|
||||
//推送用户指定英雄属性
|
||||
func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string) (m map[string]int32, err error) {
|
||||
m = this.PropertyCompute(session.GetUserId(), heroId)
|
||||
//重新计算英雄属性
|
||||
func (this *ModelHero) PushHeroProperty(session comm.IUserSession, hero *pb.DBHero) (m map[string]int32, err error) {
|
||||
m = this.PropertyCompute(session.GetUserId(), hero)
|
||||
update := map[string]interface{}{
|
||||
"property": m,
|
||||
}
|
||||
|
||||
if err = this.ChangeList(session.GetUserId(), heroId, update); err != nil {
|
||||
if err = this.ChangeList(session.GetUserId(), hero.Id, update); err != nil {
|
||||
this.moduleHero.Errorf("PushHeroProperty err:%v", err)
|
||||
return
|
||||
}
|
||||
|
@ -85,9 +85,9 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq
|
||||
//英雄列表
|
||||
func (this *Hero) GetHeroList(uid string) []*pb.DBHero {
|
||||
heroes := this.modelHero.getHeroList(uid)
|
||||
for _, h := range heroes {
|
||||
h.Property = this.modelHero.PropertyCompute(uid, h.Id)
|
||||
}
|
||||
// for _, h := range heroes {
|
||||
// h.Property = this.modelHero.PropertyCompute(uid, h)
|
||||
// }
|
||||
return heroes
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user