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