觉醒附加属性优化
This commit is contained in:
parent
cc955cc160
commit
3df4d95fe6
@ -26,7 +26,9 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
awakenData *cfg.GameHeroAwakenData
|
||||
_hero *pb.DBHero
|
||||
chanegCard []*pb.DBHero // change
|
||||
_heroMap map[string]interface{}
|
||||
)
|
||||
_heroMap = make(map[string]interface{}, 0)
|
||||
chanegCard = make([]*pb.DBHero, 0)
|
||||
code = this.AwakenCheck(session, req) // check
|
||||
if code != pb.ErrorCode_Success {
|
||||
@ -62,9 +64,11 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
_hero.SameCount -= 1
|
||||
newHero := this.module.modelHero.CloneNewHero(_hero)
|
||||
chanegCard = append(chanegCard, newHero)
|
||||
_heroMap["isOverlying"] = false
|
||||
_heroMap["sameCount"] = 1
|
||||
}
|
||||
_hero.SameCount = 1
|
||||
|
||||
_hero.IsOverlying = false
|
||||
// 加属性 awakenData
|
||||
_value, ok := strconv.Atoi(awakenData.Phasebonus[0])
|
||||
if ok == nil { // 升级技能
|
||||
@ -76,43 +80,23 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
}
|
||||
}
|
||||
}
|
||||
_heroMap := map[string]interface{}{
|
||||
"normalSkill": _hero.NormalSkill,
|
||||
"sameCount": 1,
|
||||
"isOverlying": false,
|
||||
}
|
||||
// 保存数据
|
||||
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err)
|
||||
return
|
||||
}
|
||||
_heroMap["normalSkill"] = _hero.NormalSkill
|
||||
} else { // 加属性
|
||||
|
||||
// property := make(map[string]int32, 0)
|
||||
value, err := strconv.Atoi(awakenData.Phasebonus[1])
|
||||
if err == nil {
|
||||
this.module.modelHero.setJuexingProperty(_hero, awakenData.Phasebonus[0], int32(value))
|
||||
//property[awakenData.Phasebonus[0]] += int32(value)
|
||||
}
|
||||
// this.module.modelHero.mergeMainProperty(session.GetUserId(), _hero, property)
|
||||
_hero.JuexingLv += 1
|
||||
_heroMap := map[string]interface{}{
|
||||
"juexingLv": _hero.JuexingLv,
|
||||
"sameCount": 1,
|
||||
"isOverlying": false,
|
||||
}
|
||||
// 保存数据
|
||||
err = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err)
|
||||
return
|
||||
_heroMap["juexProperty"] = _hero.JuexProperty
|
||||
}
|
||||
}
|
||||
|
||||
this.module.modelHero.ChangeHeroProperty(session, _hero) // 推送属性变化
|
||||
_hero.JuexingLv += 1
|
||||
_heroMap["juexingLv"] = _hero.JuexingLv
|
||||
// 保存数据
|
||||
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
chanegCard = append(chanegCard, _hero)
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard})
|
||||
|
@ -110,7 +110,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
}
|
||||
}
|
||||
|
||||
this.module.modelHero.ChangeHeroProperty(session, _hero) // 推送属性变化
|
||||
//this.module.modelHero.ChangeHeroProperty(session, _hero) // 推送属性变化
|
||||
|
||||
ChangeList = append(ChangeList, _hero)
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: ChangeList})
|
||||
|
@ -60,10 +60,8 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
_hero.EnergyProperty = nil
|
||||
for k := range _hero.Energy { // 清除玩家选择的共鸣属性
|
||||
delete(_hero.Energy, k)
|
||||
}
|
||||
_hero.EnergyProperty = make(map[string]int32, 0)
|
||||
_hero.Energy = make(map[string]int32)
|
||||
_hero.DistributionResonate = _hero.ResonateNum * resonConfig.Energy
|
||||
_heroMap := map[string]interface{}{
|
||||
"distributionResonate": _hero.DistributionResonate,
|
||||
@ -78,9 +76,6 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
// 计算属性
|
||||
//this.module.modelHero.setEnergyProperty(_hero)
|
||||
//session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}})
|
||||
session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
|
||||
return
|
||||
}
|
||||
|
@ -263,10 +263,6 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
|
||||
|
||||
// 觉醒
|
||||
func (this *ModelHero) setJuexingProperty(hero *pb.DBHero, key string, value int32) {
|
||||
if hero.JuexProperty == nil {
|
||||
hero.JuexProperty = make(map[string]int32)
|
||||
}
|
||||
JuexingProperty := make(map[string]int32) //副属性
|
||||
switch key {
|
||||
case comm.Hp:
|
||||
hero.JuexProperty[comm.Hp] += value
|
||||
@ -283,19 +279,6 @@ func (this *ModelHero) setJuexingProperty(hero *pb.DBHero, key string, value int
|
||||
case comm.ResonanceDefPro:
|
||||
hero.JuexProperty[comm.Def] += int32(math.Floor((1.0 + float64(value)/1000) * float64(hero.Property[comm.Def])))
|
||||
}
|
||||
for k, v := range hero.JuexProperty {
|
||||
JuexingProperty[k] = v
|
||||
}
|
||||
this.mergeJuexingProperty(hero.Uid, hero, JuexingProperty)
|
||||
}
|
||||
func (this *ModelHero) mergeJuexingProperty(uid string, hero *pb.DBHero, data map[string]int32) {
|
||||
hero.EnergyProperty = data
|
||||
|
||||
if err := this.ChangeList(uid, hero.Id, map[string]interface{}{
|
||||
"juexProperty": data,
|
||||
}); err != nil {
|
||||
this.moduleHero.Errorf("mergeAddProperty err %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 设置共鸣能量点数属性
|
||||
@ -314,7 +297,11 @@ func (this *ModelHero) setEnergyProperty(hero *pb.DBHero) {
|
||||
EnergyProperty[comm.Def] += int32(math.Floor((1.0 + float64(resonConfig.Defpro*v)/1000) * float64(hero.Property[comm.Def])))
|
||||
}
|
||||
}
|
||||
this.mergeEnegryProperty(hero.Uid, hero, EnergyProperty)
|
||||
_heroMap := make(map[string]interface{}, 0)
|
||||
_heroMap["enegryProperty"] = EnergyProperty
|
||||
if err := this.ChangeList(hero.Uid, hero.Id, _heroMap); err != nil {
|
||||
this.moduleHero.Errorf("mergeenegryProperty err %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 设置装备属性
|
||||
@ -341,8 +328,6 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//this.mergeMainProperty(hero.Uid, hero, property)
|
||||
this.mergeAddProperty(hero.Uid, hero, addProperty)
|
||||
}
|
||||
|
||||
@ -413,17 +398,6 @@ func (this *ModelHero) mergeAddProperty(uid string, hero *pb.DBHero, data map[st
|
||||
}
|
||||
}
|
||||
|
||||
// 合并附加能量属性
|
||||
func (this *ModelHero) mergeEnegryProperty(uid string, hero *pb.DBHero, data map[string]int32) {
|
||||
hero.EnergyProperty = data
|
||||
|
||||
if err := this.ChangeList(uid, hero.Id, map[string]interface{}{
|
||||
"enegryProperty": data,
|
||||
}); err != nil {
|
||||
this.moduleHero.Errorf("mergeAddProperty err %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
//属性计算
|
||||
//英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数
|
||||
func (this *ModelHero) PropertyCompute(hero *pb.DBHero) {
|
||||
|
Loading…
Reference in New Issue
Block a user