From c86bf2c37a760244f6bf4f4b3ed027db59b199e4 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 18 Sep 2023 19:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=85=BB=E6=88=90=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dragon/configure_comp.go | 24 ++++++++++++++++++------ modules/dragon/model_dragon.go | 3 +++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/dragon/configure_comp.go b/modules/dragon/configure_comp.go index 90e8963cb..3b5fec648 100644 --- a/modules/dragon/configure_comp.go +++ b/modules/dragon/configure_comp.go @@ -24,12 +24,13 @@ const ( // /配置管理组件 type configureComp struct { modules.MCompConfigure - module *Dragon - hlock sync.RWMutex - dragon map[string]*cfg.GameTrainlvData - play map[string]*cfg.GameDragonPlayData - mount map[string]*cfg.GameBuzkashiMountData - lvItem map[string]*cfg.GameDragonLvItemData + module *Dragon + hlock sync.RWMutex + dragon map[string]*cfg.GameTrainlvData + play map[string]*cfg.GameDragonPlayData + mount map[string]*cfg.GameBuzkashiMountData + lvItem map[string]*cfg.GameDragonLvItemData + attribute map[string]struct{} } // 组件初始化接口 @@ -153,10 +154,14 @@ func (this *configureComp) LoadDragonLvItem() { if v, err := this.GetConfigure(game_dragonlvitem); err == nil { this.hlock.Lock() defer this.hlock.Unlock() + this.attribute = make(map[string]struct{}, 0) this.lvItem = make(map[string]*cfg.GameDragonLvItemData) if _configure, ok := v.(*cfg.GameDragonLvItem); ok { for _, v := range _configure.GetDataList() { this.lvItem[v.Attribute+"-"+strconv.Itoa(int(v.Lv))] = v + if _, ok := this.attribute[v.Attribute]; !ok { + this.attribute[v.Attribute] = struct{}{} + } } return } @@ -176,3 +181,10 @@ func (this *configureComp) GetDragonLvItemConf(attribute string, lv int32) (conf err = comm.NewNotFoundConfErr(moduleName, dragon_trainlv, fmt.Sprintf("id:%s,lv:%d", attribute, lv)) return } + +func (this *configureComp) GetDragonAttributeConf() (conf map[string]struct{}) { + + this.hlock.RLock() + defer this.hlock.RUnlock() + return this.attribute +} diff --git a/modules/dragon/model_dragon.go b/modules/dragon/model_dragon.go index de35e4b8d..f21eb490e 100644 --- a/modules/dragon/model_dragon.go +++ b/modules/dragon/model_dragon.go @@ -122,6 +122,9 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str if !bNewDragon { continue } + for k := range this.module.configure.GetDragonAttributeConf() { + dragon.Lvitem[k] = 1 + } if dbModel != nil { err = dbModel.AddList(uid, dragon.Id, dragon)