(武将): 设置副将时从阵容中删除

This commit is contained in:
luying
2023-03-30 14:50:05 +08:00
parent fd124e3554
commit 2afe3e01f4
3 changed files with 13 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ import { isGoodsHidden, isHeroHidden } from '../../../services/dataService';
import { LadderMatchModel } from '../../../db/LadderMatch';
import { PvpSaveDataModel } from '../../../db/PvpSaveData';
import { ArtifactModel } from '../../../db/Artifact';
import { GVGVestigeRankModel } from '../../../db/GVGVestigeRank';
import { GVGTeamModel } from '../../../db/GVGTeam';
export default function (app: Application) {
new HandlerService(app, {});
@@ -779,6 +781,8 @@ export class HeroHandler {
await LadderMatchModel.removeBySub(roleId, subHid);
await PvpSaveDataModel.removeBySub(roleId, subHid);
await PvpDefenseModel.removeBySub(roleId, subHid);
await GVGVestigeRankModel.removeBySub(roleId, subHid);
await GVGTeamModel.removeBySub(roleId, subHid, subHero.ce);
} else { // 卸下
if(!hero.subHid) return resResult(STATUS.HERO_CAN_NOT_REMOVE_SUB);

View File

@@ -352,6 +352,11 @@ export default class GVGTeam extends BaseModel {
public static async checkLockTeam(roleId: string, cityId: number) {
return await GVGTeamModel.exists({ roleId, lockTime: { $gt: nowSeconds() }, cityId: { $ne: cityId } })
}
public static async removeBySub(roleId: string, subHid: number, ce: number) {
console.log('removeBySub', roleId, subHid, ce)
await GVGTeamModel.updateMany({ roleId, 'lineup.actorId': subHid }, { $pull: { lineup: { actorId: subHid } }, $inc: { lineupCe: -ce } });
}
}
export const GVGTeamModel = getModelForClass(GVGTeam);

View File

@@ -165,6 +165,10 @@ export default class GVGVestigeRank extends BaseModel {
let result: GVGVestigeRankType[] = await GVGVestigeRankModel.find({ day: today, vestigeId, groupKey, rank: { $gt: 0 } }).sort({ rank: 1 }).select('roleId rank lineup').lean();
return result;
}
public static async removeBySub(roleId: string, subHid: number) {
await GVGVestigeRankModel.updateMany({ roleId, hasDefense: true }, { $pull: { lineup: { actorId: subHid } } });
}
}
export const GVGVestigeRankModel = getModelForClass(GVGVestigeRank);