上传竞技场代码
This commit is contained in:
parent
c464856c7f
commit
e5c034ac81
@ -14,11 +14,12 @@ func (this *apiComp) RankCheck(session comm.IUserSession, req *pb.ArenaRankReq)
|
||||
// /排行榜获取
|
||||
func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
info *pb.DBArenaUser
|
||||
uids []string
|
||||
ranks []*pb.DBArenaUser
|
||||
players []*pb.ArenaPlayer
|
||||
err error
|
||||
info *pb.DBArenaUser
|
||||
uids []string
|
||||
ranks []*pb.DBArenaUser
|
||||
ranksMap map[string]*pb.DBArenaUser
|
||||
players []*pb.ArenaPlayer
|
||||
err error
|
||||
)
|
||||
|
||||
if errdata = this.RankCheck(session, req); errdata != nil {
|
||||
@ -48,25 +49,32 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
|
||||
}
|
||||
return
|
||||
}
|
||||
ranksMap = make(map[string]*pb.DBArenaUser)
|
||||
for _, v := range ranks {
|
||||
ranksMap[v.Uid] = v
|
||||
}
|
||||
players = make([]*pb.ArenaPlayer, len(ranks))
|
||||
for i, v := range ranks {
|
||||
rank := int32(i + 1)
|
||||
players[i] = &pb.ArenaPlayer{
|
||||
Uinfo: v.Uinfo,
|
||||
Dan: v.Dan,
|
||||
Rank: rank,
|
||||
Integral: v.Integral,
|
||||
}
|
||||
if session.GetUserId() == v.Uinfo.Uid && info.Rank != rank {
|
||||
info.Rank = rank
|
||||
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
for i, v := range uids {
|
||||
if player, ok := ranksMap[v]; ok {
|
||||
rank := int32(i + 1)
|
||||
players[i] = &pb.ArenaPlayer{
|
||||
Uinfo: player.Uinfo,
|
||||
Dan: player.Dan,
|
||||
Rank: rank,
|
||||
Integral: player.Integral,
|
||||
}
|
||||
if session.GetUserId() == player.Uinfo.Uid && info.Rank != rank {
|
||||
info.Rank = rank
|
||||
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "rank", &pb.ArenaRankResp{Players: players, Info: info})
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user