This commit is contained in:
liwei 2023-07-10 16:57:19 +08:00
commit a142ccc9ec
6 changed files with 109 additions and 9 deletions

View File

@ -278,6 +278,8 @@ const (
TableGuidance = "guidance" TableGuidance = "guidance"
//传功房 //传功房
TablePasson = "passon" TablePasson = "passon"
// 阵营塔 循环塔
TableRacePagoda = "racepagoda"
) )
// RPC服务接口定义处 // RPC服务接口定义处

View File

@ -0,0 +1,29 @@
package pagoda
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
//参数校验
func (this *apiComp) GetRaceCheck(session comm.IUserSession, req *pb.PagodaGetRaceReq) (errdata *pb.ErrorData) {
return
}
///获取阵营爬塔信息
func (this *apiComp) GetRace(session comm.IUserSession, req *pb.PagodaGetRaceReq) (errdata *pb.ErrorData) {
list, err := this.module.modelRacePagoda.getPagodaRaceList(session.GetUserId())
if err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), PagodaGetListResp, &pb.PagodaGetRaceResp{Race: list.Race})
return
}

View File

@ -206,7 +206,7 @@ func (this *configureComp) LoadCirculate() {
defer this.hlock.Unlock() defer this.hlock.Unlock()
this._mapRace = make(map[int32]*cfg.GameCirculateData) this._mapRace = make(map[int32]*cfg.GameCirculateData)
for _, value := range configure.GetDataList() { for _, value := range configure.GetDataList() {
this._mapRace[value.Restriction] = value this._mapRace[value.Restriction<<16+value.Floors] = value
} }
return return
} }
@ -214,3 +214,12 @@ func (this *configureComp) LoadCirculate() {
return return
} }
// 获取阵营塔数据
func (this *configureComp) GetPagodaCirculateConf(restriction int32, floor int32) (data *cfg.GamePagoda, err error) {
if _, ok := this._mapRace[restriction<<16+floor]; ok {
return
}
err = comm.NewNotFoundConfErr("pagoda", game_circulate, fmt.Errorf("tab %d ,ly %d not found", restriction, floor))
return
}

View File

@ -38,7 +38,7 @@ func (this *ModelPagoda) getPagodaList(uid string) (result *pb.DBPagoda, err err
result.Reward = make(map[int32]bool, 0) result.Reward = make(map[int32]bool, 0)
result.Data = make(map[int32]int32, 0) result.Data = make(map[int32]int32, 0)
result.Type = comm.PagodaType result.Type = comm.PagodaType
err = this.module.modelPagoda.addNewPagoda(uid, result) err = this.addNewPagoda(uid, result)
return return
} }

View File

@ -0,0 +1,58 @@
package pagoda
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
"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"
)
type ModelRace struct {
modules.MCompModel
module *Pagoda
}
func (this *ModelRace) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = string(comm.TableRacePagoda)
err = this.MCompModel.Init(service, module, comp, options)
this.module = module.(*Pagoda)
//创建uid索引
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})
return
}
// 获取爬塔信息
func (this *ModelRace) getPagodaRaceList(uid string) (result *pb.DBPagodaRace, err error) {
result = &pb.DBPagodaRace{}
if err = this.Get(uid, result); err != nil && err == mgo.MongodbNil { // 初始一条数据
result.Id = primitive.NewObjectID().Hex()
result.Uid = uid
result.Race = make(map[int32]*pb.RaceData)
err = this.addPagodaRace(uid, result)
return
}
return result, err
}
// 修改爬塔数据信息
func (this *ModelRace) modifyPagodaRaceDataByObjId(uid string, data map[string]interface{}) error {
return this.Change(uid, data)
}
// 创建一个新的塔数据
func (this *ModelRace) addPagodaRace(uId string, data *pb.DBPagodaRace) (err error) {
if err = this.Add(uId, data); err != nil {
this.module.Errorf("err:%v", err)
return
}
return nil
}

View File

@ -18,13 +18,14 @@ type Pagoda struct {
modules.ModuleBase modules.ModuleBase
modelPagoda *ModelPagoda modelPagoda *ModelPagoda
//modelSeasonPagoda *ModelSeasonPagoda //modelSeasonPagoda *ModelSeasonPagoda
api *apiComp api *apiComp
modulerank *ModelRank modulerank *ModelRank
configure *configureComp configure *configureComp
battle comm.IBattle battle comm.IBattle
service base.IRPCXService service base.IRPCXService
mail comm.Imail mail comm.Imail
friend comm.IFriend friend comm.IFriend
modelRacePagoda *ModelRace
} }
func NewModule() core.IModule { func NewModule() core.IModule {
@ -48,6 +49,7 @@ func (this *Pagoda) OnInstallComp() {
//this.modelSeasonPagoda = this.RegisterComp(new(ModelSeasonPagoda)).(*ModelSeasonPagoda) //this.modelSeasonPagoda = this.RegisterComp(new(ModelSeasonPagoda)).(*ModelSeasonPagoda)
this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank) this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
this.modelRacePagoda = this.RegisterComp(new(ModelRace)).(*ModelRace)
} }
// 接口信息 // 接口信息