Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
df5f033b1c
@ -3,7 +3,6 @@ package hero
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -34,7 +33,6 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
_costExpHero map[string]*pb.DBHero // 消耗英雄
|
||||
minAddExp int32
|
||||
_changeHero []*pb.DBHero // 变化的英雄
|
||||
iLvUp int32 // 当前升级次数
|
||||
_mapCost map[string]int32 //
|
||||
)
|
||||
_costExpHero = make(map[string]*pb.DBHero, 0)
|
||||
@ -107,11 +105,11 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
}
|
||||
curLv := _hero.Lv
|
||||
// 执行升级逻辑
|
||||
newhero, code := this.module.modelHero.AddCardExp(session.GetUserId(), _hero, addExp) // 加经验
|
||||
newhero, code := this.module.modelHero.AddCardExp(session, _hero, addExp) // 加经验
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
iLvUp = _hero.Lv - curLv
|
||||
iLvUp := _hero.Lv - curLv
|
||||
// 消耗金币
|
||||
code = this.module.ModuleUser.AddAttributeValue(session, comm.ResGold, -costGold, true)
|
||||
if code != pb.ErrorCode_Success { // 金币不足
|
||||
@ -130,39 +128,15 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
}
|
||||
_changeHero = append(_changeHero, _costExpHero[k])
|
||||
}
|
||||
|
||||
this.module.modelHero.ChangeHeroProperty(session, _hero) // 重新计算属性值
|
||||
if iLvUp > 0 {
|
||||
this.module.modelHero.ChangeHeroProperty(session, _hero) // 重新计算属性值
|
||||
}
|
||||
|
||||
_changeHero = append(_changeHero, _hero) // 升级后的英雄 hero id 不变
|
||||
if newhero != nil {
|
||||
_changeHero = append(_changeHero, newhero) // 原来的英雄 只是数量变化了
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: _changeHero})
|
||||
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
|
||||
if iLvUp > 0 { // 升级了 统计任务
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype4, utils.ToInt32(_hero.HeroID), _hero.Lv)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype23, 1, _hero.Star, _hero.Lv)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype24, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype29, 1, _hero.Lv, utils.ToInt32(_hero.HeroID))
|
||||
cfg := this.module.configure.GetHero(_hero.HeroID)
|
||||
if cfg != nil {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype32, 1, cfg.Color, _hero.Lv)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, _hero.JuexingLv)
|
||||
//xx英雄满级、共鸣、觉醒至最高状态
|
||||
nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
|
||||
if nextAwaken == nil { // 达到满级觉醒
|
||||
resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, cfg.Star)
|
||||
if resonConfig.Maxnum == _hero.ResonateNum { // 共鸣满
|
||||
if _hero.Lv == _hero.Star*comm.HeroStarLvRatio {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype33, 1, 1, _hero.Lv)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
"math"
|
||||
"math/big"
|
||||
"reflect"
|
||||
@ -500,10 +501,11 @@ func (this *ModelHero) cleanData(uid string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ModelHero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhero *pb.DBHero, code pb.ErrorCode) {
|
||||
func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, exp int32) (newhero *pb.DBHero, code pb.ErrorCode) {
|
||||
var (
|
||||
curExp int32
|
||||
curLv int32
|
||||
preLv int32 //加经验之前的等级
|
||||
curExp int32 // 加经验之后的经验
|
||||
curLv int32 // 加经验之后的等级
|
||||
update map[string]interface{} // 属性变化
|
||||
)
|
||||
if hero == nil {
|
||||
@ -513,7 +515,7 @@ func (this *ModelHero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhe
|
||||
update = make(map[string]interface{}, 0)
|
||||
curExp = hero.Exp
|
||||
curLv = hero.Lv
|
||||
|
||||
preLv = curLv
|
||||
var maxLv int32 // 校验等级达到上限
|
||||
maxLv = hero.Star * comm.HeroStarLvRatio
|
||||
_data := this.moduleHero.configure.GetHeroLv(curLv)
|
||||
@ -566,11 +568,33 @@ func (this *ModelHero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhe
|
||||
hero.IsOverlying = false
|
||||
hero.SameCount = 1
|
||||
this.moduleHero.Debugf("add hero exp :%v", hero)
|
||||
if err := this.ChangeList(uid, hero.Id, update); err != nil {
|
||||
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.Rtype4, utils.ToInt32(hero.HeroID), hero.Lv)
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype23, 1, hero.Star, hero.Lv)
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype24, 1)
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype29, 1, hero.Lv, utils.ToInt32(hero.HeroID))
|
||||
cfg := this.moduleHero.configure.GetHero(hero.HeroID)
|
||||
if cfg != nil {
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype32, 1, cfg.Color, hero.Lv)
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, hero.JuexingLv)
|
||||
//xx英雄满级、共鸣、觉醒至最高状态
|
||||
nextAwaken := this.moduleHero.configure.GetHeroAwakenConfig(hero.HeroID, hero.JuexingLv+1)
|
||||
if nextAwaken == nil { // 达到满级觉醒
|
||||
resonConfig := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID, cfg.Star)
|
||||
if resonConfig.Maxnum == hero.ResonateNum { // 共鸣满
|
||||
if hero.Lv == hero.Star*comm.HeroStarLvRatio {
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype33, 1, 1, hero.Lv)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp in
|
||||
return
|
||||
}
|
||||
//this.Debug("AddHeroExp", log.Field{Key: "hero", Value: _hero})
|
||||
newhero, code = this.modelHero.AddCardExp(session.GetUserId(), _hero, exp)
|
||||
newhero, code = this.modelHero.AddCardExp(session, _hero, exp)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user