62 lines
1.5 KiB
Go
62 lines
1.5 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 string) (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:%s ", id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取指定特权配置
|
|
func (this *configureComp) GetPrivilegeData(id int32) (result *cfg.GamePrivilegeData) {
|
|
|
|
if v, err := this.GetConfigure(game_privilege); err == nil {
|
|
|
|
if c, ok := v.(*cfg.GamePrivilege); ok {
|
|
result = c.Get(id)
|
|
return
|
|
}
|
|
}
|
|
this.module.Errorf("GetPrivilegeData err, id:%d", id)
|
|
return nil
|
|
}
|