天赋学习 道具不够的情况可使用其他道具替代
This commit is contained in:
parent
de3315de63
commit
66c5f1788d
@ -22,6 +22,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
talent *pb.DBHeroTalent
|
||||
err error
|
||||
chanegCard []*pb.DBHero // 推送属性变化
|
||||
res []*cfg.Gameatn // 学习天赋需要消耗的道具
|
||||
)
|
||||
chanegCard = make([]*pb.DBHero, 0)
|
||||
if code = this.TalentLearnCheck(session, req); code != pb.ErrorCode_Success {
|
||||
@ -81,27 +82,38 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
|
||||
}
|
||||
}
|
||||
}
|
||||
// 校验消耗
|
||||
if code = this.module.CheckRes(session, talentConf.Thing); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
res = append(res, talentConf.Thing...)
|
||||
// 消耗指定的天赋点数
|
||||
t := this.module.configure.GetHeroTalentBoxItem(talent.HeroId)
|
||||
if t != "" && talentConf.Point > 0 {
|
||||
res := &cfg.Gameatn{
|
||||
|
||||
curItemCount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), t))
|
||||
if curItemCount < talentConf.Point { // 如果数量不够 则取找其他物品替代
|
||||
leftCount := talentConf.Point - curItemCount // 需要其他物品的数量
|
||||
generaltp := this.module.configure.GetGlobalConf().Generaltp
|
||||
otherCount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), generaltp))
|
||||
if leftCount <= otherCount { // 其他物品够扣
|
||||
point := &cfg.Gameatn{
|
||||
A: "item",
|
||||
T: generaltp,
|
||||
N: leftCount,
|
||||
}
|
||||
res = append(res, point)
|
||||
} else { // 其他替代的道具也不足 直接返回
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
return
|
||||
}
|
||||
} else {
|
||||
point := &cfg.Gameatn{
|
||||
A: "item",
|
||||
T: t,
|
||||
N: talentConf.Point,
|
||||
}
|
||||
if code = this.module.CheckRes(session, []*cfg.Gameatn{res}); code != pb.ErrorCode_Success {
|
||||
return
|
||||
} else {
|
||||
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
res = append(res, point)
|
||||
}
|
||||
}
|
||||
}
|
||||
if code = this.module.ConsumeRes(session, talentConf.Thing, true); code != pb.ErrorCode_Success {
|
||||
if code = this.module.ConsumeRes(session, res, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -804,7 +804,12 @@ func (this *ModelHero) resetTalentProperty(hero *pb.DBHero) {
|
||||
func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, count int32) (hero *pb.DBHero, bFirst bool, atno []*pb.UserAtno, err error) {
|
||||
heros := make([]*pb.DBHero, 0)
|
||||
uid := session.GetUserId()
|
||||
|
||||
heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId)
|
||||
if heroCfg == nil {
|
||||
err = errors.New("not found hero configID")
|
||||
this.moduleHero.Errorf("not found hero configID:%s", heroCfgId)
|
||||
return
|
||||
}
|
||||
if this.moduleHero.IsCross() {
|
||||
if dbModel, err := this.moduleHero.GetDBModuleByUid(uid, this.TableName, this.Expired); err != nil {
|
||||
this.moduleHero.Errorln(err)
|
||||
@ -842,7 +847,8 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
||||
|
||||
// 转碎片处理
|
||||
if count > 0 {
|
||||
heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId)
|
||||
res := make([]*cfg.Gameatn, 0)
|
||||
|
||||
// 如果技能是满级 则转成其他道具
|
||||
if this.checkHeroAllSkillMax(hero) {
|
||||
list := this.moduleHero.configure.GetGlobalConf().Moonshopmoney
|
||||
@ -850,8 +856,6 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
||||
|
||||
for pos, v := range list {
|
||||
if int32(pos)+3 == heroCfg.Star && v > 0 {
|
||||
res := make([]*cfg.Gameatn, 0)
|
||||
|
||||
res = append(res, &cfg.Gameatn{
|
||||
A: "attr",
|
||||
T: "moongold",
|
||||
@ -862,15 +866,11 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
||||
T: "moongold",
|
||||
N: v * count,
|
||||
})
|
||||
this.moduleHero.DispenseRes(session, res, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId)
|
||||
if heroCfg != nil {
|
||||
res := make([]*cfg.Gameatn, 0)
|
||||
for i := 0; i < int(count); i++ {
|
||||
res = append(res, heroCfg.Herofrag...)
|
||||
for _, v := range heroCfg.Herofrag {
|
||||
@ -881,16 +881,15 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
||||
})
|
||||
}
|
||||
}
|
||||
this.moduleHero.DispenseRes(session, res, true)
|
||||
}
|
||||
}
|
||||
|
||||
// expitem 获得
|
||||
if rst, err := this.moduleHero.ModuleUser.GetUserExpand(session.GetUserId()); err == nil { // 统计主线进度
|
||||
_mp := rst.Expitem
|
||||
bAdd := false
|
||||
if heroCfg.Expitemnum > 0 {
|
||||
if v, ok := _mp[hero.HeroID]; ok {
|
||||
if v < heroCfg.Expitemnum {
|
||||
if heroCfg.Expitemnum > v {
|
||||
_mp[hero.HeroID] += 1
|
||||
bAdd = true
|
||||
}
|
||||
@ -898,11 +897,11 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
||||
_mp[hero.HeroID] = 1
|
||||
bAdd = true
|
||||
}
|
||||
}
|
||||
if bAdd {
|
||||
this.moduleHero.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
||||
"expitem": _mp,
|
||||
})
|
||||
res := make([]*cfg.Gameatn, 0)
|
||||
for i := 0; i < int(count); i++ {
|
||||
res = append(res, heroCfg.Expitem...)
|
||||
for _, v := range heroCfg.Herofrag {
|
||||
@ -913,9 +912,11 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
||||
})
|
||||
}
|
||||
}
|
||||
this.moduleHero.DispenseRes(session, res, true)
|
||||
}
|
||||
}
|
||||
if len(res) > 0 { // 资源统一发放
|
||||
this.moduleHero.DispenseRes(session, res, true)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user