go_dreamfactory/modules/robot/configure.go
2023-08-23 18:34:19 +08:00

79 lines
2.3 KiB
Go

package robot
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
gameWorldTask = "game_worldtask.json"
gameWorldtaskBattle = "game_worldbattle.json"
game_buriedcondi = "game_buriedcondi.json"
game_mainstage = "game_mainstage.json" //主线表
// gameWorldAll = "game_worldall.json"
// gameburiedCond = "game_buriedcondi.json"
// gamerdtasknpc = "game_rdtasknpc.json"
// gamesearchitemall = "game_searchitemall.json"
// gamesearchitembox = "game_searchitembox.json"
// game_worlddeal = "game_worlddeal.json"
// game_worldrd = "game_worldrd.json"
)
type configureComp struct {
cbase.ModuleCompBase
module *RobotModule
}
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
this.module = module.(*RobotModule)
configure.RegisterConfigure(gameWorldTask, cfg.NewGameWorldTask, nil)
configure.RegisterConfigure(gameWorldtaskBattle, cfg.NewGameWorldBattle, nil)
configure.RegisterConfigure(game_buriedcondi, cfg.NewGameBuriedCondi, nil)
configure.RegisterConfigure(game_mainstage, cfg.NewGameMainStage, nil)
return
}
//获取任务配置
func (this *configureComp) getGameWorldTaskData(tid int32) (conf *cfg.GameWorldTaskData, err error) {
var (
v interface{}
ok bool
)
if v, err = configure.GetConfigure(gameWorldTask); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameWorldTask).GetDataMap()[tid]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameWorldTask, tid)
log.Errorf("err:%v", err)
return
}
}
return
}
//获取战斗配置
func (this *configureComp) getGameWorldBattleData(confId int32) (conf *cfg.GameWorldBattleData, err error) {
var (
v interface{}
ok bool
)
if v, err = configure.GetConfigure(gameWorldtaskBattle); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameWorldBattle).GetDataMap()[confId]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameWorldtaskBattle, confId)
log.Errorf("err:%v", err)
return
}
}
return
}