图鉴跨服接口

This commit is contained in:
meixiongfeng 2023-03-30 11:15:58 +08:00
parent 7b53f63d5d
commit ab9542bdaf
3 changed files with 65 additions and 16 deletions

View File

@ -435,7 +435,7 @@ type (
}
IPandaAtlas interface {
CheckActivatePandaAtlasCollect(uid string, id string) (code pb.ErrorCode)
CheckActivatePandaAtlasCollect(uid string, id string)
}
//练功房
IPractice interface {

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 PandaAtlas struct {
@ -42,23 +45,67 @@ func (this *PandaAtlas) OnInstallComp() {
this.modelPandaAtlas = this.RegisterComp(new(modelPandaAtlas)).(*modelPandaAtlas)
}
func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) (code pb.ErrorCode) {
list, _ := this.modelPandaAtlas.getPandaAtlasList(uid)
if _, ok := list.Collect[id]; !ok {
conf := this.configure.GetPandoAtlasConf(id)
if conf != nil {
list.Collect[id] = &pb.CollectInfo{
Score: conf.AtlasScore,
Time: configure.Now().Unix(),
Activate: false,
func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) {
if this.IsCross() {
atlas := &pb.DBPandaAtlas{}
if model, err := this.GetDBModelByUid(uid, this.modelPandaAtlas.TableName, this.modelPandaAtlas.Expired); err == nil {
if err := model.Get(uid, atlas); err != nil { // 防止数据没有初始化情况
if mongo.ErrNoDocuments == err {
atlas.Id = primitive.NewObjectID().Hex()
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)
}
}
return
} else {
this.Errorf("err:%v", err)
return
}
}
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{
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 := make(map[string]interface{}, 0)
update["collect"] = list.Collect
this.modelPandaAtlas.modifyPandaAtlasList(uid, update)
return
}
}
code = pb.ErrorCode_SmithyNoFoundAtlas
return
}

View File

@ -45,7 +45,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
log.Errorf("get game_pagoda conf err:%v", err)
return
})
this.SetGrormetCookBookConf()
configure.RegisterConfigure(game_food, cfg.NewGameBreakingbad, this.SetGrormetCookBookConf)
return
}