go_dreamfactory/modules/linestory/config.go
2022-09-06 17:25:26 +08:00

114 lines
2.7 KiB
Go

package linestory
import (
"fmt"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
gameLinestoryChapter = "game_linestorychapter.json"
gameLinestoryTask = "game_linestorytask.json"
gameLinestoryStagetask = "game_linestorystagetask.json"
)
type configureComp struct {
modules.MCompConfigure
}
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options)
err = this.LoadMultiConfigure(map[string]interface{}{
gameLinestoryChapter: cfg.NewGameLineStoryChapter,
gameLinestoryTask: cfg.NewGameLineStoryTask,
gameLinestoryStagetask: cfg.NewGameLineStoryStageTask,
})
return
}
func (this *configureComp) getLinestoryChapterCfg() (data *cfg.GameLineStoryChapter, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameLinestoryChapter); err != nil {
return
} else {
if data, ok = v.(*cfg.GameLineStoryChapter); !ok {
err = fmt.Errorf("%T no is *cfg.GameLineStoryChapter", v)
return
}
}
return
}
func (this *configureComp) getLinestoryTaskCfg() (data *cfg.GameLineStoryTask, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameLinestoryTask); err != nil {
return
} else {
if data, ok = v.(*cfg.GameLineStoryTask); !ok {
err = fmt.Errorf("%T no is *cfg.GameLineStoryTask", v)
return
}
}
return
}
func (this *configureComp) getLinestoryStageCfg() (data *cfg.GameLineStoryStageTask, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameLinestoryStagetask); err != nil {
return
} else {
if data, ok = v.(*cfg.GameLineStoryStageTask); !ok {
err = fmt.Errorf("%T no is *cfg.GameLineStoryStageTask", v)
return
}
}
return
}
func (this *configureComp) getLinestoryChapterCfgById(id int32) (data *cfg.GameLineStoryChapterData) {
if cfg, err := this.getLinestoryChapterCfg(); err != nil {
log.Errorf("%v", err)
return
} else {
if cfg != nil {
data = cfg.GetDataMap()[id]
}
}
return
}
func (this *configureComp) getLinestoryTaskCfgById(id int32) (data *cfg.GameLineStoryTaskData) {
if cfg, err := this.getLinestoryTaskCfg(); err != nil {
log.Errorf("%v", err)
return
} else {
if cfg != nil {
data = cfg.GetDataMap()[id]
}
}
return
}
func (this *configureComp) getLinestoryStageCfgById(id int32) (data *cfg.GameLineStoryStageTaskData) {
if cfg, err := this.getLinestoryStageCfg(); err != nil {
log.Errorf("%v", err)
return
} else {
if cfg != nil {
data = cfg.GetDataMap()[id]
}
}
return
}