战力:修复战力错误

This commit is contained in:
luying
2021-12-28 19:31:48 +08:00
parent 1dee1a73b4
commit ff1f99ba42
2 changed files with 10 additions and 6 deletions

View File

@@ -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); // 公会更新战力

View File

@@ -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']) });