go_dreamfactory/modules/weektask/configure.go
2023-08-30 18:46:17 +08:00

106 lines
2.6 KiB
Go

package weektask
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"sync"
)
const (
gameActiveReward = "game_taskactivereward.json"
gameTaskRound = "game_taskround.json"
)
type configureComp struct {
modules.MCompConfigure
module *WeekTask
lock sync.RWMutex
groupTasks map[int32][]*cfg.GameAnnulartask_LibraryData //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.(*WeekTask)
err = this.LoadMultiConfigure(map[string]interface{}{
gameTaskRound: cfg.NewGameTaskRound,
gameActiveReward: cfg.NewGameActiveReward,
})
return
}
// 随机获取任务组
func (this *configureComp) getGameTaskRoundData(id int32) (conf *cfg.GameTaskRoundData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameTaskRound); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameTaskRound).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameActiveReward, id)
this.module.Errorln(err)
return
}
return
}
}
// 随机获取任务组
func (this *configureComp) getGameTaskRoundDatas() (confs []*cfg.GameTaskRoundData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(gameTaskRound); err != nil {
return
} else {
confs = v.(*cfg.GameTaskRound).GetDataList()
return
}
}
// 随机获取任务组
func (this *configureComp) getGameTaskRoundDatasByids(ids []int32) (confs []*cfg.GameTaskRoundData, err error) {
var (
v interface{}
c *cfg.GameTaskRound
conf *cfg.GameTaskRoundData
ok bool
)
if v, err = this.GetConfigure(gameTaskRound); err != nil {
return
} else {
c = v.(*cfg.GameTaskRound)
confs = make([]*cfg.GameTaskRoundData, 0)
for _, id := range ids {
if conf, ok = c.GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameActiveReward, id)
this.module.Errorln(err)
return
}
confs = append(confs, conf)
}
return
}
}
// 随机获取任务组
func (this *configureComp) getGameActiveRewardData(id int32) (conf *cfg.GameActiveRewardData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameActiveReward); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameActiveReward).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameActiveReward, id)
this.module.Errorln(err)
return
}
return
}
}