抽卡推送获取卡信息

美食家
This commit is contained in:
meixiongfeng 2022-08-16 16:22:35 +08:00
parent 4434f27e4c
commit 61c9f00eaa

View File

@ -10,35 +10,45 @@ import (
) )
const ( const (
game_pagoda = "game_pagoda.json" game_gourmet = "game_gourmet.json"
game_pagodaseasonreward = "game_pagodaseasonreward.json" game_gourmetskill = "game_gourmetskill.json"
game_pagodataskreward = "game_pagodataskreward.json"
) )
///配置管理基础组件 ///配置管理基础组件
type configureComp struct { type configureComp struct {
cbase.ModuleCompBase cbase.ModuleCompBase
hlock sync.RWMutex hlock sync.RWMutex
_pagodaMap map[int64]*cfg.GamepagodaData _gourmetMap map[int64]*cfg.GameGourmetData
_gourmetSkillMap map[int64]*cfg.GameGourmetSkillData
} }
//组件初始化接口 //组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { 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) err = this.ModuleCompBase.Init(service, module, comp, options)
err = this.LoadMultiConfigure(map[string]interface{}{
//game_pagoda: cfg.NewGame_pagoda,
game_pagodaseasonreward: cfg.NewGamepagodaSeasonReward,
game_pagodataskreward: cfg.NewGamepagodaTaskReward,
})
this._pagodaMap = make(map[int64]*cfg.GamepagodaData, 0) this._gourmetMap = make(map[int64]*cfg.GameGourmetData, 0)
configure.RegisterConfigure(game_pagoda, cfg.NewGamepagoda, func() { configure.RegisterConfigure(game_gourmet, cfg.NewGameGourmet, func() {
if v, err := this.GetConfigure(game_pagoda); err == nil { if v, err := this.GetConfigure(game_gourmet); err == nil {
if configure, ok := v.(*cfg.Gamepagoda); ok { if configure, ok := v.(*cfg.GameGourmet); ok {
this.hlock.Lock() this.hlock.Lock()
defer this.hlock.Unlock() defer this.hlock.Unlock()
for _, value := range configure.GetDataList() { for _, value := range configure.GetDataList() {
this._pagodaMap[int64(value.PagodaType<<16)+int64(value.LayerNum)] = value this._gourmetMap[int64(value.Type<<16)+int64(value.Level)] = value
}
return
}
}
log.Errorf("get game_pagoda conf err:%v", err)
return
})
this._gourmetSkillMap = make(map[int64]*cfg.GameGourmetSkillData, 0)
configure.RegisterConfigure(game_gourmetskill, cfg.NewGameGourmetSkill, func() {
if v, err := this.GetConfigure(game_gourmetskill); err == nil {
if configure, ok := v.(*cfg.GameGourmetSkill); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
this._gourmetSkillMap[int64(value.Type<<16)+int64(value.Level)] = value
} }
return return
} }
@ -49,10 +59,10 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
return return
} }
// 获取爬塔信息 参数1 塔类型 参数2 层数 // 获取美食馆配置数据
func (this *configureComp) GetPagodaConfigData(PagodaType int32, floorId int32) (data *cfg.GamepagodaData) { func (this *configureComp) GetGourmetConfigData(gourmetType int32, level int32) (data *cfg.GameGourmetData) {
return this._pagodaMap[int64(PagodaType<<16)+int64(floorId)] return this._gourmetMap[int64(gourmetType<<16)+int64(level)]
} }
//加载多个配置文件 //加载多个配置文件
@ -71,25 +81,3 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
return configure.GetConfigure(name) return configure.GetConfigure(name)
} }
// 获取爬塔配置表数据
func (this *configureComp) GetPagodaconfig(id int32) (data *cfg.GamepagodaData) {
if v, err := this.GetConfigure(game_pagoda); err != nil {
log.Errorf("get global conf err:%v", err)
return
} else {
var (
configure *cfg.Gamepagoda
ok bool
)
if configure, ok = v.(*cfg.Gamepagoda); !ok {
log.Errorf("%T no is *cfg.Game_pagodaData", v)
return
}
if data, ok = configure.GetDataMap()[id]; ok {
return
}
}
return
}