循环塔排行
This commit is contained in:
parent
f13cb072e4
commit
81f2b568ef
@ -5,6 +5,7 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/redis/pipe"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
@ -27,16 +28,20 @@ func (this *apiComp) CrossRaceRankList(session comm.IUserSession, req *pb.Pagoda
|
||||
szRank []*pb.DBRacePagodaRecord
|
||||
rd *redis.StringSliceCmd
|
||||
)
|
||||
var (
|
||||
pipe *pipe.RedisPipe
|
||||
)
|
||||
if errdata = this.CrossRaceRankListCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if this.module.IsCross() {
|
||||
var (
|
||||
pipe *pipe.RedisPipe = this.module.modelPagoda.Redis.RedisPipe(context.TODO())
|
||||
)
|
||||
conn, _ := db.Local()
|
||||
dbModel := db.NewDBModel(comm.TableRaceRecord, 0, conn)
|
||||
|
||||
rd = pipe.ZRange("race"+strconv.Itoa(int(req.Raceid)), 0, comm.MaxRankList)
|
||||
pipe = conn.Redis.RedisPipe(context.TODO())
|
||||
tablename := "race" + strconv.Itoa(int(req.Raceid))
|
||||
rd = pipe.ZRevRange(tablename, 0, comm.MaxRankList)
|
||||
|
||||
if _, err := pipe.Exec(); err != nil {
|
||||
this.module.Errorln(err)
|
||||
@ -45,10 +50,11 @@ func (this *apiComp) CrossRaceRankList(session comm.IUserSession, req *pb.Pagoda
|
||||
_dataList := rd.Val()
|
||||
for _, v := range _dataList {
|
||||
result := &pb.DBRacePagodaRecord{}
|
||||
if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
||||
if err := dbModel.Redis.HGetAll(v, result); err == nil {
|
||||
szRank = append(szRank, result)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), PagodaCrossRaceRankListReq, &pb.PagodaCrossRaceRankListResp{Ranks: szRank})
|
||||
|
@ -136,7 +136,7 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda
|
||||
Floor: race.Race[conf.Restriction].Curfloor,
|
||||
Type: conf.Restriction,
|
||||
Nickname: userinfo.Name,
|
||||
Icon: "",
|
||||
Icon: userinfo.CurSkin, // 皮肤
|
||||
Lv: userinfo.Lv,
|
||||
Overtime: configure.Now().Unix(),
|
||||
}
|
||||
@ -165,7 +165,7 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda
|
||||
} else {
|
||||
this.module.Errorf("db crosserr :%v", err)
|
||||
}
|
||||
this.module.SetPagodaRankList("race"+strconv.Itoa(int(conf.Restriction)), race.Race[conf.Restriction].Curfloor, newData.Id)
|
||||
this.module.SetRacePagodaRankList("race"+strconv.Itoa(int(conf.Restriction)), race.Race[conf.Restriction].Curfloor, session.GetUserId(), newData.Id)
|
||||
}
|
||||
// 任务相关
|
||||
//go this.module.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype168, pagoda.Data[conf.Tab], conf.Tab))
|
||||
|
@ -199,3 +199,30 @@ func (this *Pagoda) CheckCompletePagoda(uid string) (bComplete bool) {
|
||||
|
||||
return false
|
||||
}
|
||||
func (this *Pagoda) SetRacePagodaRankList(tableName string, score int32, uid string, objID string) {
|
||||
if !this.IsCross() {
|
||||
if conn, err := db.Cross(); err == nil {
|
||||
|
||||
var (
|
||||
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
||||
menbers *redis.Z
|
||||
)
|
||||
|
||||
strKey := "pagodarace:" + uid + "-" + objID // 自定义key
|
||||
menbers = &redis.Z{Score: float64(score), Member: strKey}
|
||||
|
||||
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {
|
||||
|
||||
dock, err1 := cmd.Result()
|
||||
if err1 != nil {
|
||||
this.Errorln(dock, err1)
|
||||
}
|
||||
}
|
||||
if _, err := pipe.Exec(); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user