战力
This commit is contained in:
@@ -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