go_dreamfactory/modules/shopcenter/configure.go
2023-08-02 15:03:27 +08:00

89 lines
2.6 KiB
Go

package shopcenter
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"sync"
)
const (
game_shopcentercontrol = "game_shopcentercontrol.json"
game_shopcenterfund = "game_shopcenterfund.json"
game_shopcentersubmeter = "game_shopcentersubmeter.json"
)
type configureComp struct {
modules.MCompConfigure
module *ShopCenter
lock sync.RWMutex
tasks map[int32]struct{}
grouptask map[int32]map[int32][]int32
groupreward map[int32]map[int32]*cfg.GameFategiftrewardData
}
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.(*ShopCenter)
this.LoadConfigure(game_shopcentercontrol, cfg.NewGameShopCenterControl)
this.LoadConfigure(game_shopcenterfund, cfg.NewGameShopCenterFund)
this.LoadConfigure(game_shopcentersubmeter, cfg.NewGameShopCenterSubmeter)
// configure.RegisterConfigure(game_shopcentersubmeter, cfg.NewGameFategiftFate, this.updateconfigure)
return
}
// 获取活跃度奖励配置
func (this *configureComp) getGameShopCenterControl(fid int32) (conf *cfg.GameShopCenterControlData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_shopcentercontrol); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameShopCenterControl).GetDataMap()[fid]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_shopcentercontrol, fid)
this.module.Errorln(err)
return
}
}
return
}
// 获取活跃度奖励配置
func (this *configureComp) getGameShopCenterFund(pid int32) (conf *cfg.GameShopCenterFundData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_shopcenterfund); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameShopCenterFund).GetDataMap()[pid]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_shopcenterfund, pid)
this.module.Errorln(err)
return
}
}
return
}
// 获取活跃度奖励配置
func (this *configureComp) getGameShopCenterSubmeter(pid int32) (conf *cfg.GameShopCenterSubmeterData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_shopcentersubmeter); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameShopCenterSubmeter).GetDataMap()[pid]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_shopcentersubmeter, pid)
this.module.Errorln(err)
return
}
}
return
}