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