go_dreamfactory/modules/privilege/configure.go

67 lines
1.6 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)
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("GamePrivilegeCardData 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("GamePrivilegeData not found:%d ", id)
this.module.Errorf("err:%v", err)
return
}
}
return
}