97 lines
2.5 KiB
Go
97 lines
2.5 KiB
Go
package capturesheep
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_buzkashiopen = "game_buzkashiopen.json"
|
|
game_arenarobot = "game_arenarobot.json" //ai配置表
|
|
game_qualifying = "game_qualifying.json" //段位
|
|
)
|
|
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *CaptureSheep
|
|
}
|
|
|
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
err = this.MCompConfigure.Init(service, module, comp, options)
|
|
this.module = module.(*CaptureSheep)
|
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
|
game_arenarobot: cfg.NewGameArenaRobot,
|
|
game_buzkashiopen: cfg.NewGameBuzkashiOpen,
|
|
game_qualifying: cfg.NewGameQualifying,
|
|
})
|
|
return
|
|
}
|
|
|
|
// 查询开启表
|
|
func (this *configureComp) isopen() (open bool) {
|
|
var (
|
|
v interface{}
|
|
config *cfg.GameBuzkashiOpen
|
|
currtime string = configure.Now().Format("15:04")
|
|
err error
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_buzkashiopen); err != nil {
|
|
this.module.Errorln(err)
|
|
return
|
|
} else {
|
|
if config, ok = v.(*cfg.GameBuzkashiOpen); !ok {
|
|
err = fmt.Errorf("config type err:%T", v)
|
|
return
|
|
} else {
|
|
for _, v := range config.GetDataList() {
|
|
if currtime >= fmt.Sprintf("%d:%d", v.Shtime, v.Smtime) && currtime < fmt.Sprintf("%d:%d", v.Ehtime, v.Emtime) {
|
|
open = true
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询积分段位信息
|
|
func (this *configureComp) getActiveReward(integral int32) (result *cfg.GameQualifyingData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_qualifying); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
for _, v := range v.(*cfg.GameQualifying).GetDataMap() {
|
|
if integral >= v.ScoreLow && integral <= v.ScoreUp {
|
|
result = v
|
|
return
|
|
}
|
|
}
|
|
}
|
|
err = fmt.Errorf("未找到 匹配积分:%d段位配置", integral)
|
|
return
|
|
}
|
|
|
|
//查询积分段位信息
|
|
func (this *configureComp) getActiveRewardById(lv int32) (result *cfg.GameQualifyingData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_qualifying); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if result, ok = v.(*cfg.GameQualifying).GetDataMap()[lv]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_qualifying, lv)
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
return
|
|
}
|