go_dreamfactory/modules/privilege/configure.go
2022-11-04 18:48:47 +08:00

69 lines
1.7 KiB
Go

package privilege
import (
"fmt"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
game_privilegecard = "game_privilegecard.json"
game_privilege = "game_privilege.json"
)
///背包配置管理组件
type configureComp struct {
modules.MCompConfigure
module *Privilege
}
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Privilege)
this.LoadConfigure(game_privilegecard, cfg.NewGamePrivilegeCard)
this.LoadConfigure(game_privilege, cfg.NewGamePrivilege)
// _d, err := this.GetPrivilegeCard(1)
// _d1, err := this.GetPrivilegeData(10003)
// fmt.Errorf("%v,%v", _d, _d1)
return
}
func (this *configureComp) GetPrivilegeCard(id int32) (configure *cfg.GamePrivilegeCardData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_privilegecard); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.GamePrivilegeCard).GetDataMap()[id]; !ok {
err = fmt.Errorf("ShopConfigure not found:%d ", id)
this.module.Errorf("err:%v", err)
return
}
}
return
}
func (this *configureComp) GetPrivilegeData(id int32) (result *cfg.GamePrivilegeData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_privilege); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if result, ok = v.(*cfg.GamePrivilege).GetDataMap()[id]; !ok {
err = fmt.Errorf("ShopConfigure not found:%d ", id)
this.module.Errorf("err:%v", err)
return
}
}
return
}