战力:修改战力公式
This commit is contained in:
@@ -38,6 +38,11 @@ export class CeAttrDataRole {
|
||||
export class AttributeCal {
|
||||
attrs: Map<number, number> = new Map<number, number>();
|
||||
ce?: number = 0;
|
||||
lv: number = 1;
|
||||
|
||||
public setLv(lv: number) {
|
||||
this.lv = lv;
|
||||
}
|
||||
|
||||
public setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) {
|
||||
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) {
|
||||
if(ABI_TYPE_MAIN.includes(id)) {
|
||||
this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO));
|
||||
@@ -133,7 +138,11 @@ export class AttributeCal {
|
||||
public calCe() {
|
||||
let ce = gameData.ceRatio.reduce((pre, 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);
|
||||
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 newAttr = new AttributeCal();
|
||||
newAttr.setLv(update.lv||originHero.lv);
|
||||
newAttr.setByDbData(roleAttrs, heroAttrs);
|
||||
let heroCe = newAttr.calCe(); // 计算最终战力
|
||||
let incCe = heroCe - originHero.ce;
|
||||
@@ -69,8 +70,9 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU
|
||||
let roleCe = 0; // 总战力加成
|
||||
let allIncCe = 0;
|
||||
for (let hero of heros) {
|
||||
let { attr: heroAttrs } = hero;
|
||||
let { attr: heroAttrs, lv } = hero;
|
||||
let newAttr = new AttributeCal();
|
||||
newAttr.setLv(lv);
|
||||
newAttr.setByDbData(roleAttrs, heroAttrs);
|
||||
let heroCe = newAttr.calCe(); // 计算最终战力
|
||||
if(heroCe != hero.ce) {
|
||||
|
||||
Reference in New Issue
Block a user