pvp:修复全局战力未计入pvp的问题

This commit is contained in:
luying
2022-06-22 09:42:11 +08:00
parent 212a68c307
commit 966618b816
2 changed files with 4 additions and 3 deletions

View File

@@ -305,7 +305,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
let hero = await HeroModel.updateHeroInfo(roleId, hid, { ...heroUpdate, ce });
calCe.setResultHero(hero);
heroes.push(hero);
await PvpDefenseModel.updateCe(roleId, hid, inc); // 更新pvp防守阵战力
await PvpDefenseModel.updateCe(roleId, hid, ce); // 更新pvp防守阵战力
pushHeros.push({ hid, ce, incHeroCe: inc });
changeHids.push(hid);
} else {
@@ -316,6 +316,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
for(let [hid, { ce, inc }] of heroCe) {
if(changeHids.indexOf(hid) == -1) {
let hero = await HeroModel.updateHeroInfo(roleId, hid, { ce });
await PvpDefenseModel.updateCe(roleId, hid, ce); // 更新pvp防守阵战力
pushHeros.push({ hid, ce: hero.ce, incHeroCe: inc });
changeHids.push(hid);
}

View File

@@ -109,8 +109,8 @@ export default class PvpDefense extends BaseModel {
}
public static async updateCe(roleId: string, hid: number, incCe: number, lean = true) {
const rec: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({ roleId, 'lineupCe.hid': hid }, { $inc: { 'lineupCe.$.ce': incCe } }).lean(lean);
public static async updateCe(roleId: string, hid: number, ce: number, lean = true) {
const rec: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({ roleId, 'lineupCe.hid': hid }, { $set: { 'lineupCe.$.ce': ce } }).lean(lean);
return rec
}