feat(gvg): 进驻积分点

This commit is contained in:
luying
2023-02-15 15:12:16 +08:00
parent 6815bf316a
commit 4359bfd9cc
10 changed files with 129 additions and 39 deletions

View File

@@ -74,7 +74,7 @@ export default class GVGTeam extends BaseModel {
lockTime: number; // 正在被进攻中
@prop({ required: true, default: 0 })
attackTeam: string; // 正在被这支队伍进攻中
lockTeamCode: string; // 正在被这支队伍进攻中
@prop({ required: true, default: 0 })
fromAreaId: number; // 从那个区域移动
@@ -207,8 +207,14 @@ export default class GVGTeam extends BaseModel {
}
// 防守方锁定cd
public static async battleStartLockDefense(teamCode: string, attackTeam: string) {
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { lockTime: nowSeconds() + GVG.GVG_DEFAULT_ATTACK_CD, attackTeam } }, { new: true }).lean();
public static async battleStartLockDefense(teamCode: string, lockTeamCode: string) {
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { lockTime: nowSeconds() + GVG.GVG_DEFAULT_ATTACK_CD, lockTeamCode } }, { new: true }).lean();
return team;
}
// 占领积分点
public static async settlePoint(teamCode: string, pointId: number) {
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { pointId } }, { new: true }).lean();
return team;
}
@@ -220,7 +226,7 @@ export default class GVGTeam extends BaseModel {
// 结算防守方
public static async battleEndDefense(teamCode: string, hpInc: number, playerScoreInc: number) {
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + GVG.GVG_DEFAULT_DEFENSE_CD }, $inc: { durability: hpInc, playerScore: playerScoreInc } }, { new: true }).lean();
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + GVG.GVG_DEFAULT_DEFENSE_CD, lockTime: 0, lockTeamCode: '' }, $inc: { durability: hpInc, playerScore: playerScoreInc } }, { new: true }).lean();
return team;
}
@@ -244,6 +250,12 @@ export default class GVGTeam extends BaseModel {
const team: GVGTeamType[] = await GVGTeamModel.find({ configId, cityId: { $gt: 0 } }).lean();
return team;
}
// 这个编队上是否已经有队伍了
public static async checkPoint(configId: number, groupId: number, serverType: number, pointId: number) {
return await GVGTeamModel.exists({ configId, groupId, serverType, pointId });
}
}