package worldtask import ( "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/modules" cfg "go_dreamfactory/sys/configure/structs" ) const ( gameWorldTask = "game_worldtask.json" gameWorldtaskBattle = "game_worldbattle.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{}{ gameWorldTask: cfg.NewGameWorldTask, gameWorldtaskBattle: cfg.NewGameWorldBattle, }) return } func (this *configureComp) getWorldtaskCfg() (data *cfg.GameWorldTask, err error) { var ( v interface{} ok bool ) if v, err = this.GetConfigure(gameWorldTask); err != nil { return } else { if data, ok = v.(*cfg.GameWorldTask); !ok { err = fmt.Errorf("%T is *cfg.GameWorldTask", v) return } } return } func (this *configureComp) getWorldtaskById(taskId int32) (*cfg.GameWorldTaskData, error) { gwt, err := this.getWorldtaskCfg() if err != nil { return nil, err } if data, ok := gwt.GetDataMap()[taskId]; ok { return data, nil } return nil, fmt.Errorf("GameWorldTask config id:%v not found", taskId) } func (this *configureComp) getWorldtaskBattleCfg() (data *cfg.GameWorldBattle, err error) { var ( v interface{} ok bool ) if v, err = this.GetConfigure(gameWorldtaskBattle); err != nil { return } else { if data, ok = v.(*cfg.GameWorldBattle); !ok { err = fmt.Errorf("%T is *cfg.GameWorldBattle", v) return } } return } func (this *configureComp) getWorldtaskBattleById(confId int32) (*cfg.GameWorldBattleData, error) { gwt, err := this.getWorldtaskBattleCfg() if err != nil { return nil, err } if data, ok := gwt.GetDataMap()[confId]; ok { return data, nil } return nil, fmt.Errorf("GameWorldBattleData config id:%v not found", confId) }