🐞 fix(gvg): 修复离开战场逻辑

This commit is contained in:
luying
2023-02-22 14:27:23 +08:00
parent 6cf038b588
commit a3ea2be808
5 changed files with 28 additions and 24 deletions

View File

@@ -54,11 +54,16 @@ export default class GVGCity extends BaseModel {
}
// 减少人数
public static async decreasePlayer(configId: number, groupKey: string, cityId: number, roleId: string) {
public static async decreasePlayerByCity(configId: number, groupKey: string, cityId: number, roleId: string) {
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId, groupKey, cityId, 'players.roleId': roleId }, { $inc: { userCnt: -1 }, $pull: { players: { roleId } }}, { new: true }).lean();
return city;
}
public static async decreasePlayer(configId: number, groupKey: string, roleId: string) {
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId, groupKey, 'players.roleId': roleId }, { $inc: { userCnt: -1 }, $pull: { players: { roleId } }}, { new: true }).lean();
return city;
}
// 添加人数
public static async increaseTeam(configId: number, groupKey: string, cityId: number, roleId: string) {
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId, groupKey, cityId, 'players.roleId': roleId }, { $inc: { 'players.$.teamCnt': 1 }}, { new: true }).lean();
@@ -79,7 +84,7 @@ export default class GVGCity extends BaseModel {
// 查询联军驻守情况
public static async findGuardCity(configId: number, groupKey: string, select = '') {
let cities: GVGCityType[] = await GVGCityModel.find({ configId: configId + 1, groupKey, hasGuard: true }).select(select).lean();
if(cities.length == 0) cities = await GVGCityModel.find({ configId, groupKey, hasGuard: true }).select(select).lean();
if(cities) cities = await GVGCityModel.find({ configId, groupKey }).select(select).lean();
return cities
}