✨ feat(gvg): 概览

This commit is contained in:
luying
2023-02-17 21:13:04 +08:00
parent 0a65a0863d
commit 295128d668
5 changed files with 136 additions and 16 deletions
+5 -2
View File
@@ -11,7 +11,6 @@ class Player {
teamCnt: number;
}
@index({ configId: 1, cityId: 1, groupId: 1, serverType: 1 })
// GVGCity 类,继承自 BaseModel
export default class GVGCity extends BaseModel {
@@ -77,12 +76,16 @@ export default class GVGCity extends BaseModel {
// 占领城池
public static async guardCity(configId: number, groupId: number, serverType: number, cityId: number, league: LeagueRankInfo) {
console.log('##### guardCity', configId, groupId, serverType, cityId)
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId: configId + 1, cityId, groupId, serverType }, { $set: {
hasGuard: true, guardLeague: league.code, guardLeagueName: league.name, guardLeagueIcon: league.icon
} }, { upsert: true, new: true }).lean();
return city;
}
public static async findByConfig(configId: number, groupId: number, serverType: number) {
const cities: GVGCityType[] = await GVGCityModel.find({ configId, groupId, serverType, hasGuard: true }).lean();
return cities
}
}