From 61c9f00eaabc31e2b46edf73f3a6d6811ec0f683 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 16 Aug 2022 16:22:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E6=8E=A8=E9=80=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=8D=A1=E4=BF=A1=E6=81=AF=20=E7=BE=8E=E9=A3=9F?= =?UTF-8?q?=E5=AE=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gourmet/comp_configure.go | 68 +++++++++++++------------------ 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/modules/gourmet/comp_configure.go b/modules/gourmet/comp_configure.go index 6f799573f..fcb2ff04d 100644 --- a/modules/gourmet/comp_configure.go +++ b/modules/gourmet/comp_configure.go @@ -10,35 +10,45 @@ import ( ) const ( - game_pagoda = "game_pagoda.json" - game_pagodaseasonreward = "game_pagodaseasonreward.json" - game_pagodataskreward = "game_pagodataskreward.json" + game_gourmet = "game_gourmet.json" + game_gourmetskill = "game_gourmetskill.json" ) ///配置管理基础组件 type configureComp struct { cbase.ModuleCompBase - hlock sync.RWMutex - _pagodaMap map[int64]*cfg.GamepagodaData + hlock sync.RWMutex + _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) { 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) - configure.RegisterConfigure(game_pagoda, cfg.NewGamepagoda, func() { - if v, err := this.GetConfigure(game_pagoda); err == nil { - if configure, ok := v.(*cfg.Gamepagoda); ok { + this._gourmetMap = make(map[int64]*cfg.GameGourmetData, 0) + configure.RegisterConfigure(game_gourmet, cfg.NewGameGourmet, func() { + if v, err := this.GetConfigure(game_gourmet); err == nil { + if configure, ok := v.(*cfg.GameGourmet); ok { this.hlock.Lock() defer this.hlock.Unlock() 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 } @@ -49,10 +59,10 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp 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) { 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 -}