go_dreamfactory/modules/robot/configure.go
2023-09-22 15:44:14 +08:00

95 lines
3.2 KiB
Go

package robot
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
gameWorldTask = "game_worldtask.json"
gameWorldtaskBattle = "game_worldbattle.json"
game_buriedcondi = "game_buriedcondi.json"
game_mainstage = "game_mainstage.json" //主线表
game_equip = "game_equip.json" //装备信息表
game_equipintensify = "game_equipintensify.json" //装备等级消耗表
game_equipenchanting = "game_equipenchanting.json" //装备附魔
equip_suit = "game_equipsuit.json" //装备套装表
game_pagoda = "game_pagoda.json"
hero_talent = "game_herotalent.json" // 天赋详细数据
game_playerlv = "game_playerlv.json"
hero_awaken = "game_heroawaken.json"
game_horoscope = "game_horoscope.json" //星阵图
game_combatlevel = "game_combatlevel.json" //关卡编辑器
)
type configureComp struct {
cbase.ModuleCompBase
module *RobotModule
}
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
this.module = module.(*RobotModule)
configure.RegisterConfigure(gameWorldTask, cfg.NewGameWorldTask, nil)
configure.RegisterConfigure(gameWorldtaskBattle, cfg.NewGameWorldBattle, nil)
configure.RegisterConfigure(game_buriedcondi, cfg.NewGameBuriedCondi, nil)
configure.RegisterConfigure(game_mainstage, cfg.NewGameMainStage, nil)
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, nil)
configure.RegisterConfigure(game_equipintensify, cfg.NewGameEquipIntensify, nil)
configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, nil)
configure.RegisterConfigure(equip_suit, cfg.NewGameEquipSuit, nil)
configure.RegisterConfigure(hero_talent, cfg.NewGameHeroTalent, nil)
configure.RegisterConfigure(game_playerlv, cfg.NewGamePlayerlv, nil)
configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, nil) // 觉醒
configure.RegisterConfigure(game_horoscope, cfg.NewGameHoroscope, nil)
configure.RegisterConfigure(game_horoscope, cfg.NewGameHoroscope, nil)
configure.RegisterConfigure(game_combatlevel, cfg.NewGameCombatLevel, nil)
return
}
//获取任务配置
func (this *configureComp) getGameWorldTaskData(tid int32) (conf *cfg.GameWorldTaskData, err error) {
var (
v interface{}
ok bool
)
if v, err = configure.GetConfigure(gameWorldTask); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameWorldTask).GetDataMap()[tid]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameWorldTask, tid)
log.Errorf("err:%v", err)
return
}
}
return
}
//获取战斗配置
func (this *configureComp) getGameWorldBattleData(confId int32) (conf *cfg.GameWorldBattleData, err error) {
var (
v interface{}
ok bool
)
if v, err = configure.GetConfigure(gameWorldtaskBattle); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameWorldBattle).GetDataMap()[confId]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameWorldtaskBattle, confId)
log.Errorf("err:%v", err)
return
}
}
return
}