feat(gvg): 优化血量继承、实时刷新、遗迹天数、系统播报 6267076fc

This commit is contained in:
luying
2023-10-20 09:55:08 +08:00
parent c2ad7145c1
commit d9f911f520
14 changed files with 371 additions and 98 deletions

View File

@@ -273,31 +273,51 @@ export default class GVGTeam extends BaseModel {
}
// 结算挑战方
public static async battleEndAttack(teamCode: string, hpInc: number, rebirthAreaId: number, reviveCd: number) {
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { durability: hpInc }, $set: { lockTime: 0, lockTeamCode: '' } }, { new: true }).lean();
public static async battleEndAttack(teamCode: string, hpInc: number, rebirthAreaId: number, reviveCd: number, lineupParam?: { isAllDead: boolean, newLineup: GVGHeroInfo[] }) {
let team: GVGTeamType;
if (lineupParam) {
if (lineupParam.isAllDead) {
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { durability: 0, lockTime: 0, lockTeamCode: '', lineup: lineupParam.newLineup } }, { new: true }).lean();
} else {
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { durability: hpInc }, $set: { lockTime: 0, lockTeamCode: '', lineup: lineupParam.newLineup } }, { new: true }).lean();
}
} else {
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { durability: hpInc }, $set: { lockTime: 0, lockTeamCode: '' } }, { new: true }).lean();
}
if(team.durability <= 0) {
let originPointId = team.pointId;
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId, team.areaId, reviveCd);
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId, team.areaId, reviveCd, team.lineup);
team.originPointId = originPointId;
}
return team;
}
// 结算防守方
public static async battleEndDefense(teamCode: string, hpInc: number, rebirthAreaId: number, defenseCd: number, reviveCd: number) {
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + defenseCd, lockTime: 0, lockTeamCode: '' }, $inc: { durability: hpInc } }, { new: true }).lean();
public static async battleEndDefense(teamCode: string, hpInc: number, rebirthAreaId: number, defenseCd: number, reviveCd: number, lineupParam?: { isAllDead: boolean, newLineup: GVGHeroInfo[] }) {
let team: GVGTeamType;
if (lineupParam) {
if (lineupParam.isAllDead) {
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + defenseCd, lockTime: 0, lockTeamCode: '', lineup: lineupParam.newLineup, durability: 0 } }, { new: true }).lean();
} else {
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + defenseCd, lockTime: 0, lockTeamCode: '', lineup: lineupParam.newLineup }, $inc: { durability: hpInc } }, { new: true }).lean();
}
} else {
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + defenseCd, lockTime: 0, lockTeamCode: '' }, $inc: { durability: hpInc } }, { new: true }).lean();
}
if(team.durability <= 0) {
let originPointId = team.pointId;
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId, team.areaId, reviveCd);
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId, team.areaId, reviveCd, team.lineup);
team.originPointId = originPointId;
}
return team;
}
// 队伍进入修整器
public static async teamBreak(teamCode: string, isRobot: boolean, maxDurability: number, areaId: number, fromAreaId: number, reviveCd: number) {
public static async teamBreak(teamCode: string, isRobot: boolean, maxDurability: number, areaId: number, fromAreaId: number, reviveCd: number, lineup: GVGHeroInfo[]) {
if(!isRobot) {
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { restartTime: nowSeconds() + reviveCd, stopMoveTime: nowSeconds(), areaId, fromAreaId, durability: maxDurability, pointId: 0 } }, { new: true }).lean();
lineup.forEach(hero => { hero.hp = 'max'; hero.others = ''; })
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { restartTime: nowSeconds() + reviveCd, stopMoveTime: nowSeconds(), areaId, fromAreaId, durability: maxDurability, pointId: 0, lineup } }, { new: true }).lean();
team.curTeamBreak = true;
return team;
} else {
@@ -327,7 +347,10 @@ export default class GVGTeam extends BaseModel {
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: { fromAreaId: team.areaId, areaId: rebirthAreaId, pointId: 0, durability: team.maxDurability, restartTime: nowSeconds() + reviveCd } }, { new: true }).lean();
let lineup = team.lineup||[];
lineup.forEach(hero => { hero.hp = 'max'; hero.others = ''; })
team = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { fromAreaId: team.areaId, areaId: rebirthAreaId, pointId: 0, durability: team.maxDurability, restartTime: nowSeconds() + reviveCd, lineup } }, { new: true }).lean();
team.originPointId = originPointId;
team.curTeamBreak = true;
}