99 lines
2.4 KiB
Go
99 lines
2.4 KiB
Go
package horoscope
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_horoscope = "game_horoscope.json" //购买挑战记录
|
|
game_hero = "game_hero.json" //英雄
|
|
)
|
|
|
|
///竞技场配置管理组件
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *Horoscope
|
|
}
|
|
|
|
//组件初始化接口
|
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.MCompConfigure.Init(service, module, comp, options)
|
|
this.module = module.(*Horoscope)
|
|
this.LoadConfigure(game_horoscope, cfg.NewGameHoroscope)
|
|
this.LoadConfigure(game_hero, cfg.NewGameHero)
|
|
return
|
|
}
|
|
|
|
//查询阵容表
|
|
func (this *configureComp) getHoroscope(id int32) (result *cfg.GameHoroscopeData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_horoscope); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if result, ok = v.(*cfg.GameHoroscope).GetDataMap()[id]; !ok {
|
|
err = fmt.Errorf("on found getHoroscope:%d", id)
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询星座信息
|
|
func (this *configureComp) getHoroscopebylv(nodeid, lv int32) (result *cfg.GameHoroscopeData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_horoscope); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
for _, v := range v.(*cfg.GameHoroscope).GetDataMap() {
|
|
if v.NodeId == nodeid && v.Lv == lv {
|
|
result = v
|
|
return
|
|
}
|
|
}
|
|
}
|
|
err = fmt.Errorf("No found Horoscope nodeid:%d lv:%d", nodeid, lv)
|
|
return
|
|
}
|
|
|
|
//获取英雄配置
|
|
func (this *configureComp) getHeroConfig(id string) (result *cfg.GameHeroData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_hero); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if result, ok = v.(*cfg.GameHero).GetDataMap()[id]; !ok {
|
|
err = fmt.Errorf("on found getHeroConfig:%s", id)
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询下一个节点
|
|
func (this *configureComp) getHoroscopes() (result *cfg.GameHoroscope, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_horoscope); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if result, ok = v.(*cfg.GameHoroscope); !ok {
|
|
err = fmt.Errorf("on found game_horoscope 类型异常")
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
return
|
|
}
|