🐞 fix(gvg): 修复城池驻守和机器人刷新逻辑
This commit is contained in:
+11
-15
@@ -212,19 +212,15 @@ export default class GVGTeam extends BaseModel {
|
||||
|
||||
// 每赛季初刷新机器人
|
||||
public static async initRobots(configId: number, groupKey: string, cityId: number, dicPoints: DicGVGAreaPoint[], lv: number) {
|
||||
await GVGTeamModel.bulkWrite(dicPoints.map(({ pointId, areaId, name, head, spine, ce, durability }) => {
|
||||
return {
|
||||
updateOne: {
|
||||
filter: { groupKey, cityId, areaId, pointId },
|
||||
update: { $setOnInsert: {
|
||||
teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, isRobot: true, lv,
|
||||
isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', leagueCode: '', leagueName: '', fromAreaId: areaId,
|
||||
}, $set: { configId, durability } },
|
||||
upsert: true
|
||||
}
|
||||
}
|
||||
}));
|
||||
return await this.findRobotTeams(groupKey, cityId);
|
||||
let teams: GVGTeamType[] = [];
|
||||
for(let { pointId, areaId, name, head, spine, ce, durability } of dicPoints) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ groupKey, cityId, areaId, pointId }, {
|
||||
$setOnInsert: {teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, isRobot: true, lv, isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', leagueCode: '', leagueName: '', fromAreaId: areaId,
|
||||
}, $set: { configId, durability }
|
||||
}, { new: true, upsert: true }).lean();
|
||||
teams.push(team);
|
||||
}
|
||||
return teams;
|
||||
}
|
||||
|
||||
public static async findCatapultTeams(groupKey: string, cityId: number) {
|
||||
@@ -304,8 +300,8 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public static async findByAreaId(groupKey: string, cityId: number, areaId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ groupKey, cityId, areaId, stopMoveTime: { $lte: nowSeconds() }, isBroken: false }).lean();
|
||||
public static async findByAreaId(configId: number, groupKey: string, cityId: number, areaId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ configId, groupKey, cityId, areaId, stopMoveTime: { $lte: nowSeconds() }, isBroken: false }).lean();
|
||||
return team;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user