114 lines
3.0 KiB
Go
114 lines
3.0 KiB
Go
package catchbugs
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_catchbugstage = "game_catchbugstage.json"
|
|
game_catchbugreward = "game_catchbugreward.json"
|
|
game_catchbuglllustrated = "game_catchbuglllustrated.json"
|
|
game_catchbugskill = "game_catchbugskill.json"
|
|
)
|
|
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *CatchBugs
|
|
}
|
|
|
|
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.(*CatchBugs)
|
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
|
game_catchbugstage: cfg.NewGameCatchbugStage,
|
|
game_catchbugreward: cfg.NewGameCatchbugReward,
|
|
game_catchbuglllustrated: cfg.NewGameCatchbugLllustrated,
|
|
game_catchbugskill: cfg.NewGameCatchbugSkill,
|
|
})
|
|
return
|
|
}
|
|
|
|
// 获取奖励列表
|
|
func (this *configureComp) getGameGColorRewardDatas() (confs []*cfg.GameCatchbugRewardData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_catchbugreward); err != nil {
|
|
return
|
|
}
|
|
confs = v.(*cfg.GameCatchbugReward).GetDataList()
|
|
return
|
|
}
|
|
|
|
// 获取奖励列表
|
|
func (this *configureComp) getGameCatchbugLllustratedDatas() (confs []*cfg.GameCatchbugLllustratedData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_catchbuglllustrated); err != nil {
|
|
return
|
|
}
|
|
confs = v.(*cfg.GameCatchbugLllustrated).GetDataList()
|
|
return
|
|
}
|
|
|
|
// 获取奖励列表
|
|
func (this *configureComp) getGameCatchbugSkillData(id int32) (conf *cfg.GameCatchbugSkillData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_catchbugskill); err != nil {
|
|
return
|
|
}
|
|
if conf, ok = v.(*cfg.GameCatchbugSkill).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_catchbugskill, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取奖励列表
|
|
func (this *configureComp) getGameCatchbugStage(id int32) (conf *cfg.GameCatchbugStageData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_catchbugstage); err != nil {
|
|
return
|
|
}
|
|
if conf, ok = v.(*cfg.GameCatchbugStage).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_catchbugstage, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取奖励列表
|
|
func (this *configureComp) getNextGameCatchbugStage(id int32) (conf *cfg.GameCatchbugStageData, err error) {
|
|
var (
|
|
v interface{}
|
|
confs []*cfg.GameCatchbugStageData
|
|
)
|
|
if v, err = this.GetConfigure(game_catchbugstage); err != nil {
|
|
return
|
|
}
|
|
confs = v.(*cfg.GameCatchbugStage).GetDataList()
|
|
if id == 0 || confs[len(confs)-1].Id == id {
|
|
conf = v.(*cfg.GameCatchbugStage).GetDataList()[1]
|
|
return
|
|
}
|
|
for i, v := range confs {
|
|
if v.Id == id {
|
|
conf = confs[i+1]
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|