85 lines
2.1 KiB
Go
85 lines
2.1 KiB
Go
package kftask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"sync"
|
|
)
|
|
|
|
const (
|
|
game_venturegiftstask = "game_venturegiftstask.json"
|
|
)
|
|
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *KFTask
|
|
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.(*KFTask)
|
|
configure.RegisterConfigure(game_venturegiftstask, cfg.NewGameVenturegiftsTask, this.updateconfigure)
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) gettasks() map[int32]struct{} {
|
|
this.lock.RLock()
|
|
defer this.lock.RUnlock()
|
|
return this.tasks
|
|
}
|
|
|
|
// 更新任务配置表
|
|
func (this *configureComp) updateconfigure() {
|
|
var (
|
|
v interface{}
|
|
conf *cfg.GameVenturegiftsTask
|
|
ok bool
|
|
err error
|
|
)
|
|
if v, err = this.GetConfigure(game_venturegiftstask); err != nil {
|
|
return
|
|
}
|
|
if conf, ok = v.(*cfg.GameVenturegiftsTask); !ok {
|
|
this.module.Error("日常任务配置异常!")
|
|
return
|
|
}
|
|
tasks := make(map[int32]struct{})
|
|
groupTasksConf := make(map[int32][]*cfg.GameVenturegiftsTaskData)
|
|
|
|
for _, v := range conf.GetDataList() {
|
|
|
|
if _, ok := groupTasksConf[v.Openday]; !ok {
|
|
groupTasksConf[v.Openday] = make([]*cfg.GameVenturegiftsTaskData, 0)
|
|
}
|
|
groupTasksConf[v.Openday] = append(groupTasksConf[v.Openday], v)
|
|
tasks[v.Venturetask] = struct{}{}
|
|
}
|
|
|
|
this.lock.Lock()
|
|
this.groupTasks = groupTasksConf
|
|
this.tasks = tasks
|
|
this.lock.Unlock()
|
|
}
|
|
|
|
func (this *configureComp) getGameVenturegiftsTask(id int32) (conf *cfg.GameVenturegiftsTaskData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_venturegiftstask); err != nil {
|
|
return
|
|
}
|
|
if conf, ok = v.(*cfg.GameVenturegiftsTask).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_venturegiftstask, id)
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
return
|
|
}
|