From 43f85b92d0dac9e5516d780ed24e57bc2244824d Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 23 Feb 2023 13:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(gvg):=20=E6=BF=80=E6=88=98?= =?UTF-8?q?=E6=9C=9F=E5=9F=8E=E6=B1=A0=E6=8E=92=E8=A1=8C=E6=A6=9C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=A7=AF=E5=88=86=E5=A2=9E=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/gvg/gvgBattleMemory.ts | 14 +++++++++++ .../app/services/gvg/gvgBattleService.ts | 23 ++++++++----------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/game-server/app/services/gvg/gvgBattleMemory.ts b/game-server/app/services/gvg/gvgBattleMemory.ts index 49eacf716..39f1f499a 100644 --- a/game-server/app/services/gvg/gvgBattleMemory.ts +++ b/game-server/app/services/gvg/gvgBattleMemory.ts @@ -154,6 +154,20 @@ class GVGBattleData { return teams; } + public findSettledPointMapByLeague() { + let pointByLeague = new Map(); + 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(); } diff --git a/game-server/app/services/gvg/gvgBattleService.ts b/game-server/app/services/gvg/gvgBattleService.ts index 368a75090..42aa7d042 100644 --- a/game-server/app/services/gvg/gvgBattleService.ts +++ b/game-server/app/services/gvg/gvgBattleService.ts @@ -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 }); - } }