🐞 fix(gvg): 激战期城池排行榜添加积分增速

This commit is contained in:
luying
2023-02-23 13:22:14 +08:00
parent 5ce06be73d
commit 43f85b92d0
2 changed files with 24 additions and 13 deletions

View File

@@ -154,6 +154,20 @@ class GVGBattleData {
return teams;
}
public findSettledPointMapByLeague() {
let pointByLeague = new Map<string, number[]>();
for(let [_roleId, pointIds] of this.rolePoints) {
for(let [pointId, teamCode] of pointIds) {
let team = this.teams.get(teamCode);
if(pointId > 0 && team && team.leagueCode) {
if(!pointByLeague.has(team.leagueCode)) pointByLeague.set(team.leagueCode, []);
pointByLeague.get(team.leagueCode).push(team.pointId);
};
}
}
return pointByLeague;
}
public findAreas() {
return this.areaToTeams.keys();
}

View File

@@ -318,17 +318,22 @@ export async function redisAddSettleScore(gvgTeam: GVGTeamType, incScore: number
}
// 获取排行榜
export async function getBattleRanksByCity(configId: number, groupKey: string, cityId: number, myLeague: GVGLeagueType) {
export async function getBattleRanksByCity(configId: number, groupKey: string, cityId: number, myLeague?: GVGLeagueType) {
let teamObj = getGVGBattleData(groupKey);
let pointByLeague = teamObj.findSettledPointMapByLeague();
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
r.setGenerFieldsFun((obj => {
if(obj instanceof LeagueRankInfo) {
return { rank: obj.rank, leagueCode: obj.code, leagueName: obj.name, score: obj.num }
let pointIds = pointByLeague.get(obj.code)||[];
let incScore = 0;
for(let pointId of pointIds) incScore += gameData.gvgAreaPoint.get(pointId)?.score||0;
return { rank: obj.rank, leagueCode: obj.code, leagueName: obj.name, score: obj.num, incScore }
}
return obj
}));
let { ranks, myRank } = await r.getRankListWithMyRank({ leagueCode: myLeague.leagueCode });
if (!myRank) {
let { ranks, myRank } = await r.getRankListWithMyRank({ leagueCode: myLeague?.leagueCode });
if (myLeague && !myRank) {
myRank = await r.generMyRankWithLeague(myLeague.leagueCode, 0, 0, myLeague);
}
return { ranks, myRank }
@@ -362,16 +367,8 @@ export async function gvgBattleSeconds() {
}
for(let { groupKey, cityId } of keys) {
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
let rawRanks = await r.getRankByRange();
let ranks = rawRanks.map(obj => {
if(obj instanceof LeagueRankInfo) {
return { rank: obj.rank, leagueCode: obj.code, leagueName: obj.name, score: obj.num }
}
return obj
})
let { ranks } = await getBattleRanksByCity(configId, groupKey, cityId);
await sendMessageToGVGCityWithSuc(groupKey, cityId, PUSH_ROUTE.GVG_CITY_RANK_UPDATE, { cityId, ranks });
}
}