From ff1f99ba4206699ed5ff69ca285ae127f354df73 Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 28 Dec 2021 19:31:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E5=8A=9B=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=88=98=E5=8A=9B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/pubUtils/playerCe.ts | 7 +++---- shared/pubUtils/roleUtil.ts | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/shared/pubUtils/playerCe.ts b/shared/pubUtils/playerCe.ts index c154f524b..d98a1afb2 100644 --- a/shared/pubUtils/playerCe.ts +++ b/shared/pubUtils/playerCe.ts @@ -71,7 +71,6 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>(); - let roleCe = 0; // 总战力加成 let allIncCe = 0; for (let hero of heros) { let { attr: heroAttrs, lv } = hero; @@ -82,7 +81,6 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU if(heroCe != hero.ce) { let incHeroCe = heroCe - hero.ce; allIncCe += incHeroCe; - roleCe += heroCe; pushHeros.push({ hid: hero.hid, ce: reduceCe(heroCe), incHeroCe: reduceCe(incHeroCe) }); await HeroModel.updateHeroInfo(roleId, hero.hid, { ce: heroCe }); await PvpDefenseModel.updateCe(roleId, hero.hid, incHeroCe); // 更新pvp防守阵战力 @@ -93,11 +91,12 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU if(allIncCe != 0) { update.attr = roleAttrs; - update.ce = roleCe; update.topLineup = topLineup; update.topLineupCe = topLineupCe; } - role = await RoleModel.updateRoleInfo(roleId, update); + + console.log('************ roleAttr', update.attr) + role = await RoleModel.incRoleInfo(roleId, { ce: allIncCe },update); let guild = await GuildModel.updateCe(roleId, allIncCe); // 公会更新战力 diff --git a/shared/pubUtils/roleUtil.ts b/shared/pubUtils/roleUtil.ts index 1536bcb81..8a1f0ddb9 100644 --- a/shared/pubUtils/roleUtil.ts +++ b/shared/pubUtils/roleUtil.ts @@ -100,6 +100,7 @@ import { pick } from "underscore"; import { HeroShowParam } from '../domain/roleField/hero'; import { saveCeChangeLog } from "./logUtil"; import { ActivityInRemote } from "../domain/activityField/activityField"; +import { AttributeCal } from "../domain/roleField/attribute"; // 储存在内存中的初始数据 export function getInitRoleInfo() { @@ -288,10 +289,14 @@ export class CreateHeroes extends UpdateHeroes { this.updateDbCe(true, heroInfo); // 皮肤使用初始加载进内存的数据 let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: new SkinModel()._id }, false); - initHeroInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id }); + let newAttr = new AttributeCal(); + newAttr.setLv(heroInfo.lv); + newAttr.setByDbData(role.attr, heroInfo.attr); + let heroCe = newAttr.calCe(); // 计算最终战力 + initHeroInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id, ce: heroCe }); this.heroNum ++; } - // 武将使用初始加载数据插入 + // 武将使用初始加载数据插入 this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, initHeroInfos); let heroSkins = this.resultHeroes.map(cur => { return pick(cur, ['hid', 'skins']) });