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/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{ 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 } 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 } }