🐞 fix(gvg): 修复队伍进出城池内存更新
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ import { GVG_REC_TYPE } from '../consts';
|
||||
@index({ createTime: -1 })
|
||||
export default class GVGRec extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: '' })
|
||||
@prop({ required: false, default: '' })
|
||||
leagueCode: string; // 联军id
|
||||
|
||||
@prop({ required: false, default: '' })
|
||||
|
||||
+8
-20
@@ -136,14 +136,9 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
|
||||
// 玩家切换城池更新队伍信息
|
||||
public static async enterCity(roleId: string, cityId: number, areaId: number, groupKey: string) {
|
||||
let teams = await GVGTeamModel.findByRole(roleId, '-_id')
|
||||
let result: GVGTeamType[] = [];
|
||||
for(let targetTeam of teams) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode: targetTeam.teamCode }, { $set: { cityId, areaId, fromAreaId: areaId, pointId: 0, groupKey } }, { new: true }).lean();
|
||||
result.push(team);
|
||||
}
|
||||
return result;
|
||||
public static async enterCity(teamCode: string, cityId: number, areaId: number, groupKey: string) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { cityId, areaId, fromAreaId: areaId, pointId: 0, groupKey } }, { new: true }).lean();
|
||||
return team;
|
||||
}
|
||||
|
||||
// 离开队伍
|
||||
@@ -205,16 +200,9 @@ export default class GVGTeam extends BaseModel {
|
||||
}
|
||||
|
||||
// 每赛季初刷新自己的耐久等东西
|
||||
public static async refreshByConfig(roleId: string, updateArr: GVGTeamUpdate[]) {
|
||||
await GVGTeamModel.bulkWrite(updateArr.map(obj => {
|
||||
return {
|
||||
updateOne: {
|
||||
filter: { roleId, teamCode: obj.teamCode },
|
||||
update: { $set: obj }
|
||||
}
|
||||
}
|
||||
}));
|
||||
return await GVGTeamModel.findByRole(roleId, '-_id');
|
||||
public static async refreshByConfig(teamCode: string, update: GVGTeamUpdate) {
|
||||
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: update }, { new: true }).lean();
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async findRobotTeams(groupKey: string, cityId: number) {
|
||||
@@ -306,11 +294,11 @@ export default class GVGTeam extends BaseModel {
|
||||
// 队伍进入修整器
|
||||
public static async teamBreak(teamCode: string, isRobot: boolean, maxDurability: number, areaId: number, fromAreaId: number, reviveCd: number) {
|
||||
if(!isRobot) {
|
||||
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { restartTime: nowSeconds() - reviveCd, stopMoveTime: nowSeconds(), areaId, fromAreaId, durability: maxDurability } }, { new: true }).lean();
|
||||
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { restartTime: nowSeconds() - reviveCd, stopMoveTime: nowSeconds(), areaId, fromAreaId, durability: maxDurability, pointId: 0 } }, { new: true }).lean();
|
||||
team.curTeamBreak = true;
|
||||
return team;
|
||||
} else {
|
||||
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { fromAreaId, durability: 0, isBroken: true } }, { new: true }).lean();
|
||||
const team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode }, { $set: { fromAreaId, pointId: 0, durability: 0, isBroken: true } }, { new: true }).lean();
|
||||
team.curTeamBreak = true;
|
||||
return team;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user