🐞 fix(gvg): 激战期投石车推送
This commit is contained in:
@@ -33,15 +33,17 @@ class GVGBattleData {
|
||||
}
|
||||
|
||||
public findCatapultAttackTeam(areaIds: number[], leagueCode: string) {
|
||||
let teams: string[] = [];
|
||||
let teamsByArea = new Map<number, string[]>();
|
||||
for(let areaId of areaIds) {
|
||||
let teams: string[] = [];
|
||||
let teamCodes = this.areaToTeams.get(areaId)||new Set();
|
||||
for(let teamCode of teamCodes) {
|
||||
let team = this.teams.get(teamCode);
|
||||
if(team && team.leagueCode != leagueCode && !team.isRobot) teams.push(teamCode);
|
||||
}
|
||||
teamsByArea.set(areaId, teams);
|
||||
}
|
||||
return teams;
|
||||
return teamsByArea;
|
||||
}
|
||||
|
||||
public leaveCity(roleId: string) {
|
||||
|
||||
@@ -318,21 +318,23 @@ export async function catapultHurt() {
|
||||
if(catapult.isBroken) continue;
|
||||
let dicArea = gameData.gvgArea.get(catapult.areaId);
|
||||
let relateArea = dicArea?.relateArea||[];
|
||||
let teamCodes = teamObj.findCatapultAttackTeam(relateArea, catapult.leagueCode);
|
||||
let teamCodeByArea = teamObj.findCatapultAttackTeam(relateArea, catapult.leagueCode);
|
||||
let dicGVGCity = gameData.gvgCity.get(catapult.cityId);
|
||||
let teams = await GVGTeamModel.attackByCatapult(teamCodes, catapult.captapultAtk, dicGVGCity.attackBirth);
|
||||
teamObj.battleEnd(teams);
|
||||
if(teams.length > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(teamObj.groupKey, catapult.areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId: catapult.areaId, attackType: 1, teams: teams.map(team => new GVGTeamInList(team))
|
||||
});
|
||||
await sendMessageToGVGAreaWithSuc(teamObj.groupKey, catapult.areaId, PUSH_ROUTE.GVG_SPINE_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId: catapult.areaId, attackType: 1, teams: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
||||
});
|
||||
for(let team of teams) {
|
||||
await pushTeamBeHurtMessage(team);
|
||||
if(team.curTeamBreak && team.originPointId > 0) {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, teamObj.groupKey, team.originPointId);
|
||||
for(let [ areaId, teamCodes ] of teamCodeByArea) {
|
||||
let teams = await GVGTeamModel.attackByCatapult(teamCodes, catapult.captapultAtk, dicGVGCity.attackBirth);
|
||||
teamObj.battleEnd(teams);
|
||||
if(teams.length > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(teamObj.groupKey, areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: 1, teams: teams.map(team => new GVGTeamInList(team))
|
||||
});
|
||||
await sendMessageToGVGCityWithSuc(teamObj.groupKey, catapult.cityId, PUSH_ROUTE.GVG_SPINE_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: 1, teams: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
||||
});
|
||||
for(let team of teams) {
|
||||
await pushTeamBeHurtMessage(team);
|
||||
if(team.curTeamBreak && team.originPointId > 0) {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, teamObj.groupKey, team.originPointId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,22 +317,19 @@ export default class GVGTeam extends BaseModel {
|
||||
|
||||
// 投石车伤害
|
||||
public static async attackByCatapult(teamCodes: string[], inc: number, rebirthAreaId: number) {
|
||||
await GVGTeamModel.updateMany({ teamCode: { $in: teamCodes } }, { $inc: { durability: -inc } });
|
||||
let brokenTeams: GVGTeamType[] = await GVGTeamModel.find({ teamCode: { $in: teamCodes }, durability: { $lte: 0 } }).lean();
|
||||
if(brokenTeams.length > 0) {
|
||||
await GVGTeamModel.bulkWrite(brokenTeams.map(({ teamCode, maxDurability }) => {
|
||||
return { updateOne: { filter: { teamCode }, update: { $set: { areaId: rebirthAreaId, pointId: 0, durability: maxDurability } }}}
|
||||
}));
|
||||
}
|
||||
let teams: GVGTeamType[] = await GVGTeamModel.find({ teamCode: { $in: teamCodes } }).lean();
|
||||
return teams.map(team => {
|
||||
let originTeam = brokenTeams.find(origin => origin.teamCode == team.teamCode);
|
||||
if(originTeam) {
|
||||
team.originPointId = originTeam.originPointId;
|
||||
team.curTeamBreak = originTeam.curTeamBreak;
|
||||
let teams: GVGTeamType[] = [];
|
||||
for(let teamCode of teamCodes) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { durability: -inc } }, { new: true }).lean();
|
||||
let originPointId = team.pointId;
|
||||
if(team.durability <= 0) {
|
||||
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { areaId: rebirthAreaId, pointId: 0, durability: team.maxDurability } }, { new: true }).lean();
|
||||
team.originPointId = originPointId;
|
||||
team.curTeamBreak = true;
|
||||
}
|
||||
return team
|
||||
})
|
||||
teams.push(team);
|
||||
}
|
||||
return teams
|
||||
|
||||
}
|
||||
|
||||
// 加积分
|
||||
|
||||
Reference in New Issue
Block a user