上传竞技场代码

This commit is contained in:
liwei1dao 2024-02-06 15:38:54 +08:00
parent c464856c7f
commit e5c034ac81

View File

@ -17,6 +17,7 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
info *pb.DBArenaUser
uids []string
ranks []*pb.DBArenaUser
ranksMap map[string]*pb.DBArenaUser
players []*pb.ArenaPlayer
err error
)
@ -48,16 +49,21 @@ 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 {
for i, v := range uids {
if player, ok := ranksMap[v]; ok {
rank := int32(i + 1)
players[i] = &pb.ArenaPlayer{
Uinfo: v.Uinfo,
Dan: v.Dan,
Uinfo: player.Uinfo,
Dan: player.Dan,
Rank: rank,
Integral: v.Integral,
Integral: player.Integral,
}
if session.GetUserId() == v.Uinfo.Uid && info.Rank != rank {
if session.GetUserId() == player.Uinfo.Uid && info.Rank != rank {
info.Rank = rank
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
errdata = &pb.ErrorData{
@ -68,6 +74,8 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
}
}
}
}
session.SendMsg(string(this.module.GetType()), "rank", &pb.ArenaRankResp{Players: players, Info: info})
return
}