This commit is contained in:
liwei1dao 2022-09-22 18:31:59 +08:00
commit b0a4811445
4 changed files with 54 additions and 65 deletions

View File

@ -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,41 +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 {
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
this.module.modelHero.setJuexingProperty(_hero, awakenData.Phasebonus[0], int32(value))
_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})

View File

@ -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})

View File

@ -60,19 +60,14 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
if code != pb.ErrorCode_Success {
return
}
property := make(map[string]int32, 0)
property[comm.HpPro] -= _hero.AddProperty[comm.HpPro]
property[comm.AtkPro] -= _hero.AddProperty[comm.AtkPro]
property[comm.DefPro] -= _hero.AddProperty[comm.DefPro]
this.module.modelHero.mergeMainProperty(session.GetUserId(), _hero, property)
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,
"energy": _hero.Energy,
"isOverlying": false,
"energyProperty": _hero.EnergyProperty,
}
err1 = this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
@ -81,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
}

View File

@ -261,6 +261,26 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
return heroes
}
// 觉醒
func (this *ModelHero) setJuexingProperty(hero *pb.DBHero, key string, value int32) {
switch key {
case comm.Hp:
hero.JuexProperty[comm.Hp] += value
case comm.Def:
hero.JuexProperty[comm.Def] += value
case comm.Atk:
hero.JuexProperty[comm.Atk] += value
case comm.Speed:
hero.JuexProperty[comm.Speed] += value
case comm.ResonanceHpPro:
hero.JuexProperty[comm.Hp] += int32(math.Floor((1.0 + float64(value)/1000) * float64(hero.Property[comm.Hp])))
case comm.ResonanceAtkPro:
hero.JuexProperty[comm.Atk] += int32(math.Floor((1.0 + float64(value)/1000) * float64(hero.Property[comm.Atk])))
case comm.ResonanceDefPro:
hero.JuexProperty[comm.Def] += int32(math.Floor((1.0 + float64(value)/1000) * float64(hero.Property[comm.Def])))
}
}
// 设置共鸣能量点数属性
func (this *ModelHero) setEnergyProperty(hero *pb.DBHero) {
resonConfig := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID, hero.Star)
@ -277,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)
}
}
// 设置装备属性
@ -304,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)
}
@ -376,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) {
@ -421,24 +432,24 @@ func (this *ModelHero) PropertyCompute(hero *pb.DBHero) {
return
}
curHp := hero.Property[comm.Hp]
//血量
exprHp := fmt.Sprintf("%v + %v * %v/1000 + %v * %v/1000",
(curHp + lvGrow.Hp), heroLvCfg.Hp, lvGrow.Hpgrow, heroStarCfg.Hp, stargrowCfg.StarupHp)
lvGrow.Hp, heroLvCfg.Hp, lvGrow.Hpgrow, heroStarCfg.Hp, stargrowCfg.StarupHp)
hp, _ := mengine.ParseAndExec(exprHp)
curAtk := hero.Property[comm.Atk]
// 攻击
exprAtk := fmt.Sprintf("%v +%v * %v/1000 + %v * %v/1000",
(curAtk + lvGrow.Atk), heroLvCfg.Atk, lvGrow.Atkgrow, heroStarCfg.Atk, stargrowCfg.StarupAtk)
lvGrow.Atk, heroLvCfg.Atk, lvGrow.Atkgrow, heroStarCfg.Atk, stargrowCfg.StarupAtk)
atk, _ := mengine.ParseAndExec(exprAtk)
curDef := hero.Property[comm.Def]
// 防御
exprDef := fmt.Sprintf("%v +%v * %v/1000 + %v * %v/1000",
(curDef + lvGrow.Def), heroLvCfg.Def, lvGrow.Defgrow, heroStarCfg.Def, stargrowCfg.StarupDef)
lvGrow.Def, heroLvCfg.Def, lvGrow.Defgrow, heroStarCfg.Def, stargrowCfg.StarupDef)
def, _ := mengine.ParseAndExec(exprDef)
curSpeed := hero.Property[comm.Speed]
// 速度
exprSpeed := fmt.Sprintf("%v +%v * %v/1000 + %v * %v/1000",
(curSpeed + lvGrow.Speed), 0, 0, 0, stargrowCfg.StarupSpeed)
lvGrow.Speed, 0, 0, 0, stargrowCfg.StarupSpeed)
speed, _ := mengine.ParseAndExec(exprSpeed)
hero.Property = map[string]int32{
comm.Hp: int32(math.Floor(hp)),