This commit is contained in:
liwei1dao 2023-06-15 11:34:41 +08:00
commit bfbb7b69a0
8 changed files with 64 additions and 20 deletions

View File

@ -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
}

View File

@ -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{

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}
}