🐞 fix(gvg): 修复战区问题,不跨服服务器应单列
This commit is contained in:
+17
-20
@@ -105,10 +105,7 @@ export default class GVGTeam extends BaseModel {
|
||||
lineupCe: number;
|
||||
|
||||
@prop({ required: true })
|
||||
groupId: number; // 战区
|
||||
|
||||
@prop({ required: true })
|
||||
serverType: number; // 单服还是跨服
|
||||
groupKey: string; // 战区
|
||||
|
||||
@prop({ required: true, default: false })
|
||||
isRobot: boolean; // 是否是机器人
|
||||
@@ -136,8 +133,8 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
|
||||
// 玩家切换城池更新队伍信息
|
||||
public static async enterCity(roleId: string, cityId: number, areaId: number, groupId: number, serverType: number) {
|
||||
const res = await GVGTeamModel.updateMany({ roleId }, { cityId, areaId, fromAreaId: areaId, pointId: 0, groupId, serverType }).lean();
|
||||
public static async enterCity(roleId: string, cityId: number, areaId: number, groupKey: string) {
|
||||
const res = await GVGTeamModel.updateMany({ roleId }, { cityId, areaId, fromAreaId: areaId, pointId: 0, groupKey }).lean();
|
||||
return !!res['ok'];
|
||||
}
|
||||
|
||||
@@ -200,17 +197,17 @@ export default class GVGTeam extends BaseModel {
|
||||
return await GVGTeamModel.findByRole(roleId, '-_id');
|
||||
}
|
||||
|
||||
public static async findRobotTeams(groupId: number, serverType: number, cityId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ groupId, serverType, cityId, isRobot: true }).lean();
|
||||
public static async findRobotTeams(groupKey: string, cityId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ groupKey, cityId, isRobot: true }).lean();
|
||||
return team;
|
||||
}
|
||||
|
||||
// 每赛季初刷新机器人
|
||||
public static async initRobots(configId: number, groupId: number, serverType: number, cityId: number, dicPoints: DicGVGAreaPoint[]) {
|
||||
public static async initRobots(configId: number, groupKey: string, cityId: number, dicPoints: DicGVGAreaPoint[]) {
|
||||
await GVGTeamModel.bulkWrite(dicPoints.map(({ pointId, areaId, name, head, spine, ce, durability }) => {
|
||||
return {
|
||||
updateOne: {
|
||||
filter: { groupId, serverType, cityId, areaId, pointId },
|
||||
filter: { groupKey, cityId, areaId, pointId },
|
||||
update: { $setOnInsert: {
|
||||
teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, isRobot: true,
|
||||
isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', leagueCode: '', leagueName: '', fromAreaId: areaId,
|
||||
@@ -219,20 +216,20 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
}
|
||||
}));
|
||||
return await this.findRobotTeams(groupId, serverType, cityId);
|
||||
return await this.findRobotTeams(groupKey, cityId);
|
||||
}
|
||||
|
||||
public static async findCatapultTeams(groupId: number, serverType: number, cityId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ groupId, serverType, cityId, isRobot: true, isCatapult: true }).lean();
|
||||
public static async findCatapultTeams(groupKey: string, cityId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ groupKey, cityId, isRobot: true, isCatapult: true }).lean();
|
||||
return team;
|
||||
}
|
||||
|
||||
// 生成投石车
|
||||
public static async initCatapult(configId: number, groupId: number, serverType: number, cityId: number, leagueCode: string, leagueName: string, areaIds: number[], atk: number, durability: number) {
|
||||
public static async initCatapult(configId: number, groupKey: string, cityId: number, leagueCode: string, leagueName: string, areaIds: number[], atk: number, durability: number) {
|
||||
await GVGTeamModel.bulkWrite(areaIds.map(areaId => {
|
||||
return {
|
||||
updateOne: {
|
||||
filter: { groupId, serverType, cityId, areaId },
|
||||
filter: { groupKey, cityId, areaId },
|
||||
update: { $setOnInsert: {
|
||||
teamCode: genCode(8), maxDurability: durability, captapultAtk: atk, leagueCode, leagueName,
|
||||
roleName: GVG.GVG_CATAPULT_NAME, head: GVG.GVG_CATAPULT_HEAD, spine: GVG.GVG_CATAPULT_SPINE, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: GVG.GVG_CATAPULT_CE,
|
||||
@@ -243,7 +240,7 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
}
|
||||
}));
|
||||
return await this.findCatapultTeams(groupId, serverType, cityId);
|
||||
return await this.findCatapultTeams(groupKey, cityId);
|
||||
}
|
||||
|
||||
// 攻击方攻击cd
|
||||
@@ -299,8 +296,8 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public static async findByAreaId(groupId: number, serverType: number, cityId: number, areaId: number) {
|
||||
const team: GVGTeamType[] = await GVGTeamModel.find({ groupId, serverType, cityId, areaId, stopMoveTime: { $lte: nowSeconds() }, isBroken: false }).lean();
|
||||
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();
|
||||
return team;
|
||||
}
|
||||
|
||||
@@ -310,8 +307,8 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
|
||||
// 这个编队上是否已经有队伍了
|
||||
public static async checkPoint(configId: number, groupId: number, serverType: number, pointId: number) {
|
||||
return await GVGTeamModel.exists({ configId, groupId, serverType, pointId, isBroken: false });
|
||||
public static async checkPoint(configId: number, groupKey: string, pointId: number) {
|
||||
return await GVGTeamModel.exists({ configId, groupKey, pointId, isBroken: false });
|
||||
}
|
||||
|
||||
// 投石车伤害
|
||||
|
||||
Reference in New Issue
Block a user