战力
This commit is contained in:
@@ -4,16 +4,15 @@ import { ItemInter } from "../../../pubUtils/interface";
|
||||
|
||||
import { resResult, parseGoodStr, getRandomByLen, deepCopy, mergeSameGoods, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||
import { addItems, handleCost, decreaseItems } from "../../../services/rewardService";
|
||||
import { checkMaterialEnough } from "../../../services/equipService";
|
||||
import { EquipModel, RandSe } from "../../../db/Equip";
|
||||
import { EquipModel, RandSe, EquipType } from "../../../db/Equip";
|
||||
import { HeroModel, EPlace } from "../../../db/Hero";
|
||||
import { ItemModel } from "../../../db/Item";
|
||||
import Role from "../../../db/Role";
|
||||
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||
import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||
import { getHeroJob, getGoodById, gameData, getSuit, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||
import { EQUIP } from "../../../pubUtils/dicParam";
|
||||
import { ITID, SPEICAL_ITEM, RANDOM_SE_COUNT } from "../../../consts/constModules/itemConst";
|
||||
import { changeEquip } from "../../../services/equipService";
|
||||
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService";
|
||||
|
||||
const _ = require('underscore');
|
||||
|
||||
@@ -423,7 +422,7 @@ export class EquipHandler {
|
||||
let obj = ITID.get(goodInfo.itid);
|
||||
let id = obj.type;
|
||||
let curEquips: Array<{ seqId: number, hid: number}> = [];
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
let hero = await HeroModel.getHeroEquip(roleId, hid);
|
||||
if (!hero)
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
if (type == 1) {
|
||||
@@ -439,23 +438,18 @@ export class EquipHandler {
|
||||
let index = _.findIndex(hero.ePlace, { id });
|
||||
if (index < 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let objectId = <string>hero.ePlace[index].equip;
|
||||
let curEquip = await changeEquip(roleId, sid, objectId, equip.hid, id, eid);
|
||||
let equipOffInfo = <EquipType>hero.ePlace[index].equip;
|
||||
let curEquip = await changeEquip(roleId, sid, equipOffInfo, equip.hid, id, eid);
|
||||
if (!!curEquip)
|
||||
curEquips.push(curEquip);
|
||||
curEquip = await dressEquip(roleId, sid, hero, equip);
|
||||
if (!!curEquip)
|
||||
curEquips.push(curEquip);
|
||||
hero = await HeroModel.addEquip(roleId, hid, id, equip._id);
|
||||
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
curEquips.push({ seqId: eid, hid });
|
||||
} else if (type == 2) {
|
||||
if (!equip.hid)
|
||||
return resResult(STATUS.EQUIP_NOT_EQUIPED);
|
||||
let index = _.findIndex(hero.ePlace, { id });
|
||||
if (index < 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
hero.ePlace[index].equip = null;
|
||||
let {seqId} = await EquipModel.updateEquipInfo(eid, { hid: 0 });
|
||||
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
curEquips.push({ seqId, hid:0 });
|
||||
let curEquip = await takeOffEquipAndCalPlayerCe(roleId, sid, equip.seqId, hero, id)
|
||||
curEquips.push(curEquip);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curEquips: curEquips });
|
||||
}
|
||||
@@ -622,6 +616,7 @@ export class EquipHandler {
|
||||
let goodInfo = getGoodById(jewel);
|
||||
let good = ITID.get(goodInfo.itid);
|
||||
let needUpdate = false;
|
||||
let oldJewel;
|
||||
let consumes: Array<{id: number, count: number, ratio?: number}> = [];
|
||||
if (good.type != CONSUME_TYPE.JEWEL)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
@@ -630,6 +625,7 @@ export class EquipHandler {
|
||||
equip = await EquipModel.getEquip(eid);
|
||||
let index = _.findIndex(equip.holes,{id});
|
||||
if (!!equip.holes[index] && equip.holes[index].jewel == goodInfo.composeMaterial[0].id) {
|
||||
oldJewel = equip.holes[index].jewel;
|
||||
equip.holes[index].jewel = jewel;
|
||||
needUpdate = true;
|
||||
consumes.push({id: goodInfo.composeMaterial[0].id, count: 1, ratio: 1});
|
||||
@@ -645,6 +641,10 @@ export class EquipHandler {
|
||||
let result = {};
|
||||
if (needUpdate) {
|
||||
await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
if (!!equip.hid) {
|
||||
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.JEWEL_ON, [jewel, oldJewel]);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
} else {
|
||||
result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
||||
|
||||
@@ -6,13 +6,12 @@ import {Application, BackendSession} from 'pinus';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { getTitle, getTeraph, gameData } from '../../../pubUtils/data';
|
||||
import { SCHOOL, SCROLL } from '../../../pubUtils/dicParam';
|
||||
import { getTeraphAttr } from '../../../consts/constModules/abilityConst'
|
||||
import { getTeraphAttr, getAtrrNameById } from '../../../consts/constModules/abilityConst'
|
||||
const _ = require('underscore');
|
||||
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
||||
import { SchoolModel } from '../../../db/School';
|
||||
import { TERAPH_RANDOM } from '../../../consts/consts';
|
||||
import { checkMaterialEnough } from '../../../services/roleService'
|
||||
import { calPlayerCeAndSave } from '../../../services/playerCeService';
|
||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||
import { HERO_SYSTEM_TYPE } from '../../../consts';
|
||||
|
||||
export default function(app: Application) {
|
||||
@@ -121,11 +120,13 @@ export class RoleHandler {
|
||||
let {attr, consumes} = checkMaterialEnough(type, attrs, teraphInfo, teraph);
|
||||
for (let key in attr) {
|
||||
teraph[key] += attr[key];
|
||||
role.globalCeAttr[key].fixUp += attr[key];
|
||||
}
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
await RoleModel.updateRoleInfo(roleId, { teraphs: role.teraphs });
|
||||
await RoleModel.updateRoleInfo(roleId, { teraphs: role.teraphs, globalCeAttr: role.globalCeAttr});
|
||||
await calAllHeroCe( sid, roleId);
|
||||
return resResult(STATUS.SUCCESS, { roleId, teraphs: role.teraphs });
|
||||
}
|
||||
|
||||
@@ -148,13 +149,19 @@ export class RoleHandler {
|
||||
teraph[attrName] = 0;
|
||||
}
|
||||
teraph.grade++;
|
||||
if (!getTeraph(id, teraph.grade))
|
||||
let nextTeraphInfo = getTeraph(id, teraph.grade)
|
||||
if (!nextTeraphInfo)
|
||||
return resResult(STATUS.DIC_DATA_NOT_FOUND)
|
||||
let consumes = teraphInfo.upGradeMaterial;
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
await RoleModel.updateRoleInfo(roleId, { teraphs: role.teraphs });
|
||||
for (let {id, number} of nextTeraphInfo.assiAttrValue) {
|
||||
let attrName = getAtrrNameById(id);
|
||||
role.globalCeAttr[attrName].ratioUp += number;
|
||||
}
|
||||
await RoleModel.updateRoleInfo(roleId, { teraphs: role.teraphs, globalCeAttr: role.globalCeAttr});
|
||||
await calAllHeroCe(sid, roleId);
|
||||
return resResult(STATUS.SUCCESS, { roleId, teraphs: role.teraphs });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { mergeSameGoods } from '../pubUtils/util';
|
||||
import { EquipModel } from "../db/Equip";
|
||||
import { HeroModel, EPlace } from "../db/Hero";
|
||||
import { HeroModel, EPlace, HeroType } from "../db/Hero";
|
||||
import { ITID } from "../consts/constModules/itemConst";
|
||||
import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../pubUtils/data";
|
||||
import { calPlayerCeAndSave } from "./playerCeService";
|
||||
import { HERO_SYSTEM_TYPE } from "../consts";
|
||||
import { EquipType } from "../db/Equip";
|
||||
import { calEquipSeids } from '../pubUtils/playerCe';
|
||||
const _ = require('underscore');
|
||||
|
||||
export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) {
|
||||
let comJewelMap = {};
|
||||
consumes = mergeSameGoods(consumes);
|
||||
@@ -38,46 +39,48 @@ export function checkMaterialEnough(consumes:Array<{id: number, count: number}>,
|
||||
return needConsumes;
|
||||
}
|
||||
|
||||
export async function changeEquip(roleId: string, sid: string, objectId: string, hid: number, id: number, seqId: number) {
|
||||
export async function changeEquip(roleId: string, sid: string, equip: EquipType, hid: number, id: number, seqId: number) {
|
||||
let hero;
|
||||
if (!!hid)
|
||||
if (!!hid) //需要卸下或者替换的武将
|
||||
hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!!objectId) {
|
||||
let equip = await EquipModel.getEquipByObjectId(objectId);
|
||||
if (!!hero) {
|
||||
if (!!equip) {//需要卸下的装备
|
||||
if (!!hero) {//判断是否替换装备
|
||||
let goodInfo = getGoodById(equip.id);
|
||||
let obj = ITID.get(goodInfo.itid);
|
||||
let ePlaceId = obj.type;
|
||||
if (goodInfo.lvLimited > hero.lv)
|
||||
return takeOffEquip(objectId);
|
||||
if (goodInfo.lvLimited > hero.lv)
|
||||
return takeOffEquip(equip.seqId);
|
||||
let { jobid } = gameData.hero.get(hid);
|
||||
let { job_class } = getHeroJob(jobid);
|
||||
let { classId } = getHeroEquipByClassId(goodInfo.itid);
|
||||
if (_.indexOf(classId, job_class) < 0)
|
||||
return takeOffEquip(objectId);
|
||||
hero = await HeroModel.addEquip(roleId, hero.hid, ePlaceId, objectId);
|
||||
// await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, []);
|
||||
if (!!hero) {
|
||||
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
let ePlaces = <EPlace>hero.ePlace;
|
||||
let ePlace= _.findWhere(ePlaces,{ id: ePlaceId });
|
||||
return { seqId: ePlace.equip.seqId, hid };
|
||||
}
|
||||
if (_.indexOf(classId, job_class) < 0)
|
||||
return takeOffEquip(equip.seqId);
|
||||
return dressEquip(roleId, sid, hero, equip);
|
||||
} else {
|
||||
return takeOffEquip(objectId);
|
||||
return takeOffEquip(equip.seqId);
|
||||
}
|
||||
}
|
||||
if (!!hero) {
|
||||
let index = _.findIndex(hero.ePlace, { id });
|
||||
if (index < 0)
|
||||
return;
|
||||
hero.ePlace[index].equip = null;
|
||||
await EquipModel.updateEquipInfo(seqId, { hid: 0 });
|
||||
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
} else if (!!hero) {//从穿戴装备的武将上卸下装备
|
||||
await takeOffEquipAndCalPlayerCe(roleId, sid, seqId, hero, id);//卸下装备并重算战力
|
||||
}
|
||||
}
|
||||
|
||||
async function takeOffEquip(objectId: string) {
|
||||
let { seqId } = await EquipModel.updateEquipInfobyObjectId(objectId, { hid: 0 });
|
||||
export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, seqId: number, hero:HeroType, id: number ) {
|
||||
let index = _.findIndex(hero.ePlace, { id });
|
||||
if (index < 0)
|
||||
return;
|
||||
await EquipModel.updateEquipInfo(seqId, { hid: 0 });
|
||||
hero.ePlace[index].equip = null;
|
||||
let args = calEquipSeids(hero);
|
||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, args);
|
||||
return { seqId, hid: 0};
|
||||
}
|
||||
|
||||
export async function dressEquip(roleId: string, sid: string, hero:HeroType, equip: EquipType) {
|
||||
hero = await HeroModel.addEquip(roleId, hero.hid, equip.ePlaceId, equip._id);
|
||||
let args = calEquipSeids(hero);
|
||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, args);
|
||||
return { seqId: equip.seqId, hid: hero.hid };
|
||||
}
|
||||
|
||||
async function takeOffEquip(seqId: number) {
|
||||
await EquipModel.updateEquipInfo(seqId, { hid: 0 });
|
||||
return { seqId, hid: 0};
|
||||
}
|
||||
@@ -5,7 +5,11 @@
|
||||
import { pinus } from 'pinus';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
|
||||
<<<<<<< HEAD
|
||||
import { resResult, reduceCe } from '../pubUtils/util';
|
||||
=======
|
||||
import { resResult, reduceCe } from '../pubUtils/util';
|
||||
>>>>>>> cb1f9ea... 战力
|
||||
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
|
||||
import { HeroType } from '../db/Hero';
|
||||
const _ = require('underscore');
|
||||
@@ -16,19 +20,27 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Arr
|
||||
let {role, pushHeros} = await pubCalPlayerCeAndSave(roleId, heros, type, args);
|
||||
//下发战力
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
<<<<<<< HEAD
|
||||
let pushHerosReduced = pushHeros.map(cur => {
|
||||
return { hid: cur.hid, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }
|
||||
});
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: pushHerosReduced, topFiveCe: 0 }), uids);
|
||||
=======
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce), heros: pushHeros, topFiveCe: 0 }), uids);
|
||||
>>>>>>> cb1f9ea... 战力
|
||||
return heros;
|
||||
}
|
||||
|
||||
export async function calAllHeroCe(sid: string, roleId: string, type:number, args:Array<number>) {
|
||||
export async function calAllHeroCe(sid: string, roleId: string, type?:number, args?:Array<number>) {
|
||||
let {ce, pushHeros}= await reCalAllHeroCe(roleId,type, args);
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
<<<<<<< HEAD
|
||||
let pushHerosReduced = pushHeros.map(cur => {
|
||||
return { hid: cur.hid, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }
|
||||
});
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHerosReduced, topFiveCe: 0 }), uids);
|
||||
=======
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topFiveCe: 0 }), uids);
|
||||
>>>>>>> cb1f9ea... 战力
|
||||
return;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ export default class Hero extends BaseModel {
|
||||
}
|
||||
|
||||
public static async getHeroEquip(roleId: string, hid: number, lean = true) {
|
||||
let result: HeroType = await HeroModel.findOne({ roleId, hid }).populate('ePlace.equip').select('ePlace.equip').lean(lean);
|
||||
let result: HeroType = await HeroModel.findOne({ roleId, hid }).populate('ePlace.equip').lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,6 @@ export function getScollByStar(quality: number, star: number, curQuality: number
|
||||
return heroScroll;
|
||||
}
|
||||
|
||||
|
||||
// 根据存在升星表等的stage字段的id对应17维id
|
||||
export function getFieldByStage(stage: number, jobid: number) {
|
||||
let targetAttrId = ABI_TYPE_TO_STAGE.get(stage);
|
||||
@@ -241,4 +240,9 @@ export function getFieldByStage(stage: number, jobid: number) {
|
||||
const dicJob = gameData.job.get(jobid);
|
||||
return targetAttrId(dicJob.type);
|
||||
}
|
||||
}
|
||||
|
||||
export function getSuit(id: number) {
|
||||
const suitInfo = gameData.suit.get(id);
|
||||
return suitInfo;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ export interface DicSuit {
|
||||
readonly totalCount: number;
|
||||
// 套装效果
|
||||
readonly effect: Array<{ count: number, seid: number }>;
|
||||
readonly tireInfo: Map<number,number>;
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_SUIT);
|
||||
@@ -20,6 +21,7 @@ export const dicSuit = new Map<number, DicSuit>();
|
||||
|
||||
arr.forEach(o => {
|
||||
o.effect = parseSuitEffect(o.effect);
|
||||
o.tireInfo = parseTireInfo(o.tireInfo);
|
||||
dicSuit.set(o.id, o);
|
||||
});
|
||||
arr = undefined;
|
||||
@@ -35,4 +37,13 @@ function parseSuitEffect(str: string) {
|
||||
result.push({ count: parseInt(count), seid: parseFloat(seid) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function parseTireInfo(str: string) {
|
||||
let result = new Map<number,number>();
|
||||
let arrs = str.split('&');
|
||||
for (let arr of arrs) {
|
||||
result.set(parseInt(arr), 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ export interface DicTeraph {
|
||||
readonly criEffect;
|
||||
readonly upMaterial:Array<{id: number, number: number}>;
|
||||
|
||||
readonly assiAttrValue: Map<number, number>;
|
||||
readonly assiAttrValue:Array<{id: number, number: number}>;
|
||||
readonly upGradeMaterial:Array<{id: number, number: number}>;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { HERO_SYSTEM_TYPE, ABI_TYPE, JEWEL_ATTR } from '../consts';
|
||||
|
||||
import { deepCopy, getAllAttrStage } from './util';
|
||||
import { deepCopy, getAllAttrStage, reduceCe } from './util';
|
||||
import { HeroModel, HeroType } from '../db/Hero';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { CeAttrData, CeAttr, CeAttrRole, CeAttrNumber, CeAttrDataRole } from '../db/generalField';
|
||||
@@ -60,6 +60,7 @@ export function calPlayerCe(globalCeAttr: CeAttrRole, hero: HeroType, type: numb
|
||||
|
||||
addSeidEffect(reIncAttr, hero.ceAttr, addSeidList, removeSeidList); // 处理加值
|
||||
if(!hero.ceAttr) hero.ceAttr = new CeAttr();
|
||||
|
||||
for (let attrName in reIncAttr) {
|
||||
if(!reIncAttr[attrName] || attrName == '_id') continue;
|
||||
let originalAttrData: CeAttrData = hero.ceAttr[attrName]||new CeAttrData();
|
||||
@@ -114,8 +115,8 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
|
||||
pushHeros.push({
|
||||
hid: hero.hid,
|
||||
ce: hero.ce,
|
||||
incHeroCe : incHeroCe,
|
||||
ce: reduceCe(hero.ce),
|
||||
incHeroCe : reduceCe(incHeroCe),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -440,11 +441,44 @@ export function calEquipPutOnOffIncAttr(hero: HeroType, args: Array<number>, add
|
||||
}
|
||||
});
|
||||
|
||||
for(let arg of args) { removeSeidList.push(arg) }
|
||||
for(let arg of args) {
|
||||
removeSeidList.push(arg)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
export function calEquipSeids(hero: HeroType) {
|
||||
let seids = [];
|
||||
// 计算被动技能
|
||||
let { ePlace } = hero;
|
||||
let suits = new Map<number, number>();
|
||||
|
||||
for(let { equip } of ePlace) {
|
||||
if(equip) {
|
||||
let e = <EquipType>equip;
|
||||
for(let { seid, rand } of e.randSe) {
|
||||
seids.push(seid, rand);
|
||||
}
|
||||
if(e.suitId > 0) {
|
||||
if(suits.has(e.suitId)) {
|
||||
suits.set(e.suitId, 1);
|
||||
} else {
|
||||
suits.set(e.suitId, suits.get(e.suitId) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
suits.forEach((suitId, count) => {
|
||||
let { effect } = gameData.suit.get(suitId);
|
||||
for(let e of effect) {
|
||||
if(count >= e.count) {
|
||||
seids.push(e.seid, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return seids;
|
||||
}
|
||||
|
||||
// 装备,装备栏升级,装备精炼等涉及到值的
|
||||
export function calHeroEquipIncAttr(hero: HeroType) {
|
||||
@@ -632,8 +666,7 @@ function calHeroCeWhenJewelOff(hero: HeroType, args: Array<number>) {
|
||||
export async function reCalAllHeroCe(roleId: string, type: number, args:Array<number>) {
|
||||
let reIncAttr: CeAttrRole = {};
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
if(!role.globalCeAttr) role.globalCeAttr = new CeAttrRole();
|
||||
let originalAttr = role.globalCeAttr;
|
||||
if(!role.globalCeAttr) role.globalCeAttr = new CeAttr();
|
||||
let pushHeros:Array<{hid:number, ce:number, incHeroCe:number}> = []
|
||||
if (type == 1) {//获得皮肤
|
||||
reIncAttr = calHeroAddSkin(args, role.globalCeAttr);
|
||||
@@ -642,17 +675,23 @@ export async function reCalAllHeroCe(roleId: string, type: number, args:Array<nu
|
||||
role.globalCeAttr[attrName].fixUp = reIncAttr[attrName].fixUp;
|
||||
role.globalCeAttr[attrName].ratioUp = reIncAttr[attrName].ratioUp;
|
||||
}
|
||||
role.ce = 0;
|
||||
let heros = await HeroModel.findByRole(roleId);
|
||||
for (let hero of heros) {
|
||||
let incHeroCe = 0;
|
||||
for (let attrName in reIncAttr) {
|
||||
let oldcCe = originalAttr[attrName].fixUp * HERO_CE_RATIO + hero.ceAttr[attrName].base * (HERO_CE_RATIO + originalAttr[attrName].ratioUp);
|
||||
let incArr = role.globalCeAttr[attrName].fixUp * HERO_CE_RATIO + hero.ceAttr[attrName].base * (HERO_CE_RATIO + role.globalCeAttr[attrName].ratioUp) - oldcCe;
|
||||
incHeroCe += incArr * getAttrCeRatio(attrName);
|
||||
let heroCe = 0;
|
||||
for (let attrName in role.globalCeAttr) {
|
||||
if (attrName == '_id')
|
||||
continue;
|
||||
let heroAttrData: CeAttrData = hero.ceAttr[attrName]||new CeAttrData();
|
||||
let globalAttrData: CeAttrData = role.globalCeAttr[attrName];
|
||||
let attrNumber = (heroAttrData.fixUp + (heroAttrData.equipUp||0) + globalAttrData.fixUp) * HERO_CE_RATIO + heroAttrData.base *(HERO_CE_RATIO + heroAttrData.ratioUp + globalAttrData.ratioUp) ;
|
||||
heroCe += attrNumber * getAttrCeRatio(attrName);
|
||||
}
|
||||
incHeroCe += incHeroCe;
|
||||
hero.ce += incHeroCe;
|
||||
pushHeros.push({ hid: hero.hid, ce: hero.ce, incHeroCe });
|
||||
incHeroCe = heroCe - hero.ce;
|
||||
hero.ce = heroCe;
|
||||
role.ce += hero.ce;
|
||||
pushHeros.push({ hid: hero.hid, ce: reduceCe(hero.ce), incHeroCe: reduceCe(incHeroCe) });
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, {ce: hero.ce});
|
||||
}
|
||||
await RoleModel.updateRoleInfo(roleId, {globalCeAttr: role.globalCeAttr, ce: role.ce});
|
||||
|
||||
Reference in New Issue
Block a user