🐞 fix(gvg): 修复城池驻守和机器人刷新逻辑
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import BaseModel from "./BaseModel";
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { LeagueRankInfo } from "../domain/rank";
|
||||
import { GVGLeagueType } from "./GVGLeague";
|
||||
|
||||
class Player {
|
||||
@prop({ required: true })
|
||||
@@ -96,17 +96,22 @@ export default class GVGCity extends BaseModel {
|
||||
}
|
||||
|
||||
// 占领城池
|
||||
public static async guardCity(configId: number, groupKey: string, cityId: number, league: LeagueRankInfo) {
|
||||
public static async guardCity(configId: number, groupKey: string, cityId: number, league: GVGLeagueType) {
|
||||
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId: configId + 1, cityId, groupKey }, { $set: {
|
||||
hasGuard: true, guardLeague: league.code, guardLeagueName: league.name, guardLeagueIcon: league.icon
|
||||
hasGuard: true, guardLeague: league.leagueCode, guardLeagueName: league.name, guardLeagueIcon: league.icon
|
||||
}, $setOnInsert: { userCnt: 0, players: [] } }, { upsert: true, new: true }).lean();
|
||||
return city;
|
||||
}
|
||||
|
||||
public static async findByConfig(configId: number, groupKey: string) {
|
||||
public static async findByConfigAndGroup(configId: number, groupKey: string) {
|
||||
const cities: GVGCityType[] = await GVGCityModel.find({ configId, groupKey, hasGuard: true }).lean();
|
||||
return cities
|
||||
}
|
||||
|
||||
public static async findByConfig(configId: number) {
|
||||
const cities: GVGCityType[] = await GVGCityModel.find({ configId, hasGuard: true }).lean();
|
||||
return cities
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user