名将擂台:排行榜

This commit is contained in:
luying
2022-07-19 17:14:11 +08:00
parent 8297742afd
commit 0fbc8bd7d8
6 changed files with 46 additions and 6 deletions
+12 -3
View File
@@ -15,6 +15,7 @@ import { CounterModel } from "../db/Counter";
import { ActivityTimeLimitRankModel } from "../db/ActivityTimeLimitRank";
import { sendMessageToServerWithSuc } from "./pushService";
import { LadderMatchModel } from "../db/LadderMatch";
import { completeLadderRanks } from "./ladderService";
/**
@@ -659,8 +660,8 @@ export class Rank {
}
}
public async getRankListWithMyRank(myId: myIdInter) {
let ranks = await this.getRankByRange();
public async getRankListWithMyRank(myId: myIdInter, isReverse = false) {
let ranks = await this.getRankByRange('+inf', '-inf', isReverse);
let newRanks = [], newMyRank: any;
let myRank = ranks.find(cur => {
return cur.isMyInfo(myId);
@@ -1173,6 +1174,9 @@ export async function getRankInHandler(redisKey: REDIS_KEY, type: RANK_TYPE, key
let r = new Rank(redisKey, keyParam);
r.setGenerFieldsFun((obj => {
let result = new RoleAndGuildRankInfo(obj.rank, obj.num);
if(type == RANK_TYPE.LADDER) {
result = new RoleAndGuildRankInfo(obj.num, 0);
}
if(obj instanceof GuildRankInfo) {
result.setGuildInfo(obj);
}
@@ -1182,7 +1186,7 @@ export async function getRankInHandler(redisKey: REDIS_KEY, type: RANK_TYPE, key
return result
}));
let { ranks, myRank } = await r.getRankListWithMyRank({ roleId, guildCode });
let { ranks, myRank } = await r.getRankListWithMyRank({ roleId, guildCode }, type == RANK_TYPE.LADDER);
if (!myRank) {
let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true);
if (type == RANK_TYPE.TOP_LINTUP) {
@@ -1214,7 +1218,12 @@ export async function getRankInHandler(redisKey: REDIS_KEY, type: RANK_TYPE, key
let limitRank = await ActivityTimeLimitRankModel.findByCode(serverId, keyParam.activityId, guildCode);
myRank = await r.generMyRankWithGuild(guildCode, limitRank?.score||0, limitRank?.time);
}
} else if (type == RANK_TYPE.LADDER) {
myRank = await r.generMyRankWithRole(roleId, 0, 0, role);
}
}
if(type == RANK_TYPE.LADDER) {
ranks = completeLadderRanks(ranks);
}
return { ranks, myRank }
}