战力:修改战力公式
This commit is contained in:
@@ -154,7 +154,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
|||||||
if(h) {
|
if(h) {
|
||||||
let { star, lv, attr: heroAttrs, ce } = h;
|
let { star, lv, attr: heroAttrs, ce } = h;
|
||||||
let dicHero = gameData.hero.get(hero.actorId);
|
let dicHero = gameData.hero.get(hero.actorId);
|
||||||
let { attribute } = getPlayerAttribute(heroAttrs, roleAttrs);
|
let { attribute } = getPlayerAttribute(lv, heroAttrs, roleAttrs);
|
||||||
let heroInfo = {
|
let heroInfo = {
|
||||||
actorId: hero.actorId,
|
actorId: hero.actorId,
|
||||||
actorName: dicHero.name,
|
actorName: dicHero.name,
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, mapWarJson: DicWarJ
|
|||||||
let heroInfo = new PvpHeroInfo();
|
let heroInfo = new PvpHeroInfo();
|
||||||
heroInfo.setHeroInfo(dbHero);
|
heroInfo.setHeroInfo(dbHero);
|
||||||
heroInfo.setOutIndex(h.order);
|
heroInfo.setOutIndex(h.order);
|
||||||
let { attribute, ce } = getPlayerAttribute(dbHero.attr, role.attr);
|
let { attribute, ce } = getPlayerAttribute(dbHero.lv, dbHero.attr, role.attr);
|
||||||
heroInfo.setAttribute(attribute);
|
heroInfo.setAttribute(attribute);
|
||||||
let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, ce);
|
let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, ce);
|
||||||
heroes.push(enemy);
|
heroes.push(enemy);
|
||||||
@@ -525,8 +525,9 @@ export function getRobotAttribute(attribute: { id: number, val: number }[], ce:
|
|||||||
* @param ceAttr hero表的ceAttr
|
* @param ceAttr hero表的ceAttr
|
||||||
* @param globalCeAttr role表中的globalCeAttr
|
* @param globalCeAttr role表中的globalCeAttr
|
||||||
*/
|
*/
|
||||||
export function getPlayerAttribute(heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) {
|
export function getPlayerAttribute(lv: number, heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) {
|
||||||
let newAttribute = new AttributeCal();
|
let newAttribute = new AttributeCal();
|
||||||
|
newAttribute.setLv(lv);
|
||||||
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
||||||
let attribute = newAttribute.getReduceAttributesToString();
|
let attribute = newAttribute.getReduceAttributesToString();
|
||||||
let ce = newAttribute.calCelAndReduce();
|
let ce = newAttribute.calCelAndReduce();
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ export class CeAttrDataRole {
|
|||||||
export class AttributeCal {
|
export class AttributeCal {
|
||||||
attrs: Map<number, number> = new Map<number, number>();
|
attrs: Map<number, number> = new Map<number, number>();
|
||||||
ce?: number = 0;
|
ce?: number = 0;
|
||||||
|
lv: number = 1;
|
||||||
|
|
||||||
|
public setLv(lv: number) {
|
||||||
|
this.lv = lv;
|
||||||
|
}
|
||||||
|
|
||||||
public setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) {
|
public setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) {
|
||||||
for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) {
|
for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) {
|
||||||
@@ -61,7 +66,7 @@ export class AttributeCal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) {
|
public setByWarJson(attributes: {id: number, val: number}[], ratio: number = 1) {
|
||||||
for(let {id, val} of attributes) {
|
for(let {id, val} of attributes) {
|
||||||
if(ABI_TYPE_MAIN.includes(id)) {
|
if(ABI_TYPE_MAIN.includes(id)) {
|
||||||
this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO));
|
this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO));
|
||||||
@@ -133,7 +138,11 @@ export class AttributeCal {
|
|||||||
public calCe() {
|
public calCe() {
|
||||||
let ce = gameData.ceRatio.reduce((pre, cur) => {
|
let ce = gameData.ceRatio.reduce((pre, cur) => {
|
||||||
let { type, val } = cur;
|
let { type, val } = cur;
|
||||||
return pre + val * (this.attrs.get(type)|| 0)
|
if(ABI_TYPE_MAIN.includes(type)) {
|
||||||
|
return pre + val * (this.attrs.get(type)|| 0)
|
||||||
|
} else {
|
||||||
|
return pre + val * (this.attrs.get(type)|| 0) * this.lv
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
return Math.floor(ce);
|
return Math.floor(ce);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export async function calPlayerCeAndSave(type: number, roleId: string, originHer
|
|||||||
let heroAttrs = calPlayerCe(originHero, update, type, args); // 根据操作计算attr的增加
|
let heroAttrs = calPlayerCe(originHero, update, type, args); // 根据操作计算attr的增加
|
||||||
|
|
||||||
let newAttr = new AttributeCal();
|
let newAttr = new AttributeCal();
|
||||||
|
newAttr.setLv(update.lv||originHero.lv);
|
||||||
newAttr.setByDbData(roleAttrs, heroAttrs);
|
newAttr.setByDbData(roleAttrs, heroAttrs);
|
||||||
let heroCe = newAttr.calCe(); // 计算最终战力
|
let heroCe = newAttr.calCe(); // 计算最终战力
|
||||||
let incCe = heroCe - originHero.ce;
|
let incCe = heroCe - originHero.ce;
|
||||||
@@ -69,8 +70,9 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU
|
|||||||
let roleCe = 0; // 总战力加成
|
let roleCe = 0; // 总战力加成
|
||||||
let allIncCe = 0;
|
let allIncCe = 0;
|
||||||
for (let hero of heros) {
|
for (let hero of heros) {
|
||||||
let { attr: heroAttrs } = hero;
|
let { attr: heroAttrs, lv } = hero;
|
||||||
let newAttr = new AttributeCal();
|
let newAttr = new AttributeCal();
|
||||||
|
newAttr.setLv(lv);
|
||||||
newAttr.setByDbData(roleAttrs, heroAttrs);
|
newAttr.setByDbData(roleAttrs, heroAttrs);
|
||||||
let heroCe = newAttr.calCe(); // 计算最终战力
|
let heroCe = newAttr.calCe(); // 计算最终战力
|
||||||
if(heroCe != hero.ce) {
|
if(heroCe != hero.ce) {
|
||||||
|
|||||||
Reference in New Issue
Block a user