🐞 fix(gvg): 激战期,占领城池逻辑
This commit is contained in:
@@ -590,7 +590,6 @@ export async function calCityGuard(configId: number, canSendReward: boolean) {
|
||||
let sortCities = new Map<string, SortCities[]>(); // groupKey => cities
|
||||
let rankByCity = new Map<string, Map<number, RankAndLastLeague>>(); // 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user