72 lines
1.4 KiB
Go
72 lines
1.4 KiB
Go
package rtask
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
gameTaskCond = "game_rdtaskcondi.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{}{
|
|
gameTaskCond: cfg.NewGameRdtaskCondi,
|
|
})
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getRtaskCondiCfg() (data *cfg.GameRdtaskCondi, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(gameTaskCond); err != nil {
|
|
return
|
|
} else {
|
|
if data, ok = v.(*cfg.GameRdtaskCondi); !ok {
|
|
err = fmt.Errorf("%T is *cfg.GameRdtaskCondi", v)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
|
|
// 查询任务类型
|
|
func (this *configureComp) getRtaskTypeById(typeId int32) (data *cfg.GameRdtaskCondiData, err error) {
|
|
cfg, err := this.getRtaskCondiCfg()
|
|
if err != nil {
|
|
return
|
|
}
|
|
if cfg != nil {
|
|
if data, ok := cfg.GetDataMap()[typeId]; ok {
|
|
return data, nil
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getRtaskCondis(typeId int32) (list []*cfg.GameRdtaskCondiData) {
|
|
cfg, err := this.getRtaskCondiCfg()
|
|
if err != nil {
|
|
return
|
|
}
|
|
if cfg != nil {
|
|
for _, v := range cfg.GetDataList() {
|
|
if v.Type == typeId {
|
|
list = append(list, v)
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|