From 7e583b8f5d0972abd39ed68970d3e68d7724581d Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 7 Mar 2023 13:43:18 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(gvg):=20=E4=BF=AE=E5=A4=8Dgv?= =?UTF-8?q?g=E5=AE=88=E5=9F=8E=E4=BC=9A=E5=87=BA=E7=8E=B0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E8=81=94=E5=86=9B3=E4=B8=AA=E5=9F=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/gvg/gvgBattleService.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/game-server/app/services/gvg/gvgBattleService.ts b/game-server/app/services/gvg/gvgBattleService.ts index b4ac76173..af0eb473b 100644 --- a/game-server/app/services/gvg/gvgBattleService.ts +++ b/game-server/app/services/gvg/gvgBattleService.ts @@ -561,7 +561,7 @@ export async function calCityGuard(configId: number) { for(let [groupKey, cities] of sortCities) { let cityResult: number[] = []; let index = 0; // 防死循环,万一出什么事cityResult.length一直不等于cities.length - + let guardLeagueCnt = new Map(); while(cityResult.length != cities.length && (++index < 1000)) { let sorted = cities .filter(city => cityResult.indexOf(city.cityId) == -1) @@ -571,8 +571,8 @@ export async function calCityGuard(configId: number) { return b.cityId - a.cityId; }); - let guardLeagueCnt = new Map(); for(let { league: leagueCode, cityId } of sorted) { + if(!leagueCode) continue; let cnt = guardLeagueCnt.get(leagueCode)||0; if(cnt < GVG.GVG_CITY_OCCUPIED_NUMBER) { await addGuardCity(configId, groupKey, cityId, leagueCode); @@ -619,11 +619,12 @@ async function generateData(configId: number, sortCities: Mapawait r.getRankByRange(); - let guardCity = lastCities.find(city => city.cityId == cityId && city.groupKey == groupKey); + if(ranks.length <= 0) continue; if(!sortCities.has(groupKey)) sortCities.set(groupKey, []); - sortCities.get(groupKey).push({ cityType: dicCity.cityType, cityId, index: 0, league: ranks.length > 0? ranks[0].code: (guardCity?.guardLeague), score: ranks.length > 0? ranks[0].num: 0 }); + sortCities.get(groupKey).push({ cityType: dicCity.cityType, cityId, index: 0, league: ranks[0].code, score: ranks[0].num }); if(!rankByCity.has(groupKey)) rankByCity.set(groupKey, new Map()); + let guardCity = lastCities.find(city => city.cityId == cityId && city.groupKey == groupKey); if(!rankByCity.get(groupKey).has(cityId)) rankByCity.get(groupKey).set(cityId, { ranks, lastLeague: guardCity?.guardLeague??'' }) } for(let { groupKey, cityId, guardLeague } of lastCities) { @@ -641,9 +642,11 @@ async function generateData(configId: number, sortCities: Map