From ad778836cc1a7105832f0745131c90d30cd2856b Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 27 Jun 2022 11:10:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BB=8F=E9=AA=8C=E5=8D=A1=E6=B6=88?= =?UTF-8?q?=E8=80=97=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_heroexp.json | 50 +++++++++++++++++++++++ modules/hero/configure_comp.go | 2 + sys/configure/structs/game.heroExp.go | 42 +++++++++++++++++++ sys/configure/structs/game.heroExpData.go | 35 ++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 bin/json/game_heroexp.json create mode 100644 sys/configure/structs/game.heroExp.go create mode 100644 sys/configure/structs/game.heroExpData.go diff --git a/bin/json/game_heroexp.json b/bin/json/game_heroexp.json new file mode 100644 index 000000000..9e333403f --- /dev/null +++ b/bin/json/game_heroexp.json @@ -0,0 +1,50 @@ +[ + { + "hid": 42911, + "name": "初级经验精灵", + "star": 2, + "color": 1, + "heroexp": 1000, + "skilllevelup": 0 + }, + { + "hid": 43911, + "name": "中级经验精灵", + "star": 3, + "color": 2, + "heroexp": 5000, + "skilllevelup": 0 + }, + { + "hid": 44911, + "name": "高级经验精灵", + "star": 4, + "color": 3, + "heroexp": 20000, + "skilllevelup": 0 + }, + { + "hid": 43921, + "name": "技能精灵·稀有", + "star": 3, + "color": 2, + "heroexp": 0, + "skilllevelup": 1 + }, + { + "hid": 44921, + "name": "技能精灵·史诗", + "star": 4, + "color": 3, + "heroexp": 0, + "skilllevelup": 1 + }, + { + "hid": 45921, + "name": "技能精灵·传说", + "star": 5, + "color": 4, + "heroexp": 0, + "skilllevelup": 1 + } +] \ No newline at end of file diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index de21c1bab..dd3711f16 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -14,6 +14,7 @@ const ( game_heroLevelgrow = "game_heroLevelgrow.json" game_heroStarup = "game_heroStarup.json" game_heroLevelup = "game_heroLevelup.json" + game_heroExp = "game_exp.json" ) ///配置管理组件 @@ -29,6 +30,7 @@ func (this *Configure_Comp) Init(service core.IService, module core.IModule, com this.LoadConfigure(game_heroLevelgrow, cfg.NewGame_heroLevelgrow) this.LoadConfigure(game_heroStarup, cfg.NewGame_heroStarup) this.LoadConfigure(game_heroLevelup, cfg.NewGame_heroLevelup) + this.LoadConfigure(game_heroExp, cfg.NewGame_heroExp) return } diff --git a/sys/configure/structs/game.heroExp.go b/sys/configure/structs/game.heroExp.go new file mode 100644 index 000000000..73283f657 --- /dev/null +++ b/sys/configure/structs/game.heroExp.go @@ -0,0 +1,42 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +package cfg + +type Game_heroExp struct { + _dataMap map[int32]*Game_heroExpData + _dataList []*Game_heroExpData +} + +func NewGame_heroExp(_buf []map[string]interface{}) (*Game_heroExp, error) { + _dataList := make([]*Game_heroExpData, 0, len(_buf)) + dataMap := make(map[int32]*Game_heroExpData) + for _, _ele_ := range _buf { + if _v, err2 := NewGame_heroExpData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Hid] = _v + } + } + return &Game_heroExp{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *Game_heroExp) GetDataMap() map[int32]*Game_heroExpData { + return table._dataMap +} + +func (table *Game_heroExp) GetDataList() []*Game_heroExpData { + return table._dataList +} + +func (table *Game_heroExp) Get(key int32) *Game_heroExpData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/game.heroExpData.go b/sys/configure/structs/game.heroExpData.go new file mode 100644 index 000000000..a48bbdeb4 --- /dev/null +++ b/sys/configure/structs/game.heroExpData.go @@ -0,0 +1,35 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +package cfg + +import "errors" + +type Game_heroExpData struct { + Hid int32 + Name string + Star int32 + Color int32 + Heroexp int32 + Skilllevelup int32 +} + +func (Game_heroExpData) GetTypeId() int { + return 2029779473 +} + +func NewGame_heroExpData(_buf map[string]interface{}) (_v *Game_heroExpData, err error) { + _v = &Game_heroExpData{} + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["hid"].(float64); !_ok_ { err = errors.New("hid error"); return }; _v.Hid = int32(_tempNum_) } + { var _ok_ bool; if _v.Name, _ok_ = _buf["name"].(string); !_ok_ { err = errors.New("name error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["color"].(float64); !_ok_ { err = errors.New("color error"); return }; _v.Color = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["heroexp"].(float64); !_ok_ { err = errors.New("heroexp error"); return }; _v.Heroexp = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skilllevelup"].(float64); !_ok_ { err = errors.New("skilllevelup error"); return }; _v.Skilllevelup = int32(_tempNum_) } + return +} From 05226c76f2f72c98b8e401650e27059f82b126a8 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 27 Jun 2022 15:45:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_heroStrengthen.go | 17 +++++- modules/hero/configure_comp.go | 98 ++++++++++++++++++++++++++++-- modules/hero/module.go | 6 ++ 3 files changed, 114 insertions(+), 7 deletions(-) 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) {