🐞 fix(gvg): 守城顺序&投石车数据
This commit is contained in:
@@ -233,10 +233,15 @@ export async function leaveCity(isForce: boolean, roleId: string, serverId: numb
|
||||
}
|
||||
|
||||
// 复活cd
|
||||
export async function getTechReviveMinus(configId: number, leagueCode: string) {
|
||||
let leaguePrepare = await GVGLeaguePrepareModel.findByLeague(configId, leagueCode);
|
||||
export async function getTechReviveMinus(groupKey: string, configId: number, leagueCode: string) {
|
||||
let teamObj = getGVGBattleData(groupKey);
|
||||
let activeTech = teamObj.getLeagueTech(leagueCode);
|
||||
if(!activeTech) {
|
||||
let leaguePrepare = await GVGLeaguePrepareModel.findByLeague(configId, leagueCode);
|
||||
activeTech = leaguePrepare?.activeTech||[];
|
||||
teamObj.setLeagueTech(leagueCode, activeTech);
|
||||
}
|
||||
let minusCd = 0;
|
||||
let activeTech = leaguePrepare?.activeTech||[];
|
||||
for(let techId of activeTech) {
|
||||
let dicTech = gameData.gvgTech.get(techId);
|
||||
if(dicTech && dicTech.type == GVG_TECH_TYPE.BATTLE_REVIVE_GAP) {
|
||||
@@ -245,6 +250,7 @@ export async function getTechReviveMinus(configId: number, leagueCode: string) {
|
||||
}
|
||||
let cd = GVG.GVG_DEFAULT_REVIVE_CD - minusCd;
|
||||
if(cd < 0) cd = 0;
|
||||
|
||||
return cd;
|
||||
}
|
||||
|
||||
@@ -366,16 +372,20 @@ export async function catapultHurt() {
|
||||
let battleAreaIds = dicGVGCity?.battleAreaIds||[]
|
||||
if(!catapult || catapult.isBroken || !dicGVGCity || battleAreaIds.length <= 0) continue;
|
||||
let areaId = getRandSingleEelm(battleAreaIds);
|
||||
let teamCodes = teamObj.findCatapultAttackTeam(areaId, catapult.leagueCode);
|
||||
|
||||
let teams = await GVGTeamModel.attackByCatapult(teamCodes, catapult.captapultAtk, dicGVGCity.attackBirth);
|
||||
// let areaId = catapult.cityId * 100 + 2;
|
||||
let teamMems = teamObj.findCatapultAttackTeam(areaId, catapult.leagueCode);
|
||||
let teams: GVGTeamType[] = [];
|
||||
for(let { teamCode, leagueCode } of teamMems) {
|
||||
let team = await GVGTeamModel.attackByCatapult(teamCode, catapult.captapultAtk, dicGVGCity.attackBirth, await getTechReviveMinus(teamObj.groupKey, configId, leagueCode));
|
||||
teams.push(team);
|
||||
}
|
||||
teamObj.battleEnd(teams);
|
||||
if(teams.length > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(teamObj.groupKey, areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: GVG_ATTACK_TYPE.CATAPULT, teams: teams.map(team => new GVGTeamInList(team))
|
||||
});
|
||||
await sendMessageToGVGCityWithSuc(teamObj.groupKey, catapult.cityId, PUSH_ROUTE.GVG_SPINE_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: GVG_ATTACK_TYPE.CATAPULT, teams: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
||||
cityId: catapult.cityId, areaId, teamCode: catapult.teamCode, attackType: GVG_ATTACK_TYPE.CATAPULT, spines: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
||||
});
|
||||
for(let team of teams) {
|
||||
await pushTeamBeHurtMessage(team);
|
||||
@@ -486,7 +496,12 @@ export async function gvgBattleEnd() {
|
||||
let rankKeys = keys.map(key => {
|
||||
let [,, groupKey, _cityId] = key.split(':');
|
||||
return { groupKey, cityId: parseInt(_cityId) };
|
||||
}).sort((a, b) => b.cityId - a.cityId);
|
||||
}).sort((a, b) => {
|
||||
let dicCityA = gameData.gvgCity.get(a.cityId);
|
||||
let dicCityB = gameData.gvgCity.get(b.cityId);
|
||||
if(dicCityA.cityType == dicCityB.cityType) return a.cityId - b.cityId;
|
||||
return dicCityA.cityType - dicCityB.cityType;
|
||||
});
|
||||
let lastCities = await GVGCityModel.findByConfig(configId);
|
||||
for(let { cityId, groupKey } of lastCities) {
|
||||
let hasKey = rankKeys.find(cur => cur.cityId == cityId && cur.groupKey == groupKey);
|
||||
@@ -500,30 +515,28 @@ export async function gvgBattleEnd() {
|
||||
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
|
||||
let ranks = await r.getRankByRange();
|
||||
// 排名最高占领城池
|
||||
let hasGuard = false;
|
||||
for(let obj of ranks) {
|
||||
let rankInfo = <LeagueRankInfo>obj;
|
||||
let cnt = guardLeagueCnt.get(rankInfo.code)||0;
|
||||
if(cnt < GVG.GVG_CITY_OCCUPIED_NUMBER) {
|
||||
await addGuardCity(configId, groupKey, cityId, rankInfo.code);
|
||||
guardLeagueCnt.set(rankInfo.code, cnt + 1);
|
||||
hasGuard = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let guardCity = lastCities.find(city => city.cityId == cityId && city.groupKey == groupKey);
|
||||
if(guardCity) {
|
||||
let cnt = guardLeagueCnt.get(guardCity.guardLeague)||0;
|
||||
if(cnt < GVG.GVG_CITY_OCCUPIED_NUMBER) {
|
||||
await addGuardCity(configId, groupKey, cityId, guardCity.guardLeague);
|
||||
guardLeagueCnt.set(guardCity.guardLeague, cnt + 1);
|
||||
if(!hasGuard) {
|
||||
let guardCity = lastCities.find(city => city.cityId == cityId && city.groupKey == groupKey);
|
||||
if(guardCity) {
|
||||
let cnt = guardLeagueCnt.get(guardCity.guardLeague)||0;
|
||||
if(cnt < GVG.GVG_CITY_OCCUPIED_NUMBER) {
|
||||
await addGuardCity(configId, groupKey, cityId, guardCity.guardLeague);
|
||||
guardLeagueCnt.set(guardCity.guardLeague, cnt + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(let { cityId, groupKey, guardLeague } of lastCities) {
|
||||
let hasKey = rankKeys.find(cur => cur.cityId == cityId && cur.groupKey == groupKey);
|
||||
if(hasKey) continue;
|
||||
await addGuardCity(configId, groupKey, cityId, guardLeague);
|
||||
}
|
||||
|
||||
// 联军排行榜发放奖励
|
||||
let leagueKeys = await findKeys(`${REDIS_KEY.GVG_BATTLE_LEAGUE_RANK}:${configId}:`);
|
||||
@@ -569,11 +582,11 @@ async function addGuardCity(configId: number, groupKey: string, cityId: number,
|
||||
|
||||
// —————————— 推送相关 —————————— //
|
||||
// 推送
|
||||
export async function battleEndSendMessage(groupKey: string, cityId: number, defenseTeam: GVGTeamType, attackTeam: GVGTeamType) {
|
||||
export async function battleEndSendMessage(groupKey: string, cityId: number, defenseTeam: GVGTeamType, attackTeam: GVGTeamType, attackType: GVG_ATTACK_TYPE) {
|
||||
let areaId = defenseTeam.curTeamBreak? defenseTeam.fromAreaId: defenseTeam.areaId;
|
||||
// 推送伤害
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId, areaId, attackType: GVG_ATTACK_TYPE.PLAYER, teams: [new GVGTeamInList(defenseTeam), new GVGTeamInList(attackTeam)]
|
||||
cityId, areaId, attackType, teams: [new GVGTeamInList(defenseTeam), new GVGTeamInList(attackTeam)]
|
||||
});
|
||||
await pushTeamBeHurtMessage(defenseTeam, attackTeam);
|
||||
await pushTeamBeHurtMessage(attackTeam);
|
||||
|
||||
Reference in New Issue
Block a user