88 lines
2.7 KiB
Go
88 lines
2.7 KiB
Go
package realarena
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"sync"
|
|
)
|
|
|
|
const (
|
|
game_arenarealtimeconfig = "game_arenarealtimeconfig.json" //购买挑战记录
|
|
game_arenarealtimerankreward = "game_arenarealtimerankreward.json"
|
|
game_arenarealtimewinstreak = "game_arenarealtimewinstreak.json"
|
|
game_arenarealtimeopentime = "game_arenarealtimeopentime.json" //开启时间
|
|
)
|
|
|
|
///竞技场配置管理组件
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *RealArena
|
|
lock sync.RWMutex
|
|
ais map[int32][]*cfg.GameArenaRobotData
|
|
mformatlock sync.RWMutex
|
|
mformat map[int32][]*cfg.GameMonsterFormatData //怪物阵营表
|
|
}
|
|
|
|
//组件初始化接口
|
|
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.(*RealArena)
|
|
this.LoadConfigure(game_arenarealtimeopentime, cfg.NewGameArenarealtimeOpentime)
|
|
this.LoadConfigure(game_arenarealtimeconfig, cfg.NewGameArenarealtimeConfig)
|
|
this.LoadConfigure(game_arenarealtimerankreward, cfg.NewGameArenarealtimeRankreward)
|
|
this.LoadConfigure(game_arenarealtimewinstreak, cfg.NewGameArenarealtimeWinStreak)
|
|
return
|
|
}
|
|
|
|
//查询积分段位信息
|
|
func (this *configureComp) getGameArenarealtimeConfigByIntegral(integral int32) (conf *cfg.GameArenarealtimeConfigData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_arenarealtimeconfig); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
for _, conf = range v.(*cfg.GameArenarealtimeConfig).GetDataList() {
|
|
if integral >= conf.RankMin && integral <= conf.RankMax {
|
|
return
|
|
}
|
|
}
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_arenarealtimeconfig, integral)
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询积分段位信息
|
|
func (this *configureComp) getGameArenarealtimeConfig(dan int32) (conf *cfg.GameArenarealtimeConfigData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_arenarealtimeconfig); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if conf, ok = v.(*cfg.GameArenarealtimeConfig).GetDataMap()[dan]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_arenarealtimeconfig, dan)
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//获取全部开启时间
|
|
func (this *configureComp) GetGameArenarealtimeOpentime() (conf *cfg.GameArenarealtimeOpentime, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_arenarealtimeopentime); err == nil {
|
|
conf = v.(*cfg.GameArenarealtimeOpentime)
|
|
return
|
|
}
|
|
return
|
|
}
|