feat(gvg): 添加推送

This commit is contained in:
luying
2023-02-16 22:07:58 +08:00
parent 605ee869a9
commit 2eea5d86d9
15 changed files with 319 additions and 103 deletions

View File

@@ -119,6 +119,9 @@ export default class GVGTeam extends BaseModel {
@prop({ required: false })
batchCode: string; // 批量编号
originPointId: number;
curTeamBreak: boolean;
// 创建队伍
public static async saveTeam(roleId: string, index: number, updateParam: SaveTeamUpdateParam, initParam: InitTeamParam) {
const doc = new GVGTeamModel();
@@ -256,12 +259,13 @@ export default class GVGTeam extends BaseModel {
public static async battleEndAttack(teamCode: string, hpInc: number, playerScoreInc: number, rebirthAreaId: number) {
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { durability: hpInc, score: playerScoreInc } }, { new: true }).lean();
if(team.durability <= 0) {
let originPointId = team.pointId;
team = await GVGTeamModel.teamBreak(teamCode, team.isRobot, team.maxDurability, rebirthAreaId);
team.originPointId = originPointId;
}
return team;
}
originPointId: number;
// 结算防守方
public static async battleEndDefense(teamCode: string, hpInc: number, playerScoreInc: number, rebirthAreaId: number) {
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { defenseTime: nowSeconds() + GVG.GVG_DEFAULT_DEFENSE_CD, lockTime: 0, lockTeamCode: '' }, $inc: { durability: hpInc, score: playerScoreInc } }, { new: true }).lean();
@@ -273,7 +277,6 @@ export default class GVGTeam extends BaseModel {
return team;
}
curTeamBreak: boolean;
// 队伍进入修整器
public static async teamBreak(teamCode: string, isRobot: boolean, maxDurability: number, areaId: number) {
if(!isRobot) {
@@ -313,7 +316,14 @@ export default class GVGTeam extends BaseModel {
}));
}
let teams: GVGTeamType[] = await GVGTeamModel.find({ batchCode }).lean();
return teams
return teams.map(team => {
let originTeam = brokenTeams.find(origin => origin.teamCode == team.teamCode);
if(originTeam) {
team.originPointId = originTeam.originPointId;
team.curTeamBreak = originTeam.curTeamBreak;
}
return team
})
}
// 加积分

View File

@@ -55,7 +55,7 @@ export default class GVGUserItem extends BaseModel {
}
public static async checkItemCnt(configId: number, leagueCode: string, roleId: string, id: number, count: number) {
return await GVGUserItemModel.exists({ configId, leagueCode, roleId, id, count: { $gte: count } });
return await GVGUserItemModel.exists({ configId, leagueCode, roleId, id, count: { $gte: count }, expireTime: { $gte: nowSeconds() } });
}
}