This commit is contained in:
meixiongfeng 2023-03-30 11:47:54 +08:00
parent 4a199ed7d1
commit 440f4fe1f9
6 changed files with 113 additions and 82 deletions

View File

@ -431,7 +431,7 @@ type (
}
ISmithy interface {
CheckActivateAtlasCollect(uid string, id string) (code pb.ErrorCode)
CheckActivateAtlasCollect(uid string, id string)
}
IPandaAtlas interface {

View File

@ -46,6 +46,10 @@ func (this *PandaAtlas) OnInstallComp() {
}
func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) {
conf := this.configure.GetPandoAtlasConf(id)
if conf != nil {
return
}
if this.IsCross() {
atlas := &pb.DBPandaAtlas{}
if model, err := this.GetDBModelByUid(uid, this.modelPandaAtlas.TableName, this.modelPandaAtlas.Expired); err == nil {
@ -56,17 +60,16 @@ func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) {
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)
}
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 {
@ -75,36 +78,32 @@ func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) {
}
}
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{
atlas.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["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 {
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
}
}
return

View File

@ -450,7 +450,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
}
if len(atlas) > 0 {
for k := range atlas {
code = this.ModuleSmithy.CheckActivateAtlasCollect(session.GetUserId(), k)
this.ModuleSmithy.CheckActivateAtlasCollect(session.GetUserId(), k)
this.Debugf("发放图鉴资源: %v [%v]", k, code)
}
}

View File

@ -121,25 +121,3 @@ func (this *modelAtlas) CheckActivateAtlas(uid string, id string, lv int32, qual
}
return true
}
// 检查是否激活收藏品
func (this *modelAtlas) CheckActivateAtlasCollect(uid string, id string) {
atlasConf := this.module.configure.GetSmithyAtlasConf(id)
if atlasConf != nil && atlasConf.TypeId == 2 {
if list, err := this.module.modelAtlas.getSmithyAtlasList(uid); err == nil {
if _, ok := list.Collect[id]; !ok {
list.Collect[id] = &pb.CollectData{
Id: id,
Score: atlasConf.AtlasScore,
Time: configure.Now().Unix(),
}
list.Score += atlasConf.AtlasScore
update := make(map[string]interface{}, 0)
update["collect"] = list.Collect
update["score"] = list.Score
this.module.modelAtlas.modifySmithyAtlasList(uid, update) // 更新分数信息
}
}
}
}

View File

@ -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 Smithy struct {
@ -47,9 +50,58 @@ func (this *Smithy) OnInstallComp() {
this.modelTask = this.RegisterComp(new(modelTask)).(*modelTask)
}
func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) (code pb.ErrorCode) {
func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) {
atlasConf := this.configure.GetSmithyAtlasConf(id)
if atlasConf != nil && atlasConf.TypeId == 2 { //类型为2表示特殊类型图鉴
if atlasConf == nil || atlasConf.TypeId != 2 {
return
}
if this.IsCross() {
atlas := &pb.DBAtlas{}
if model, err := this.GetDBModelByUid(uid, this.modelAtlas.TableName, this.modelAtlas.Expired); err == nil {
if err := model.Get(uid, atlas); err != nil { // 防止数据没有初始化情况
if mongo.ErrNoDocuments == err {
atlas.Id = primitive.NewObjectID().Hex()
atlas.Uid = uid
atlas.Atlas = make(map[string]*pb.ForgeList, 0)
atlas.Collect = make(map[string]*pb.CollectData, 0)
atlas.Award = 1 // 初始1级
atlas.Collect[id] = &pb.CollectData{
Id: id,
Score: atlasConf.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 {
atlas.Collect[id] = &pb.CollectData{
Id: id,
Score: atlasConf.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 {
if list, err := this.modelAtlas.getSmithyAtlasList(uid); err == nil {
if _, ok := list.Collect[id]; !ok {
list.Collect[id] = &pb.CollectData{
@ -58,16 +110,13 @@ func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) (code pb.Er
Time: configure.Now().Unix(),
Activate: false,
}
//list.Score += atlasConf.AtlasScore
update := make(map[string]interface{}, 0)
update["collect"] = list.Collect
//update["score"] = list.Score
this.modelAtlas.modifySmithyAtlasList(uid, update) // 更新信息
return
}
}
}
code = pb.ErrorCode_SmithyNoFoundAtlas
return
}

View File

@ -340,6 +340,7 @@ const (
ErrorCode_SmithyNoActivateAtlas ErrorCode = 4113 // 没有图鉴更新数据
ErrorCode_SmithyLvToolsFailed ErrorCode = 4114 //
ErrorCode_SmithyLvToolsPre ErrorCode = 4115 // 前置条件不足
ErrorCode_SmithyAtlasTypeErr ErrorCode = 4116 //图鉴类型错误
// dispatch
ErrorCode_DispatchHeroNoReached ErrorCode = 4201 //英雄条件未达标
ErrorCode_DispatchNoFree ErrorCode = 4202 //免费次数用尽
@ -643,6 +644,7 @@ var (
4113: "SmithyNoActivateAtlas",
4114: "SmithyLvToolsFailed",
4115: "SmithyLvToolsPre",
4116: "SmithyAtlasTypeErr",
4201: "DispatchHeroNoReached",
4202: "DispatchNoFree",
4203: "DispatchTicketNoEnough",
@ -941,6 +943,7 @@ var (
"SmithyNoActivateAtlas": 4113,
"SmithyLvToolsFailed": 4114,
"SmithyLvToolsPre": 4115,
"SmithyAtlasTypeErr": 4116,
"DispatchHeroNoReached": 4201,
"DispatchNoFree": 4202,
"DispatchTicketNoEnough": 4203,
@ -986,7 +989,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xe5, 0x35, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xfe, 0x35, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76,
@ -1399,25 +1402,27 @@ var file_errorcode_proto_rawDesc = []byte{
0x20, 0x12, 0x18, 0x0a, 0x13, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x4c, 0x76, 0x54, 0x6f, 0x6f,
0x6c, 0x73, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0x92, 0x20, 0x12, 0x15, 0x0a, 0x10, 0x53,
0x6d, 0x69, 0x74, 0x68, 0x79, 0x4c, 0x76, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x50, 0x72, 0x65, 0x10,
0x93, 0x20, 0x12, 0x1a, 0x0a, 0x15, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65,
0x72, 0x6f, 0x4e, 0x6f, 0x52, 0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xe9, 0x20, 0x12, 0x13,
0x0a, 0x0e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x46, 0x72, 0x65, 0x65,
0x10, 0xea, 0x20, 0x12, 0x1b, 0x0a, 0x16, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x54,
0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xeb, 0x20,
0x93, 0x20, 0x12, 0x17, 0x0a, 0x12, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x41, 0x74, 0x6c, 0x61,
0x73, 0x54, 0x79, 0x70, 0x65, 0x45, 0x72, 0x72, 0x10, 0x94, 0x20, 0x12, 0x1a, 0x0a, 0x15, 0x44,
0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x52, 0x65, 0x61,
0x63, 0x68, 0x65, 0x64, 0x10, 0xe9, 0x20, 0x12, 0x13, 0x0a, 0x0e, 0x44, 0x69, 0x73, 0x70, 0x61,
0x74, 0x63, 0x68, 0x4e, 0x6f, 0x46, 0x72, 0x65, 0x65, 0x10, 0xea, 0x20, 0x12, 0x1b, 0x0a, 0x16,
0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x4e, 0x6f,
0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xeb, 0x20, 0x12, 0x19, 0x0a, 0x14, 0x44, 0x69, 0x73,
0x70, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65,
0x64, 0x10, 0xec, 0x20, 0x12, 0x18, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68,
0x54, 0x61, 0x73, 0x6b, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x10, 0xed, 0x20, 0x12, 0x17,
0x0a, 0x12, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73,
0x68, 0x4d, 0x61, 0x78, 0x10, 0xee, 0x20, 0x12, 0x17, 0x0a, 0x12, 0x44, 0x69, 0x73, 0x70, 0x61,
0x74, 0x63, 0x68, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xef, 0x20,
0x12, 0x19, 0x0a, 0x14, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x72, 0x6f,
0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x10, 0xec, 0x20, 0x12, 0x18, 0x0a, 0x13, 0x44,
0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x78, 0x70, 0x69, 0x72,
0x65, 0x64, 0x10, 0xed, 0x20, 0x12, 0x17, 0x0a, 0x12, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63,
0x68, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x4d, 0x61, 0x78, 0x10, 0xee, 0x20, 0x12, 0x17,
0x0a, 0x12, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x69,
0x73, 0x68, 0x65, 0x64, 0x10, 0xef, 0x20, 0x12, 0x19, 0x0a, 0x14, 0x44, 0x69, 0x73, 0x70, 0x61,
0x74, 0x63, 0x68, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10,
0xf0, 0x20, 0x12, 0x16, 0x0a, 0x11, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x51, 0x69,
0x65, 0x63, 0x75, 0x6f, 0x69, 0x6e, 0x67, 0x10, 0xcd, 0x21, 0x12, 0x11, 0x0a, 0x0c, 0x50, 0x72,
0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x53, 0x65, 0x6e, 0x74, 0x10, 0xce, 0x21, 0x12, 0x1a, 0x0a,
0x15, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54,
0x69, 0x6d, 0x65, 0x4f, 0x75, 0x74, 0x10, 0xcf, 0x21, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x4e, 0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xf0, 0x20, 0x12, 0x16, 0x0a, 0x11, 0x50,
0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x51, 0x69, 0x65, 0x63, 0x75, 0x6f, 0x69, 0x6e, 0x67,
0x10, 0xcd, 0x21, 0x12, 0x11, 0x0a, 0x0c, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69, 0x63, 0x65, 0x53,
0x65, 0x6e, 0x74, 0x10, 0xce, 0x21, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x72, 0x61, 0x63, 0x74, 0x69,
0x63, 0x65, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x4f, 0x75, 0x74, 0x10,
0xcf, 0x21, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (