六合塔
This commit is contained in:
parent
4a68d0d46f
commit
d7c7f06301
@ -39,7 +39,7 @@ func (this *apiComp) GetRace(session comm.IUserSession, req *pb.PagodaGetRaceReq
|
||||
update["rtime"] = list.Rtime
|
||||
}
|
||||
|
||||
if err = this.module.modelRacePagoda.ModifyPagodaRaceDataByObjId(session.GetUserId(), update); err != nil {
|
||||
if err = this.module.modelRacePagoda.ModifyPagodaRaceData(session.GetUserId(), update); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
|
@ -84,12 +84,20 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda
|
||||
mapData["battlecount"] = list.Battlecount
|
||||
|
||||
if new {
|
||||
if conf.Floors == 1 { // 写数据
|
||||
this.module.modelRacePagoda.addCrossPagodaRace(session.GetUserId(), list)
|
||||
} else {
|
||||
this.module.modelRacePagoda.ModifyCrossPagodaRaceData(session.GetUserId(), mapData)
|
||||
}
|
||||
var score int32
|
||||
score = 10000*list.Maxfloor + (10000 - costTime)
|
||||
this.module.modelRacePagoda.SetRacePagodaRankList(score, session.GetUserId())
|
||||
// 校验是否刷新记录
|
||||
if list.Data[conf.Floors].Consttime > costTime { // 小于之前的时间 入榜
|
||||
this.module.modelRacePagoda.SetRacePagodaRankList(score, session.GetUserId())
|
||||
}
|
||||
}
|
||||
|
||||
if err = this.module.modelRacePagoda.ModifyPagodaRaceDataByObjId(session.GetUserId(), mapData); err != nil {
|
||||
if err = this.module.modelRacePagoda.ModifyPagodaRaceData(session.GetUserId(), mapData); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
|
@ -36,6 +36,7 @@ func (this *ModelRace) Init(service core.IService, module core.IModule, comp cor
|
||||
|
||||
// 获取爬塔信息
|
||||
func (this *ModelRace) getPagodaRaceList(uid string) (result *pb.DBPagodaRace, err error) {
|
||||
|
||||
result = &pb.DBPagodaRace{
|
||||
Data: map[int32]*pb.RaceData{},
|
||||
}
|
||||
@ -44,21 +45,66 @@ func (this *ModelRace) getPagodaRaceList(uid string) (result *pb.DBPagodaRace, e
|
||||
result.Uid = uid
|
||||
result.Data = make(map[int32]*pb.RaceData)
|
||||
result.Rtime = configure.Now().Unix()
|
||||
err = this.addPagodaRace(uid, result)
|
||||
err = this.Add(uid, result)
|
||||
return
|
||||
}
|
||||
|
||||
return result, err
|
||||
}
|
||||
|
||||
// 修改爬塔数据信息
|
||||
func (this *ModelRace) ModifyPagodaRaceDataByObjId(uid string, data map[string]interface{}) error {
|
||||
func (this *ModelRace) ModifyPagodaRaceData(uid string, data map[string]interface{}) error {
|
||||
|
||||
return this.Change(uid, data)
|
||||
}
|
||||
|
||||
func (this *ModelRace) getCrossPagodaRaceList(uid string) (result *pb.DBPagodaRace, err error) {
|
||||
var (
|
||||
model *db.DBModel
|
||||
)
|
||||
if model, err = this.module.GetCrossDBModel(this.TableName); err != nil {
|
||||
return
|
||||
}
|
||||
result = &pb.DBPagodaRace{
|
||||
Data: map[int32]*pb.RaceData{},
|
||||
}
|
||||
if err = model.Get(uid, result); err != nil && err == mgo.MongodbNil { // 初始一条数据
|
||||
result.Id = primitive.NewObjectID().Hex()
|
||||
result.Uid = uid
|
||||
result.Data = make(map[int32]*pb.RaceData)
|
||||
result.Rtime = configure.Now().Unix()
|
||||
if err = model.Add(uid, result); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
// 修改爬塔数据信息
|
||||
func (this *ModelRace) ModifyCrossPagodaRaceData(uid string, data map[string]interface{}) error {
|
||||
var (
|
||||
model *db.DBModel
|
||||
err error
|
||||
)
|
||||
if model, err = this.module.GetCrossDBModel(this.TableName); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.Change(uid, data)
|
||||
}
|
||||
|
||||
// 创建一个新的塔数据
|
||||
func (this *ModelRace) addPagodaRace(uId string, data *pb.DBPagodaRace) (err error) {
|
||||
if err = this.Add(uId, data); err != nil {
|
||||
func (this *ModelRace) addCrossPagodaRace(uId string, result *pb.DBPagodaRace) (err error) {
|
||||
var (
|
||||
model *db.DBModel
|
||||
)
|
||||
if model, err = this.module.GetCrossDBModel(this.TableName); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
result.Id = primitive.NewObjectID().Hex()
|
||||
result.Uid = uId
|
||||
if err = model.Add(uId, result); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
@ -102,23 +148,7 @@ func (this *ModelRace) queryPlayers(uIds []string) (result []*pb.DBRacePagodaRec
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModelRace) getCrossPagodaRaceList(uid string) (result *pb.DBPagodaRace, err error) {
|
||||
result = &pb.DBPagodaRace{
|
||||
Data: map[int32]*pb.RaceData{},
|
||||
}
|
||||
if err = this.Get(uid, result); err != nil && err == mgo.MongodbNil { // 初始一条数据
|
||||
result.Id = primitive.NewObjectID().Hex()
|
||||
result.Uid = uid
|
||||
result.Data = make(map[int32]*pb.RaceData)
|
||||
result.Rtime = configure.Now().Unix()
|
||||
err = this.addPagodaRace(uid, result)
|
||||
return
|
||||
}
|
||||
|
||||
return result, err
|
||||
}
|
||||
|
||||
// 六合塔记录
|
||||
// 六合塔记录 (存在跨服)
|
||||
func (this *ModelRace) SetRacePagodaRankList(score int32, uid string) {
|
||||
|
||||
var (
|
||||
@ -147,30 +177,3 @@ func (this *ModelRace) SetRacePagodaRankList(score int32, uid string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ModelRace) SetNormalPagodaRankList(score int32, uid string) {
|
||||
|
||||
var (
|
||||
pipe *pipe.RedisPipe
|
||||
menbers *redis.Z
|
||||
strTable string
|
||||
model *db.DBModel
|
||||
err error
|
||||
)
|
||||
if model, err = this.module.GetCrossDBModel(this.TableName); err != nil {
|
||||
return
|
||||
}
|
||||
strTable = fmt.Sprintf("%s-%s", db.CrossTag(), this.TableName)
|
||||
menbers = &redis.Z{Score: float64(score), Member: uid}
|
||||
pipe = model.Redis.RedisPipe(context.TODO())
|
||||
if cmd := pipe.ZAdd(strTable, menbers); cmd != nil {
|
||||
dock, err1 := cmd.Result()
|
||||
if err1 != nil {
|
||||
this.module.Errorln(dock, err1)
|
||||
}
|
||||
}
|
||||
if _, err := pipe.Exec(); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package pagoda
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
//"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/lego/sys/redis/pipe"
|
||||
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||
)
|
||||
@ -59,26 +57,3 @@ func (this *ModelRank) getPagodaRankListByFloorid(uid string, cid int32) *pb.DBP
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *ModelRank) SetNormalPagodaRankList(tableName string, score int32, uid string) {
|
||||
|
||||
var (
|
||||
pipe *pipe.RedisPipe = this.DBModel.Redis.RedisPipe(context.TODO())
|
||||
menbers *redis.Z
|
||||
)
|
||||
|
||||
menbers = &redis.Z{Score: float64(score), Member: uid}
|
||||
|
||||
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {
|
||||
|
||||
dock, err1 := cmd.Result()
|
||||
if err1 != nil {
|
||||
this.modulePagoda.Errorln(dock, err1)
|
||||
}
|
||||
}
|
||||
if _, err := pipe.Exec(); err != nil {
|
||||
this.modulePagoda.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ func (this *Pagoda) GMModifyRacePagoda(uid string, floor int32) {
|
||||
update["rtime"] = data.Rtime
|
||||
update["battlecount"] = data.Battlecount
|
||||
update["maxfloor"] = data.Maxfloor
|
||||
this.modelRacePagoda.ModifyPagodaRaceDataByObjId(uid, update)
|
||||
this.modelPagoda.modifyPagodaDataByObjId(uid, update)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user