🐞 fix(gvg): 激战期投石车推送
This commit is contained in:
+12
-15
@@ -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