diff --git a/modules/hero/api_talentlearn.go b/modules/hero/api_talentlearn.go index d05678c62..8cbb46f6a 100644 --- a/modules/hero/api_talentlearn.go +++ b/modules/hero/api_talentlearn.go @@ -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) diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 96596e120..0cb47011c 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -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 "" +}