额外消耗天赋点数

This commit is contained in:
meixiongfeng 2022-10-26 11:44:18 +08:00
parent 830df642ab
commit c912ae1c17
2 changed files with 31 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
@ -84,9 +85,26 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
if code = this.module.CheckRes(session, talentConf.Thing); code != pb.ErrorCode_Success {
return
}
// 消耗指定的天赋点数
t := this.module.configure.GetHeroTalentBoxItem(talent.HeroId)
if t != "" && talentConf.Point > 0 {
res := &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.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success {
return
}
}
}
if code = this.module.DispenseRes(session, talentConf.Thing, true); code != pb.ErrorCode_Success {
return
}
// 校验通过可以加
talent.Talent[req.TalentID] = 1
update := make(map[string]interface{}, 0)

View File

@ -62,6 +62,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
hero_starupsp: cfg.NewGameHeroStarupSp,
hero_talentskill: cfg.NewGameTalentSkill,
hero_talent: cfg.NewGameHeroTalent,
hero_itembox: cfg.NewGameItemBox,
})
this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0)
configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, this.SetHeroDrawConfig)
@ -110,10 +111,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
}
})
// 测试接口 功能完成后删
// _data := this.GetHeroTalentSkill(20101)
// _data1 := this.GetHeroTalent(1)
// this.module.Debugf("%v,%v", _data, _data1)
return
}
@ -433,3 +430,15 @@ func (this *configureComp) GetHeroTalentSkill(skillId int32) (data *cfg.GameTale
this.module.Errorf("cfg.GameTalentSkillData GetHeroTalentSkill:skillId = %d", skillId)
return nil
}
// 天赋指定消耗
func (this *configureComp) GetHeroTalentBoxItem(heroid string) (itemid string) {
if v, err := this.GetConfigure(hero_itembox); err == nil {
if configure, ok := v.(*cfg.GameItemBox); ok {
itemid = configure.Get(heroid).Itemid
return
}
}
this.module.Errorf("cfg.GameItemBoxData GetHeroTalentBoxItem:skillId = %d", heroid)
return ""
}