118 lines
3.2 KiB
Go
118 lines
3.2 KiB
Go
package storyline
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"sync"
|
|
)
|
|
|
|
const (
|
|
game_heroupstory = "game_heroupstory.json"
|
|
game_heroupstorybattle = "game_heroupstorybattle.json"
|
|
game_heroupstorychapter = "game_heroupstorychapter.json"
|
|
game_heroupstorychaptertxt = "game_heroupstorychaptertxt.json"
|
|
)
|
|
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *StoryLine
|
|
lock sync.RWMutex
|
|
tasks map[int32]struct{}
|
|
groupTasks map[int32][]*cfg.GameVenturegiftsTaskData //key 条件ID
|
|
}
|
|
|
|
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)
|
|
this.module = module.(*StoryLine)
|
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
|
game_heroupstory: cfg.NewGameHeroupstory,
|
|
game_heroupstorybattle: cfg.NewGameHeroupstoryBattle,
|
|
game_heroupstorychapter: cfg.NewGameHeroupstoryChapter,
|
|
game_heroupstorychaptertxt: cfg.NewGameHeroupstoryChaptertxt,
|
|
})
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getGameHeroupstory() (confs []*cfg.GameHeroupstoryData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_heroupstory); err != nil {
|
|
return
|
|
} else {
|
|
confs = v.(*cfg.GameHeroupstory).GetDataList()
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getGameHeroupstoryById(id int32) (conf *cfg.GameHeroupstoryData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_heroupstory); err != nil {
|
|
return
|
|
} else {
|
|
if conf, ok = v.(*cfg.GameHeroupstory).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_heroupstory, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getGameHeroupstoryChapter(id int32) (conf *cfg.GameHeroupstoryChapterData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_heroupstorychapter); err != nil {
|
|
return
|
|
} else {
|
|
if conf, ok = v.(*cfg.GameHeroupstoryChapter).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_heroupstorychapter, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getGameHeroupstoryBattle(id int32) (conf *cfg.GameHeroupstoryBattleData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_heroupstorybattle); err != nil {
|
|
return
|
|
} else {
|
|
if conf, ok = v.(*cfg.GameHeroupstoryBattle).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_heroupstorybattle, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//获取章节信息
|
|
func (this *configureComp) getGameHeroupstoryChaptertxt(id int32) (conf *cfg.GameHeroupstoryChaptertxtData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_heroupstorychaptertxt); err != nil {
|
|
return
|
|
} else {
|
|
if conf, ok = v.(*cfg.GameHeroupstoryChaptertxt).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_heroupstorychaptertxt, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|