package mainline import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" ) const ( game_mainlinechapter = "game_mainlinechapter.json" game_mainlineeasy = "game_mainlineeasy.json" game_mainlinehard = "game_mainlinehard.json" game_mainlinepurgatory = "game_mainlinepurgatory.json" ) ///配置管理基础组件 type configureComp struct { modules.MCompConfigure module *Mainline } //组件初始化接口 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.(*Mainline) err = this.LoadMultiConfigure(map[string]interface{}{ game_mainlinechapter: cfg.NewGamemainlineChapter, game_mainlineeasy: cfg.NewGamemainlineEasy, game_mainlinehard: cfg.NewGamemainlineHard, game_mainlinepurgatory: cfg.NewGamemainlinePurgatory, }) return } //读取配置数据 func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { return configure.GetConfigure(name) } func (this *configureComp) GetMainlineChapter(id int32) (data *cfg.GamemainlineChapterData) { if v, err := this.GetConfigure(game_mainlinechapter); err != nil { this.module.Errorf("get global conf err:%v", err) return } else { var ( configure *cfg.GamemainlineChapter ok bool ) if configure, ok = v.(*cfg.GamemainlineChapter); !ok { this.module.Errorf("%T no is *cfg.Game_mainlineChapterData", v) return } if data, ok = configure.GetDataMap()[id]; ok { return } } return } // 获取简单的关卡配置信息 func (this *configureComp) GetMainlineEasyChapter(id int32) (data *cfg.GamemainlineEasyData) { if v, err := this.GetConfigure(game_mainlineeasy); err != nil { this.module.Errorf("get global conf err:%v", err) return } else { var ( configure *cfg.GamemainlineEasy ok bool ) if configure, ok = v.(*cfg.GamemainlineEasy); !ok { this.module.Errorf("%T no is *cfg.Game_mainlineEasyData", v) return } if data, ok = configure.GetDataMap()[id]; ok { return } } return } // 获取炼狱级别难度的关卡配置 func (this *configureComp) GetMainlinePurgatoryChapter(id int32) (data *cfg.GamemainlinePurgatoryData) { if v, err := this.GetConfigure(game_mainlinepurgatory); err != nil { this.module.Errorf("get global conf err:%v", err) return } else { var ( configure *cfg.GamemainlinePurgatory ok bool ) if configure, ok = v.(*cfg.GamemainlinePurgatory); !ok { this.module.Errorf("%T no is *cfg.Game_mainlinePurgatoryData", v) return } if data, ok = configure.GetDataMap()[id]; ok { return } } return } // 获取困难的关卡配置 func (this *configureComp) GetMainlineHardChapter(id int32) (data *cfg.GamemainlineHardData) { if v, err := this.GetConfigure(game_mainlinehard); err != nil { this.module.Errorf("get global conf err:%v", err) return } else { var ( configure *cfg.GamemainlineHard ok bool ) if configure, ok = v.(*cfg.GamemainlineHard); !ok { this.module.Errorf("%T no is *cfg.Game_mainlineHardData", v) return } if data, ok = configure.GetDataMap()[id]; ok { return } } return }