From 72e9f12905ea23c7b3504fd25b33b3b9a013ca8b Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 15 Jun 2023 09:45:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=93=81=E5=8C=A0=E9=93=BA=E6=89=8B?= =?UTF-8?q?=E5=86=8C=E5=8F=B0=E6=94=B6=E8=97=8F=E5=AE=B6=E7=BA=A2=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/smithy/model_atlas.go | 10 ++++++++++ modules/smithy/module.go | 3 +++ 2 files changed, 13 insertions(+) diff --git a/modules/smithy/model_atlas.go b/modules/smithy/model_atlas.go index 768d6a838..ed3a8731a 100644 --- a/modules/smithy/model_atlas.go +++ b/modules/smithy/model_atlas.go @@ -159,3 +159,13 @@ func (this *modelAtlas) checkReddot17102(uid string) bool { return false } +func (this *modelAtlas) checkReddot17106(uid string) bool { + list, _ := this.module.modelAtlas.getSmithyAtlasList(uid) + for _, v := range list.Collect { + if v.Activate == false { + return true + } + } + + return false +} diff --git a/modules/smithy/module.go b/modules/smithy/module.go index d399b6f8a..01cf0a15a 100644 --- a/modules/smithy/module.go +++ b/modules/smithy/module.go @@ -130,6 +130,9 @@ func (this *Smithy) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r case comm.Reddot17107: // 铁匠铺手册台收藏家奖励按钮上 reddot[comm.Reddot17107] = this.modelTask.checkReddot17107(session.GetUserId()) break + case comm.Reddot17106: // + reddot[comm.Reddot17106] = this.modelAtlas.checkReddot17106(session.GetUserId()) + break } } From dca0850ff336755c68993fa6a1cb436071d59d9e Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 15 Jun 2023 11:10:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=8B=B1=E9=9B=84=20=E5=A4=A9=E8=B5=8B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8B=B1=E9=9B=84=E7=AD=89=E7=BA=A7=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_talentlearn.go | 48 +++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/modules/hero/api_talentlearn.go b/modules/hero/api_talentlearn.go index d2d7e68e9..fb55b9aa8 100644 --- a/modules/hero/api_talentlearn.go +++ b/modules/hero/api_talentlearn.go @@ -26,6 +26,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe err error chanegCard []*pb.DBHero // 推送属性变化 res []*cfg.Gameatn // 学习天赋需要消耗的道具 + hero *pb.DBHero ) chanegCard = make([]*pb.DBHero, 0) @@ -41,8 +42,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe } return } - this.module.Debugf("%v", talent) - + this.module.Debugf("TalentLearn:%v", talent) } else { if req.Heroid == "" { // 英雄id不能为空 errdata = &pb.ErrorData{ @@ -66,6 +66,12 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe talent, err = this.module.modelTalent.CreateHeroTalent(session.GetUserId(), req.Heroid) if err != nil { this.module.Errorf("create talent data failed:%v", err) + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return } } } @@ -79,18 +85,25 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe } return } - user := this.module.ModuleUser.GetUser(session.GetUserId()) - if user != nil { - // 校验玩家等级 - if talentConf.Condition > user.Lv { // 等级不满足 - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserLvNoEnough, - Title: pb.ErrorCode_UserLvNoEnough.ToString(), - Message: fmt.Sprintf("等级不满足要求:curLv = %d,lv = %d", user.Lv, talentConf.Condition), - } - - return + hero = this.module.QueryHeroByConfId(session.GetUserId(), talent.HeroId) + if hero == nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_HeroNoExist, + Title: pb.ErrorCode_HeroNoExist.ToString(), + Message: err.Error(), } + return + } + + // 校验玩家等级 + if talentConf.Condition > hero.Lv { // 等级不满足 + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserLvNoEnough, + Title: pb.ErrorCode_UserLvNoEnough.ToString(), + Message: fmt.Sprintf("英雄等级不满足要求:curLv = %d,lv = %d", hero.Lv, talentConf.Condition), + } + + return } // 校验 @@ -160,13 +173,8 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe } // 同步修改属性 - heroList := this.module.GetHeroList(session.GetUserId()) - for _, v := range heroList { - if v.HeroID == talent.HeroId { // 找到对应的英雄ID - this.module.modelHero.setTalentProperty(v, talentConf) - chanegCard = append(chanegCard, v) // 添加推送属性变化信息 - } - } + this.module.modelHero.setTalentProperty(hero, talentConf) + chanegCard = append(chanegCard, hero) // 添加推送属性变化信息 session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard}) session.SendMsg(string(this.module.GetType()), HeroTalentLearnResp, &pb.HeroTalentLearnResp{ From cb1c32f3566cf783fdf858da9b8a35c8cb0de87f Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 15 Jun 2023 11:30:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?db=E5=88=9B=E5=BB=BA=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/enchant/model_rank.go | 5 +++++ modules/hero/model_record.go | 4 ++++ modules/hero/model_talent.go | 5 +++++ modules/hunting/model_rank.go | 5 +++++ modules/library/model_fetterstory.go | 4 ++++ 5 files changed, 23 insertions(+) diff --git a/modules/enchant/model_rank.go b/modules/enchant/model_rank.go index 2d8f8353c..8bed3f9ae 100644 --- a/modules/enchant/model_rank.go +++ b/modules/enchant/model_rank.go @@ -10,6 +10,8 @@ import ( "go_dreamfactory/sys/db" "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelRank struct { @@ -21,6 +23,9 @@ func (this *ModelRank) Init(service core.IService, module core.IModule, comp cor this.TableName = comm.TableEnchantRank // 挑战记录 err = this.MCompModel.Init(service, module, comp, options) this.moduleEnchant = module.(*Enchant) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/hero/model_record.go b/modules/hero/model_record.go index 0caf230f3..419509cd8 100644 --- a/modules/hero/model_record.go +++ b/modules/hero/model_record.go @@ -9,6 +9,7 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) // 记录一些扩展数据 图鉴 改名次数等 @@ -19,6 +20,9 @@ type ModelRecord struct { func (this *ModelRecord) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.TableName = comm.TableUserRecord err = this.MCompModel.Init(service, module, comp, options) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/hero/model_talent.go b/modules/hero/model_talent.go index 9a4793dab..798b2efc8 100644 --- a/modules/hero/model_talent.go +++ b/modules/hero/model_talent.go @@ -9,6 +9,8 @@ import ( "go_dreamfactory/pb" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) // 英雄天赋组件 @@ -21,6 +23,9 @@ func (this *ModelTalent) Init(service core.IService, module core.IModule, comp c this.TableName = comm.TableTalent err = this.MCompModel.Init(service, module, comp, options) this.module = module.(*Hero) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/hunting/model_rank.go b/modules/hunting/model_rank.go index f2d307f7f..00613dbce 100644 --- a/modules/hunting/model_rank.go +++ b/modules/hunting/model_rank.go @@ -10,6 +10,8 @@ import ( "go_dreamfactory/sys/db" "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelRank struct { @@ -21,6 +23,9 @@ func (this *ModelRank) Init(service core.IService, module core.IModule, comp cor this.TableName = comm.TableHuntingRecord // 挑战记录 err = this.MCompModel.Init(service, module, comp, options) this.moduleHunting = module.(*Hunting) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/library/model_fetterstory.go b/modules/library/model_fetterstory.go index 185ecd248..29aaab377 100644 --- a/modules/library/model_fetterstory.go +++ b/modules/library/model_fetterstory.go @@ -9,6 +9,7 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type modelFetterstory struct { @@ -22,6 +23,9 @@ func (this *modelFetterstory) Init(service core.IService, module core.IModule, c err = this.MCompModel.Init(service, module, comp, options) this.module = module.(*Library) this.service = service + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return }