From ab9542bdaf31aa1af4ca94d6a055b6b3b7acb092 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 30 Mar 2023 11:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E9=89=B4=E8=B7=A8=E6=9C=8D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 +- modules/atlas/module.go | 75 +++++++++++++++++++++++++------ modules/gourmet/comp_configure.go | 4 +- 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index f3ca79269..d1d3a7c9c 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -435,7 +435,7 @@ type ( } IPandaAtlas interface { - CheckActivatePandaAtlasCollect(uid string, id string) (code pb.ErrorCode) + CheckActivatePandaAtlasCollect(uid string, id string) } //练功房 IPractice interface { diff --git a/modules/atlas/module.go b/modules/atlas/module.go index d2f528afb..2ba5a1106 100644 --- a/modules/atlas/module.go +++ b/modules/atlas/module.go @@ -11,6 +11,9 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" + + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" ) type PandaAtlas struct { @@ -42,23 +45,67 @@ func (this *PandaAtlas) OnInstallComp() { this.modelPandaAtlas = this.RegisterComp(new(modelPandaAtlas)).(*modelPandaAtlas) } -func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) (code pb.ErrorCode) { - list, _ := this.modelPandaAtlas.getPandaAtlasList(uid) - if _, ok := list.Collect[id]; !ok { - conf := this.configure.GetPandoAtlasConf(id) - if conf != nil { - list.Collect[id] = &pb.CollectInfo{ - Score: conf.AtlasScore, - Time: configure.Now().Unix(), - Activate: false, +func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) { + if this.IsCross() { + atlas := &pb.DBPandaAtlas{} + if model, err := this.GetDBModelByUid(uid, this.modelPandaAtlas.TableName, this.modelPandaAtlas.Expired); err == nil { + + if err := model.Get(uid, atlas); err != nil { // 防止数据没有初始化情况 + if mongo.ErrNoDocuments == err { + atlas.Id = primitive.NewObjectID().Hex() + atlas.Uid = uid + atlas.Collect = make(map[string]*pb.CollectInfo, 0) + atlas.Award = 1 // 初始1级 + if conf := this.configure.GetPandoAtlasConf(id); conf != nil { + atlas.Collect[id] = &pb.CollectInfo{ + Score: conf.AtlasScore, + Time: configure.Now().Unix(), + Activate: false, + } + update := make(map[string]interface{}, 0) + update["collect"] = atlas.Collect + if err := model.Add(uid, update); err != nil { + this.Errorf("err:%v", err) + } + } + return + } else { + this.Errorf("err:%v", err) + return + } + } + if _, ok := atlas.Collect[id]; !ok { + if conf := this.configure.GetPandoAtlasConf(id); conf != nil { + atlas.Collect[id] = &pb.CollectInfo{ + Score: conf.AtlasScore, + Time: configure.Now().Unix(), + Activate: false, + } + update := make(map[string]interface{}, 0) + update["collect"] = atlas.Collect + if err := model.Change(uid, update); err != nil { + this.Errorf("err:%v", err) + return + } + } + } + } + } else { + list, _ := this.modelPandaAtlas.getPandaAtlasList(uid) + if _, ok := list.Collect[id]; !ok { + if conf := this.configure.GetPandoAtlasConf(id); conf != nil { + list.Collect[id] = &pb.CollectInfo{ + Score: conf.AtlasScore, + Time: configure.Now().Unix(), + Activate: false, + } + update := make(map[string]interface{}, 0) + update["collect"] = list.Collect + this.modelPandaAtlas.modifyPandaAtlasList(uid, update) + return } - update := make(map[string]interface{}, 0) - update["collect"] = list.Collect - this.modelPandaAtlas.modifyPandaAtlasList(uid, update) - return } } - code = pb.ErrorCode_SmithyNoFoundAtlas return } diff --git a/modules/gourmet/comp_configure.go b/modules/gourmet/comp_configure.go index 9e8f86d1d..f982649a2 100644 --- a/modules/gourmet/comp_configure.go +++ b/modules/gourmet/comp_configure.go @@ -45,7 +45,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp log.Errorf("get game_pagoda conf err:%v", err) return }) - this.SetGrormetCookBookConf() + + configure.RegisterConfigure(game_food, cfg.NewGameBreakingbad, this.SetGrormetCookBookConf) + return }