You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.6 KiB
111 lines
3.6 KiB
|
7 months ago
|
import { Player, Attribute } from '@/config';
|
||
|
|
import { deepCopy } from '.';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 计算角色最终属性于技能
|
||
|
|
* @param player 角色
|
||
|
|
* @param rA 转生属性
|
||
|
|
*/
|
||
|
|
export const callPlayerAttribute = (player: Player, rA: any) => {
|
||
|
|
const equips = [player.weapon, player.armor, player.neck, player.ring, player.jewelry, player.pants, player.shoes, player.bracers];
|
||
|
|
const curHp = player.attribute.curHp,
|
||
|
|
hp = player.attribute.hp;
|
||
|
|
const hpP = hp > 0 ? curHp / hp : 1;
|
||
|
|
|
||
|
|
const attribute: Attribute = new Attribute(rA);
|
||
|
|
const entry = new Array();
|
||
|
|
equips.forEach((equip) => {
|
||
|
|
equip && Array.prototype.push.apply(entry, equip.extraEntry);
|
||
|
|
equip && Array.prototype.push.apply(entry, strengthenEntry(equip));
|
||
|
|
});
|
||
|
|
|
||
|
|
entry.forEach((item) => {
|
||
|
|
const key = item.type;
|
||
|
|
if (key == 'dmgPercent') {
|
||
|
|
attribute[key] = Math.round((attribute[key] + 100) * (item.value / 100 + 1) - 100);
|
||
|
|
} else if (key == 'dmgReduc') {
|
||
|
|
attribute[key] = Math.round(100 - (1 - attribute[key] / 100) * (1 - item.value / 100) * 100);
|
||
|
|
} else {
|
||
|
|
attribute[key] += item.value;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
// 暴击率最多100%
|
||
|
|
// if (attribute.crit > 100) {
|
||
|
|
// attribute.crit = 100;
|
||
|
|
// }
|
||
|
|
//计算最终属性
|
||
|
|
attribute.hp = Math.ceil(attribute.hp * (1 + attribute.hpPercent / 100));
|
||
|
|
attribute.curHp = Math.ceil(attribute.hp * hpP);
|
||
|
|
attribute.baseAtk = attribute.atk;
|
||
|
|
attribute.atk = Math.ceil(attribute.baseAtk * (1 + attribute.atkPercent / 100));
|
||
|
|
attribute.def = Math.ceil(attribute.def * (1 + attribute.defPercent / 100));
|
||
|
|
attribute.bloc = Math.ceil(attribute.bloc * (1 + attribute.blocPercent / 100));
|
||
|
|
const arr = ['hp', 'curHp', 'atk', 'def', 'bloc', 'eva'];
|
||
|
|
arr.forEach((key) => {
|
||
|
|
attribute[key] = Math.round(attribute[key]);
|
||
|
|
});
|
||
|
|
//计算秒伤
|
||
|
|
const atk = attribute.atk,
|
||
|
|
crit = attribute.crit / 100,
|
||
|
|
critdmg = attribute.critDmg / 100,
|
||
|
|
dmgPercent = attribute.dmgPercent / 100;
|
||
|
|
attribute.dps = Math.ceil((1 - crit + crit * critdmg) * atk * (1 + dmgPercent));
|
||
|
|
//计算减伤比例
|
||
|
|
attribute.reducPercent = attribute.def / (200 + 1.1111 * attribute.def);
|
||
|
|
// attribute.reducPercent = attribute.def / (200 + 1.1 * attribute.def) + (0.09 * attribute.def) / (attribute.def + 200);
|
||
|
|
// attribute.reducPercent = (0.5 * attribute.def) / (200 + 0.502 * attribute.def);
|
||
|
|
player.attribute = attribute;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 计算装备强化后的基础属性
|
||
|
|
* @param equip 装备
|
||
|
|
* @returns
|
||
|
|
*/
|
||
|
|
const strengthenEntry = (equip) => {
|
||
|
|
const temp = deepCopy(equip.base.entry);
|
||
|
|
temp.forEach((item) => {
|
||
|
|
item.value = strengthenValue(item.value, equip.strengthenLv);
|
||
|
|
});
|
||
|
|
return temp;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 计算基础属性强化后的值
|
||
|
|
* @param value 基础值
|
||
|
|
* @param strengthenLv 强化等级
|
||
|
|
* @returns
|
||
|
|
*/
|
||
|
|
export const strengthenValue = (value, strengthenLv) => {
|
||
|
|
if (strengthenLv <= 0) {
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
const factor = 1.055 ** (strengthenLv ** 1.1);
|
||
|
|
return Math.round(factor * value);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 计算角色转生可获得的转生点数
|
||
|
|
* @param playerAttribute 角色属性
|
||
|
|
* @returns
|
||
|
|
*/
|
||
|
|
export const getPointsOfReborn = (playerAttribute) => {
|
||
|
|
const lv = playerAttribute.lv;
|
||
|
|
let points = lv >= 20 ? Math.floor((lv - 20) ** 1.1 / 2.1) : 0;
|
||
|
|
|
||
|
|
const euqips = [playerAttribute.weapon, playerAttribute.armor, playerAttribute.neck, playerAttribute.ring];
|
||
|
|
euqips.forEach((equip) => {
|
||
|
|
if (!equip) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
const wlv = equip.lv;
|
||
|
|
const elv = equip.enchantlvl || 0;
|
||
|
|
const q = equip.quality.qualityCoefficient;
|
||
|
|
if (wlv >= 20) {
|
||
|
|
points += Math.floor((((wlv - 20) / 10) ** 1.1 * (0.1 * elv ** 1.5 + 1) * q) / 3.5);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
return Math.round(points * 1.2);
|
||
|
|
};
|