装备:一键装备

This commit is contained in:
luying
2021-07-06 14:26:57 +08:00
parent f0852f653a
commit 61df3881cf
7 changed files with 117 additions and 17 deletions

View File

@@ -128,6 +128,17 @@ export class Attribute {
}
}
setByMap( attributes: Map<number, number>, ratio: number = 1 ) {
for(let [id, val] of attributes) {
let attrName = getAtrrNameById(id);
if(ABI_TYPE_MAIN.includes(id)) {
if(attrName in this) this[attrName] = Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO);
} else {
if(attrName in this) this[attrName] = Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO);
}
}
}
private calAttrValue(roleFix: number = 0, roleRatio: number = 0, heroBase: number = 0, heroFix: number = 0, heroRatio: number = 0, heroEquip: number = 0) {
return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio );
}
@@ -209,6 +220,12 @@ export class Attribute {
return ce > 0? ce: 1;
}
// 计算未装备的装备的简易战力公式
public calEquipCe() {
let { hp, atk, def, mdef } = this.getRealMainAttr();
return hp * 1 + atk * 3 + def * 2 + mdef * 2;
}
public calCelAndReduce() {
return Math.floor(this.calCe() / HERO_CE_RATIO / HERO_CE_RATIO);
}