163 lines
4.1 KiB
Go
163 lines
4.1 KiB
Go
package guildgve
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_guildboss = "game_guildboss.json"
|
|
game_guildbossrank = "game_guildbossrank.json"
|
|
game_guildbossroulette = "game_guildbossroulette.json"
|
|
game_guildbossscore = "game_guildbossscore.json"
|
|
)
|
|
|
|
// /配置管理基础组件
|
|
type MCompConfigure struct {
|
|
modules.MCompConfigure
|
|
module *GuildGve
|
|
}
|
|
|
|
// 组件初始化接口
|
|
func (this *MCompConfigure) 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.(*GuildGve)
|
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
|
game_guildboss: cfg.NewGameGuildBoss,
|
|
game_guildbossrank: cfg.NewGameGuildBossRank,
|
|
game_guildbossroulette: cfg.NewGameGuildBossRoulette,
|
|
game_guildbossscore: cfg.NewGameGuildBossScore,
|
|
})
|
|
err = this.LoadConfigure(game_guildboss, cfg.NewGameGuildBoss)
|
|
return
|
|
}
|
|
|
|
// 获取所有难度一的boos
|
|
func (this *MCompConfigure) getguildbossroulette() (results []*cfg.GameGuildBossRouletteData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
|
|
if v, err = this.GetConfigure(game_guildbossroulette); err != nil {
|
|
return
|
|
} else {
|
|
data, ok := v.(*cfg.GameGuildBossRoulette)
|
|
if !ok {
|
|
err = fmt.Errorf("%T no is *cfg.GameGuildActivity", v)
|
|
return
|
|
}
|
|
results = data.GetDataList()
|
|
return
|
|
}
|
|
}
|
|
|
|
// 获取所有难度一的boos
|
|
func (this *MCompConfigure) getguildboss() (results []*cfg.GameGuildBossData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
|
|
if v, err = this.GetConfigure(game_guildboss); err != nil {
|
|
return
|
|
} else {
|
|
data, ok := v.(*cfg.GameGuildBoss)
|
|
if !ok {
|
|
err = fmt.Errorf("%T no is *cfg.GameGuildActivity", v)
|
|
return
|
|
}
|
|
results = make([]*cfg.GameGuildBossData, 0)
|
|
for _, v := range data.GetDataList() {
|
|
if v.BossLv == 1 {
|
|
results = append(results, v)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
// 获取所有难度一的boos
|
|
func (this *MCompConfigure) getguildbossByid(id int32) (results *cfg.GameGuildBossData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
|
|
if v, err = this.GetConfigure(game_guildboss); err != nil {
|
|
return
|
|
} else {
|
|
if results, ok = v.(*cfg.GameGuildBoss).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_guildboss, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取所有难度一的boos
|
|
func (this *MCompConfigure) getguildbossByNext(id int32, lv int32) (results *cfg.GameGuildBossData, err error) {
|
|
var (
|
|
v interface{}
|
|
conf *cfg.GameGuildBossData
|
|
ok bool
|
|
)
|
|
|
|
if v, err = this.GetConfigure(game_guildboss); err != nil {
|
|
return
|
|
} else {
|
|
if conf, ok = v.(*cfg.GameGuildBoss).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_guildboss, id)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
|
|
for _, results = range v.(*cfg.GameGuildBoss).GetDataList() {
|
|
if conf.Group == results.Group && results.BossLv == lv {
|
|
return
|
|
}
|
|
}
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_guildboss, fmt.Sprintf("id:%d lv:%d", id, lv))
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取伤害对应的评分组
|
|
func (this *MCompConfigure) getguildbossscore(group int32, score int32) (conf *cfg.GameGuildBossScoreData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
|
|
if v, err = this.GetConfigure(game_guildbossscore); err != nil {
|
|
return
|
|
} else {
|
|
if conf, ok = v.(*cfg.GameGuildBossScore).GetDataMap()[score]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_guildbossscore, score)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *MCompConfigure) getRankReward() (results *cfg.GameGuildBossRank, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
|
|
if v, err = this.GetConfigure(game_guildbossrank); err != nil {
|
|
return
|
|
} else {
|
|
if results, ok = v.(*cfg.GameGuildBossRank); !ok {
|
|
err = fmt.Errorf("%T no is *cfg.GameGuildBossRank", v)
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|