feat(gvg): 激战期数据补充、排行榜等

This commit is contained in:
luying
2023-02-18 14:44:48 +08:00
parent f33ec1aff8
commit 77d04cb04b
11 changed files with 151 additions and 46 deletions
+14 -2
View File
@@ -63,8 +63,20 @@ export default class GVGCity extends BaseModel {
}
// 查询联军驻守情况
public static async findGuardCityByLeague(configId: number, groupId: number, serverType: number, ) {
const cities: GVGCityType[] = await GVGCityModel.find({ configId, groupId, serverType, hasGuard: true }).lean();
public static async findGuardCityByLeague(configId: number, leagueCode: string, select = '') {
const cities: GVGCityType[] = await GVGCityModel.find({ configId, guardLeague: leagueCode, hasGuard: true }).select(select).lean();
return cities
}
// 查询联军驻守情况
public static async checkLeagueHasGuard(configId: number, leagueCode: string) {
return await GVGCityModel.exists({ configId, guardLeague: leagueCode, hasGuard: true });
}
// 查询联军驻守情况
public static async findGuardCity(configId: number, groupId: number, serverType: number, select = '') {
let cities: GVGCityType[] = await GVGCityModel.find({ configId: configId + 1, groupId, serverType, hasGuard: true }).select(select).lean();
if(cities.length == 0) cities = await GVGCityModel.find({ configId, groupId, serverType, hasGuard: true }).select(select).lean();
return cities
}
+6 -3
View File
@@ -93,7 +93,10 @@ export default class GVGTeam extends BaseModel {
defenseTime: number; // 防守保护时间
@prop({ required: true, default: 0 })
score: number; // 积分
battleScore: number; // 积分
@prop({ required: true, default: 0 })
settleScore: number; // 积分
@prop({ required: true, type: () => GVGHeroInfo, _id: false })
lineup: GVGHeroInfo[];
@@ -336,8 +339,8 @@ export default class GVGTeam extends BaseModel {
}
// 加积分
public static async addScore(teamCode: string, incScore: number) {
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { score: incScore } }, { new: true }).lean();
public static async addScore(teamCode: string, battleScore: number, settleScore: number) {
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $inc: { battleScore, settleScore } }, { new: true }).lean();
return team;
}