From a377f6e9c6fd63f9f1e1cc2ab339f680ef7fdd53 Mon Sep 17 00:00:00 2001 From: luying Date: Mon, 12 Jun 2023 21:10:41 +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=EF=BC=8C=E5=8D=A0=E9=A2=86=E5=9F=8E=E6=B1=A0=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/gvg/gvgBattleService.ts | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/game-server/app/services/gvg/gvgBattleService.ts b/game-server/app/services/gvg/gvgBattleService.ts index b52d02f46..8706a8230 100644 --- a/game-server/app/services/gvg/gvgBattleService.ts +++ b/game-server/app/services/gvg/gvgBattleService.ts @@ -590,7 +590,6 @@ export async function calCityGuard(configId: number, canSendReward: boolean) { let sortCities = new Map(); // groupKey => cities let rankByCity = new Map>(); // groupKey => city => {ranks, lastLeague} await generateData(configId, sortCities, rankByCity); - for(let [groupKey, cities] of sortCities) { let cityResult: number[] = []; let index = 0; // 防死循环,万一出什么事cityResult.length一直不等于cities.length @@ -611,28 +610,28 @@ export async function calCityGuard(configId: number, canSendReward: boolean) { await addGuardCity(configId, groupKey, cityId, leagueCode, canSendReward); guardLeagueCnt.set(leagueCode, cnt + 1); cityResult.push(cityId); - } - } - - for(let city of cities) { // 没有成功防守到联军的城池,进行下一轮处理 - if(cityResult.indexOf(city.cityId) != -1) continue; - if(city.index == -1) { - cityResult.push(city.cityId); continue; - } - let nextIndex = city.index + 1; - let { ranks, lastLeague } = rankByCity.get(groupKey)?.get(city.cityId)||{ ranks: [], lastLeague: '' }; - if(ranks[nextIndex]) { - city.index = nextIndex; - city.league = ranks[nextIndex].code; - city.score = ranks[nextIndex].num; + break; } else { - if(lastLeague) { - city.index = -1; - city.league = lastLeague; - city.score = 0; - } else { + let city = cities.find(cur => cur.cityId == cityId); + if(!city) continue; + if(city.index == -1) { cityResult.push(city.cityId); continue; } + let nextIndex = city.index + 1; + let { ranks, lastLeague } = rankByCity.get(groupKey)?.get(city.cityId)||{ ranks: [], lastLeague: '' }; + if(ranks[nextIndex]) { + city.index = nextIndex; + city.league = ranks[nextIndex].code; + city.score = ranks[nextIndex].num; + } else { + if(lastLeague) { + city.index = -1; + city.league = lastLeague; + city.score = 0; + } else { + cityResult.push(city.cityId); continue; + } + } } } }