96 lines
2.4 KiB
Go
96 lines
2.4 KiB
Go
package whackamole
|
|
|
|
import (
|
|
"fmt"
|
|
"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"
|
|
game_tdherogrowup = "game_tdherogrowup.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)
|
|
err = this.LoadConfigure(game_tdherogrowup, cfg.NewGameTDHeroGrowup)
|
|
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
|
|
}
|
|
|
|
// 获取奖励列表
|
|
func (this *configureComp) getGameTDHeroData(id int32) (conf *cfg.GameTDHeroData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_tdhero); err != nil {
|
|
return
|
|
}
|
|
if conf, ok = v.(*cfg.GameTDHero).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_tdhero, id)
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getGameTDHeroGrowupData(job int32, lv int32) (conf *cfg.GameTDHeroGrowupData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_tdherogrowup); err != nil {
|
|
return
|
|
}
|
|
for _, v := range v.(*cfg.GameTDHeroGrowup).GetDataList() {
|
|
if v.Job == job && v.Lv == lv {
|
|
conf = v
|
|
return
|
|
}
|
|
}
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_tdherogrowup, fmt.Sprintf("%d-%d", job, lv))
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|