genshin-manager
Version:
<div align="center"> <p> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https://img.shields.io/npm/v/genshin-manager.svg?maxAge=3600" alt="npm version" /></a> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https:
85 lines (84 loc) • 2.59 kB
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatProperty = void 0;
const Client_1 = require("../client/Client");
/**
* Class of stat property
*/
class StatProperty {
/**
* Create a StatProperty
* @param type FightPropType
* @param value Value of the stat
*/
constructor(type, value) {
this.type = type;
const manualTextJson = Client_1.Client._getJsonFromCachedExcelBinOutput('ManualTextMapConfigData', this.type);
this.name =
Client_1.Client._cachedTextMap.get(String(manualTextJson.textMapContentTextMapHash)) || '';
this.isPercent = percentFightPropType.includes(this.type);
this.value = this.cleanUp(value);
}
/**
* Get value text
* @returns Value text
*/
get valueText() {
const fix = this.isPercent ? 1 : 0;
const formattedValue = new Intl.NumberFormat(undefined, {
minimumFractionDigits: fix,
maximumFractionDigits: fix,
}).format(this.multipliedValue === 0 ? 0 : this.multipliedValue);
return `${formattedValue}${this.isPercent ? '%' : ''}`;
}
/**
* Get multiplied value
* @returns Multiplied value
*/
get multipliedValue() {
return this.cleanUp(this.value * (this.isPercent ? 100 : 1));
}
/**
* IEEE 754 rounding method
* @param v Value
* @returns Rounded value
*/
cleanUp(v) {
return Math.round(v * 100000) / 100000 + 0;
}
}
exports.StatProperty = StatProperty;
_a = StatProperty;
(() => {
Client_1.Client._addExcelBinOutputKeyFromClassPrototype(_a.prototype);
})();
const percentFightPropType = [
'FIGHT_PROP_HP_PERCENT',
'FIGHT_PROP_ATTACK_PERCENT',
'FIGHT_PROP_DEFENSE_PERCENT',
'FIGHT_PROP_SPEED_PERCENT',
'FIGHT_PROP_CRITICAL',
'FIGHT_PROP_CRITICAL_HURT',
'FIGHT_PROP_CHARGE_EFFICIENCY',
'FIGHT_PROP_HEAL_ADD',
'FIGHT_PROP_HEALED_ADD',
'FIGHT_PROP_PHYSICAL_SUB_HURT',
'FIGHT_PROP_PHYSICAL_ADD_HURT',
'FIGHT_PROP_FIRE_ADD_HURT',
'FIGHT_PROP_ELEC_ADD_HURT',
'FIGHT_PROP_WATER_ADD_HURT',
'FIGHT_PROP_GRASS_ADD_HURT',
'FIGHT_PROP_WIND_ADD_HURT',
'FIGHT_PROP_ROCK_ADD_HURT',
'FIGHT_PROP_ICE_ADD_HURT',
'FIGHT_PROP_FIRE_SUB_HURT',
'FIGHT_PROP_ELEC_SUB_HURT',
'FIGHT_PROP_WATER_SUB_HURT',
'FIGHT_PROP_GRASS_SUB_HURT',
'FIGHT_PROP_WIND_SUB_HURT',
'FIGHT_PROP_ROCK_SUB_HURT',
'FIGHT_PROP_ICE_SUB_HURT',
'FIGHT_PROP_SKILL_CD_MINUS_RATIO',
'FIGHT_PROP_SHIELD_COST_MINUS_RATIO',
];