go_dreamfactory/modules/whackamole/configure.go
2023-12-27 10:23:22 +08:00

58 lines
1.4 KiB
Go

package whackamole
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"sync"
)
const (
game_tdreward = "game_tdreward.json"
game_tdhero = "game_tdhero.json"
)
type configureComp struct {
modules.MCompConfigure
module *Whackamole
lock sync.RWMutex
}
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.(*Whackamole)
err = this.LoadConfigure(game_tdreward, cfg.NewGameTDReward)
err = this.LoadConfigure(game_tdhero, cfg.NewGameTDHero)
return
}
// 获取奖励列表
func (this *configureComp) getGameTDRewardData(id int32) (conf *cfg.GameTDRewardData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_tdreward); err != nil {
return
}
if conf, ok = v.(*cfg.GameTDReward).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_tdreward, id)
this.module.Errorln(err)
return
}
return
}
// 获取奖励列表
func (this *configureComp) getGameTDHeroDatas() (confs []*cfg.GameTDHeroData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_tdhero); err != nil {
return
}
confs = v.(*cfg.GameTDHero).GetDataList()
return
}