🐞 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 sortCities = new Map<string, SortCities[]>(); // groupKey => cities
|
||||||
let rankByCity = new Map<string, Map<number, RankAndLastLeague>>(); // groupKey => city => {ranks, lastLeague}
|
let rankByCity = new Map<string, Map<number, RankAndLastLeague>>(); // groupKey => city => {ranks, lastLeague}
|
||||||
await generateData(configId, sortCities, rankByCity);
|
await generateData(configId, sortCities, rankByCity);
|
||||||
|
|
||||||
for(let [groupKey, cities] of sortCities) {
|
for(let [groupKey, cities] of sortCities) {
|
||||||
let cityResult: number[] = [];
|
let cityResult: number[] = [];
|
||||||
let index = 0; // 防死循环,万一出什么事cityResult.length一直不等于cities.length
|
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);
|
await addGuardCity(configId, groupKey, cityId, leagueCode, canSendReward);
|
||||||
guardLeagueCnt.set(leagueCode, cnt + 1);
|
guardLeagueCnt.set(leagueCode, cnt + 1);
|
||||||
cityResult.push(cityId);
|
cityResult.push(cityId);
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
} else {
|
} else {
|
||||||
if(lastLeague) {
|
let city = cities.find(cur => cur.cityId == cityId);
|
||||||
city.index = -1;
|
if(!city) continue;
|
||||||
city.league = lastLeague;
|
if(city.index == -1) {
|
||||||
city.score = 0;
|
|
||||||
} else {
|
|
||||||
cityResult.push(city.cityId); continue;
|
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