148 lines
4.0 KiB
Go
148 lines
4.0 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" //段位
|
|
game_buzkashilv = "game_buzkashilv.json" //评级表
|
|
game_dragonweeklyreward = "game_dragonweeklyreward.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,
|
|
game_buzkashilv: cfg.NewGameBuzkashiLv,
|
|
game_dragonweeklyreward: cfg.NewGameDragonWeeklyreward,
|
|
})
|
|
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) getGameDragonWeeklyreward(id int32) (result *cfg.GameDragonWeeklyrewardData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_dragonweeklyreward); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if result, ok = v.(*cfg.GameDragonWeeklyreward).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_dragonweeklyreward, id)
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询积分段位信息
|
|
func (this *configureComp) getGameDragonWeeklyrewards() (confs []*cfg.GameDragonWeeklyrewardData, err error) {
|
|
var (
|
|
v interface{}
|
|
)
|
|
if v, err = this.GetConfigure(game_dragonweeklyreward); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
confs = v.(*cfg.GameDragonWeeklyreward).GetDataList()
|
|
}
|
|
return
|
|
}
|
|
|
|
//查询积分段位信息
|
|
func (this *configureComp) getGameBuzkashiLv(id int32) (result *cfg.GameBuzkashiLvData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_buzkashilv); err != nil {
|
|
this.module.Errorln(err)
|
|
} else {
|
|
if result, ok = v.(*cfg.GameBuzkashiLv).GetDataMap()[id]; !ok {
|
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_buzkashilv, id)
|
|
this.module.Errorln(err)
|
|
}
|
|
}
|
|
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
|
|
}
|