图鉴激活检测

This commit is contained in:
meixiongfeng 2023-02-20 19:10:21 +08:00
parent 760de42723
commit cabae82815
2 changed files with 49 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import (
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
@ -29,11 +30,51 @@ func (this *modelAtlas) Init(service core.IService, module core.IModule, comp co
func (this *modelAtlas) getSmithyAtlasList(uid string) (result *pb.DBAtlas, err error) {
result = &pb.DBAtlas{}
if err = this.Get(uid, result); err != nil {
if mongo.ErrNoDocuments == err {
result.Id = primitive.NewObjectID().Hex()
result.Uid = uid
result.Tujian = make(map[string]*pb.ForgeData, 0)
this.Add(uid, result)
err = nil
}
return
}
return result, nil
return
}
func (this *modelAtlas) modifySmithyAtlasList(uid string, data map[string]interface{}) error {
return this.Change(uid, data)
}
// 检查是否激活图鉴
func (this *modelAtlas) CheckActivateAtlas(uid string, id string, lv int32, quality int32, forgeCount int32) bool {
conf := this.module.configure.GetSmithyAtlasConf(id)
if conf != nil {
return false
}
list, err := this.module.modelAtlas.getSmithyAtlasList(uid)
if err != nil {
return false
}
for k, v := range list.Tujian {
if k == id { // 找到相同的 校验 对应的分数
// 获取分数
scoreConf := this.module.configure.GetSmithyAtlasScoreConf(quality, lv)
if scoreConf != nil {
if v.Score <= scoreConf.Score {
v.Lv = lv
v.Quality = quality
v.Score = scoreConf.Score
v.ForgeCount = forgeCount // 更新锻造次数
update := make(map[string]interface{}, 0)
update["tujian"] = list.Tujian
this.module.modelAtlas.modifySmithyAtlasList(uid, update) // 更新分数信息
}
return true
}
return false
}
}
return true
}

View File

@ -327,11 +327,11 @@ type DBAtlas struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
Tujian map[int32]*ForgeData `protobuf:"bytes,3,rep,name=tujian,proto3" json:"tujian" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 图鉴信息
Slider int32 `protobuf:"varint,4,opt,name=slider,proto3" json:"slider"` // 进度
Reward int32 `protobuf:"varint,5,opt,name=reward,proto3" json:"reward"` // 奖励进度
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
Tujian map[string]*ForgeData `protobuf:"bytes,3,rep,name=tujian,proto3" json:"tujian" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 图鉴信息
Slider int32 `protobuf:"varint,4,opt,name=slider,proto3" json:"slider"` // 进度
Reward int32 `protobuf:"varint,5,opt,name=reward,proto3" json:"reward"` // 奖励进度
}
func (x *DBAtlas) Reset() {
@ -380,7 +380,7 @@ func (x *DBAtlas) GetUid() string {
return ""
}
func (x *DBAtlas) GetTujian() map[int32]*ForgeData {
func (x *DBAtlas) GetTujian() map[string]*ForgeData {
if x != nil {
return x.Tujian
}
@ -796,7 +796,7 @@ var file_smithy_smithy_db_proto_rawDesc = []byte{
0x69, 0x64, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x05,
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x1a, 0x45, 0x0a, 0x0b,
0x54, 0x75, 0x6a, 0x69, 0x61, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x46,
0x6f, 0x72, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x02, 0x38, 0x01, 0x22, 0x6b, 0x0a, 0x09, 0x46, 0x6f, 0x72, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61,