UNPKG

borderlands2

Version:

Borderlands 2 weapon damage and DPS calculation library

111 lines 4.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var console_table_printer_1 = require("console-table-printer"); var target_type_1 = require("../../enemy/value_object/target_type"); var damage_service_1 = require("../../weapon/service/damage_service"); var TablePrinterService = /** @class */ (function () { function TablePrinterService(context, weapons) { this.context = context; this.weapons = weapons; } TablePrinterService.prototype.printWeaponSummary = function () { var tbl = new console_table_printer_1.Table(); var weaponSummaries = this.getWeaponSummaries(); tbl.addRows(weaponSummaries); tbl.printTable(); }; TablePrinterService.prototype.printCategoryMaximums = function () { var tbl = new console_table_printer_1.Table(); var weaponSummaries = this.getWeaponSummaries(); var stats = [{ name: 'Single Shot', field: 'singleShot' }, { name: 'DPS', field: 'dps' }, { name: 'Crit Shot', field: 'critShot' }, { name: 'Crit DPS', field: 'critDps' }, { name: 'Flesh Shot', field: 'fleshShot' }, { name: 'Flesh DPS', field: 'fleshDps' }, { name: 'Flesh Crit Shot', field: 'fleshCritShot' }, { name: 'Flesh Crit DPS', field: 'fleshCritDps' }, { name: 'Armor Shot', field: 'armorShot' }, { name: 'Armor DPS', field: 'armorDps' }, { name: 'Armor Crit Shot', field: 'armorCritShot' }, { name: 'Armor Crit DPS', field: 'armorCritDps' }, { name: 'Shield Shot', field: 'shieldShot' }, { name: 'Shield DPS', field: 'shieldDps' }, { name: 'Shield Crit Shot', field: 'shieldCritShot' }, { name: 'Shield Crit DPS', field: 'shieldCritDps' }]; stats.forEach(function (stat) { var max = weaponSummaries.sort(function (a, b) { return b[stat.field] - a[stat.field]; })[0]; tbl.addRow({ stat: stat.name, name: max.name, value: max[stat.field] }); }); tbl.printTable(); }; TablePrinterService.prototype.getWeaponSummaries = function () { var _this = this; return this.weapons.map(function (weapon) { var ds = new damage_service_1.DamageService(weapon, _this.context); return { name: weapon.name, type: weapon.type, //singleShot: Math.round(ds.getDamage()), //dps: Math.round(ds.getDps()), //critShot: Math.round(ds.getCritDamage()), //critDps: Math.round(ds.getCritDps()), fleshShot: Math.round(ds.getDamage(target_type_1.TargetType.Flesh)), fleshDps: Math.round(ds.getTargetTypeDps(target_type_1.TargetType.Flesh)), fleshCritShot: Math.round(ds.getCritDamage(target_type_1.TargetType.Flesh)), fleshCritDps: Math.round(ds.getTargetTypeCritDps(target_type_1.TargetType.Flesh)), armorShot: Math.round(ds.getDamage(target_type_1.TargetType.Armor)), armorDps: Math.round(ds.getTargetTypeDps(target_type_1.TargetType.Armor)), armorCritShot: Math.round(ds.getCritDamage(target_type_1.TargetType.Armor)), armorCritDps: Math.round(ds.getTargetTypeCritDps(target_type_1.TargetType.Armor)), shieldShot: Math.round(ds.getDamage(target_type_1.TargetType.Shield)), shieldDps: Math.round(ds.getTargetTypeDps(target_type_1.TargetType.Shield)), shieldCritShot: Math.round(ds.getCritDamage(target_type_1.TargetType.Shield)), shieldCritDps: Math.round(ds.getTargetTypeCritDps(target_type_1.TargetType.Shield)), }; }); }; TablePrinterService.prototype.formatDps = function (damageService, targetType) { var dps = damageService.getTargetTypeDps(targetType); var elementalDps = damageService.getElementalDps(targetType); if (elementalDps) return dps + " (" + elementalDps + ")"; return "" + dps; }; return TablePrinterService; }()); exports.TablePrinterService = TablePrinterService; //# sourceMappingURL=table_printer.js.map