diff --git a/modules/hero/api_heroStrengthen.go b/modules/hero/api_heroStrengthen.go index ef3565d12..ba3d24f36 100644 --- a/modules/hero/api_heroStrengthen.go +++ b/modules/hero/api_heroStrengthen.go @@ -3,22 +3,33 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "log" ) //参数校验 -func (this *Api_Comp) Hero_Check(session comm.IUserSession, req *pb.Hero_StrengthenUplv_Req) (result map[string]interface{}, code comm.ErrorCode) { +func (this *Api_Comp) StrengthenUplv_Check(session comm.IUserSession, req *pb.Hero_StrengthenUplv_Req) (result map[string]interface{}, code comm.ErrorCode) { + if req.HeroObjID == "" { + code.Code = pb.ErrorCode_ReqParameterError + } + //this.module.model_hero.moduleHero.GetHeroInfoByObjID() return } /// 英雄升级 -func (this *Api_Comp) HeroStrengthenLv(session comm.IUserSession, agrs map[string]interface{}, req *pb.Hero_StrengthenUplv_Req) (code pb.ErrorCode) { +func (this *Api_Comp) StrengthenUplv(session comm.IUserSession, agrs map[string]interface{}, req *pb.Hero_StrengthenUplv_Req) (code pb.ErrorCode) { defer func() { if code == pb.ErrorCode_Success { session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.Hero_StrengthenUplv_Resp{}) } }() - this.module.configure_comp.GetHeroConfigure() + + if configure, err := this.module.configure_comp.GetHeroConfigure(); err != nil { + _data := configure.GetDataMap() + for key, value := range _data { + log.Fatalf("%d,%v", key, value) + } + } return } diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index dd3711f16..d6eab6892 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -31,6 +31,13 @@ func (this *Configure_Comp) Init(service core.IService, module core.IModule, com this.LoadConfigure(game_heroStarup, cfg.NewGame_heroStarup) this.LoadConfigure(game_heroLevelup, cfg.NewGame_heroLevelup) this.LoadConfigure(game_heroExp, cfg.NewGame_heroExp) + + // this.GetHeroConfigure() + // this.GetHeroStargrowCon() + // this.GetHeroLevelgrowCon() + // this.GetHeroStarupCon() + // this.GetHeroLevelUpCon() + // this.GetHeroExpCon() return } @@ -40,13 +47,96 @@ func (this *Configure_Comp) GetHeroConfigure() (configure *cfg.Game_newHero, err v interface{} ok bool ) - if v, err = this.GetConfigure(game_hero); err != nil { - return - } else { + if v, err = this.GetConfigure(game_hero); err == nil { if configure, ok = v.(*cfg.Game_newHero); !ok { err = fmt.Errorf("%T no is *cfg.Game_hero", v) - return } + } else { + err = fmt.Errorf("%T no is *cfg.Game_hero", v) + } + return +} + +// 获取英雄强化增加属性配置数据 +func (this *Configure_Comp) GetHeroStargrowCon() (configure *cfg.Game_heroStargrow, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_heroStargrow); err == nil { + if configure, ok = v.(*cfg.Game_heroStargrow); !ok { + err = fmt.Errorf("%T no is *cfg.Game_hero", v) + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_hero", v) + } + + return +} + +// 获取英雄升级属性变化相关配置数据 +func (this *Configure_Comp) GetHeroLevelgrowCon() (configure *cfg.Game_heroLevelgrow, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_heroLevelgrow); err == nil { + if configure, ok = v.(*cfg.Game_heroLevelgrow); !ok { + err = fmt.Errorf("%T no is *cfg.Game_heroLevelgrow", v) + return + } + + } + return +} + +// 获取英雄升星相关配置数据 +func (this *Configure_Comp) GetHeroStarupCon() (configure *cfg.Game_heroStarup, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_heroStarup); err == nil { + if configure, ok = v.(*cfg.Game_heroStarup); !ok { + err = fmt.Errorf("%T no is *cfg.Game_heroStarup", v) + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_heroStarup", v) + } + return +} + +// 获取英雄升级相关配置数据 +func (this *Configure_Comp) GetHeroLevelUpCon() (configure *cfg.Game_heroLevelup, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_heroLevelup); err == nil { + if configure, ok = v.(*cfg.Game_heroLevelup); !ok { + err = fmt.Errorf("%T no is *cfg.Game_heroLevelup", v) + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_heroLevelup", v) + } + return +} + +func (this *Configure_Comp) GetHeroExpCon() (configure *cfg.Game_heroExp, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_heroExp); err == nil { + if configure, ok = v.(*cfg.Game_heroExp); !ok { + err = fmt.Errorf("%T no is *cfg.Game_heroExp", v) + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_heroExp", v) } return } diff --git a/modules/hero/module.go b/modules/hero/module.go index 4676d0fa2..6a2191026 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -38,6 +38,12 @@ func (this *Hero) OnInstallComp() { this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) } +//通过唯一对象获取英雄信息 +func (this *Hero) GetHeroInfoByObjID(id string) (*pb.DB_HeroData, pb.ErrorCode) { + + return nil, pb.ErrorCode_HeroNoExist +} + //获取英雄 func (this *Hero) GetHero(heroId int32) (*pb.DB_HeroData, pb.ErrorCode) {