60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package academy
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_teaching = "game_teaching.json"
|
|
)
|
|
|
|
///背包配置管理组件
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *Academy
|
|
}
|
|
|
|
//组件初始化接口
|
|
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.(*Academy)
|
|
this.LoadConfigure(game_teaching, cfg.NewGameTeaching)
|
|
return
|
|
}
|
|
|
|
//查询管卡表
|
|
func (this *configureComp) getGameTeaching(id int32) (result *cfg.GameTeachingData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_teaching); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if result, ok = v.(*cfg.GameTeaching).GetDataMap()[id]; !ok {
|
|
err = fmt.Errorf("on found GameMonster:%s", id)
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询管卡表
|
|
func (this *configureComp) getGameTeachingByGroup(group int32) (result []*cfg.GameTeachingData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_teaching); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
result = make([]*cfg.GameTeachingData, 0)
|
|
for _, v := range v.(*cfg.GameTeaching).GetDataMap() {
|
|
result = append(result, v)
|
|
}
|
|
}
|
|
return
|
|
}
|