go_dreamfactory/modules/battle/configure.go
2022-09-06 11:05:01 +08:00

63 lines
1.5 KiB
Go

package battle
import (
"fmt"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
game_monsterformat = "game_monsterformat.json" //整容表
game_monster = "game_monster.json" //怪物表
)
///背包配置管理组件
type configureComp struct {
modules.MCompConfigure
module *Battle
}
//组件初始化接口
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.(*Battle)
this.LoadConfigure(game_monster, cfg.NewGameMonster)
this.LoadConfigure(game_monsterformat, cfg.NewGameMonsterFormat)
return
}
//查询阵容表
func (this *configureComp) GetMonsterFormat(id int32) (result *cfg.GameMonsterFormatData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_monsterformat); err != nil {
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameMonsterFormat).GetDataMap()[id]; !ok {
err = fmt.Errorf("on found MonsterFormat:%d", id)
this.module.Errorln(err)
}
}
return
}
//查询怪物表
func (this *configureComp) GetMonster(id int32) (result *cfg.GameMonsterData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_monster); err != nil {
this.module.Errorln(err)
} else {
if result, ok = v.(*cfg.GameMonster).GetDataMap()[id]; !ok {
err = fmt.Errorf("on found GameMonster:%d", id)
this.module.Errorln(err)
}
}
return
}