78 lines
1.9 KiB
Go
78 lines
1.9 KiB
Go
package warorder
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"sync"
|
|
)
|
|
|
|
const (
|
|
game_passcheck = "game_passcheck.json"
|
|
)
|
|
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *Warorder
|
|
lock sync.RWMutex
|
|
product map[string]int32 //商品id
|
|
order map[int32][]*cfg.GamePassCheckData //战令
|
|
}
|
|
|
|
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.(*Warorder)
|
|
configure.RegisterConfigure(game_passcheck, cfg.NewGamePassCheck, this.updateconfigure)
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getproduct() map[string]int32 {
|
|
this.lock.RLock()
|
|
defer this.lock.RUnlock()
|
|
return this.product
|
|
}
|
|
|
|
// 读取任务配置表
|
|
func (this *configureComp) getPassCheckCfg() (data *cfg.GamePassCheck, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_passcheck); err != nil {
|
|
return
|
|
} else {
|
|
if data, ok = v.(*cfg.GamePassCheck); !ok {
|
|
err = fmt.Errorf("%T is *cfg.GameWorldTask", v)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 更新任务配置表
|
|
func (this *configureComp) updateconfigure() {
|
|
gwt, err := this.getPassCheckCfg()
|
|
if err != nil {
|
|
this.module.Error("世界任务配置表异常!")
|
|
return
|
|
}
|
|
productConf := make(map[string]int32)
|
|
orderConf := make(map[int32][]*cfg.GamePassCheckData)
|
|
for _, v := range gwt.GetDataList() {
|
|
if _, ok := productConf[v.PayId]; !ok {
|
|
productConf[v.PayId] = v.PasscheckType
|
|
}
|
|
if _, ok := orderConf[v.PasscheckType]; !ok {
|
|
orderConf[v.PasscheckType] = make([]*cfg.GamePassCheckData, 0)
|
|
}
|
|
orderConf[v.PasscheckType] = append(orderConf[v.PasscheckType], v)
|
|
}
|
|
|
|
this.lock.Lock()
|
|
this.product = productConf
|
|
this.order = orderConf
|
|
this.lock.Unlock()
|
|
}
|