feat(gvg): 优化血量继承、实时刷新、遗迹天数、系统播报 6267076fc
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,9 @@ export default class GVGUserData extends BaseModel {
|
||||
@prop({ required: false })
|
||||
reviveCnt: number; // 城池id
|
||||
|
||||
@prop({ required: false })
|
||||
winStreak: number; // 连胜
|
||||
|
||||
public static async findByRole(configId: number, leagueCode: string, roleId: string) {
|
||||
const result: GVGUserDataType = await GVGUserDataModel.findOneAndUpdate({ configId, leagueCode, roleId }, {}, { new: true, upsert: true}).lean();
|
||||
return result;
|
||||
@@ -145,6 +148,16 @@ export default class GVGUserData extends BaseModel {
|
||||
const result: GVGUserDataType = await GVGUserDataModel.findOneAndUpdate({ configId, leagueCode, roleId, hasCheckBox: { $exists: false }}, { $set: { hasCheckBox: true } }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async setWinStreak(configId: number, leagueCode: string, roleId: string, isSuccess: boolean) {
|
||||
if (isSuccess) {
|
||||
const result: GVGUserDataType = await GVGUserDataModel.findOneAndUpdate({ configId, leagueCode, roleId }, { $inc: { winStreak: 1 } }, { new: true }).lean();
|
||||
return result;
|
||||
} else {
|
||||
const result: GVGUserDataType = await GVGUserDataModel.findOneAndUpdate({ configId, leagueCode, roleId }, { $set: { winStreak: 0 } }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGUserDataModel = getModelForClass(GVGUserData);
|
||||
|
||||
Reference in New Issue
Block a user