import React from 'react'; import PropTypes from 'prop-types'; import TranslatedComponent from './TranslatedComponent'; import cn from 'classnames'; import { Warning } from './SvgIcons'; import * as Calc from '../shipyard/Calculations'; /** * Ship Summary Table / Stats */ export default class ShipSummaryTable extends TranslatedComponent { static propTypes = { ship: PropTypes.object.isRequired, cargo: PropTypes.number.isRequired, fuel: PropTypes.number.isRequired, marker: PropTypes.string.isRequired, pips: PropTypes.object.isRequired }; constructor(props) { super(props) this.didContextChange = this.didContextChange.bind(this); this.state = { shieldColour: 'blue' } } /** * Render the table * @return {React.Component} Summary table */ render() { const { ship, cargo, fuel, pips } = this.props; let { language, tooltip, termtip } = this.context; let translate = language.translate; let u = language.units; let formats = language.formats; let { time, int, round, f1, f2 } = formats; let hide = tooltip.bind(null, null); const shieldGenerator = ship.findInternalByGroup('sg') || ship.findInternalByGroup('psg'); const sgClassNames = cn({ warning: shieldGenerator && !ship.shield, muted: !shieldGenerator }); const sgTooltip = shieldGenerator ? 'TT_SUMMARY_SHIELDS' : 'TT_SUMMARY_SHIELDS_NONFUNCTIONAL'; const timeToDrain = Calc.timeToDrainWep(ship, 4); const canThrust = ship.canThrust(cargo, ship.fuelCapacity); const speedTooltip = canThrust ? 'TT_SUMMARY_SPEED' : 'TT_SUMMARY_SPEED_NONFUNCTIONAL'; const canBoost = ship.canBoost(cargo, ship.fuelCapacity); const boostTooltip = canBoost ? 'TT_SUMMARY_BOOST' : canThrust ? 'TT_SUMMARY_BOOST_NONFUNCTIONAL' : 'TT_SUMMARY_SPEED_NONFUNCTIONAL'; const sgMetrics = Calc.shieldMetrics(ship, pips.sys || 2); const armourMetrics = Calc.armourMetrics(ship); let shieldColour = 'blue'; if (shieldGenerator && shieldGenerator.m.grp === 'psg') { shieldColour = 'green'; } else if (shieldGenerator && shieldGenerator.m.grp === 'bsg') { shieldColour = 'purple'; } this.state = { shieldColour } return
{/* */} {/* */}
{translate('speed')} {translate('boost')} {translate('jump range')} {translate('shield')} {translate('integrity')} {translate('DPS')} {translate('EPS')} {translate('TTD')}{translate('HPS')}{translate('cargo')} {translate('pax')} {translate('fuel')} {translate('mass')} {translate('hrd')} {translate('crew')} {translate('MLF')}
{translate('max')} {translate('unladen')} {translate('laden')} {translate('total unladen')} {translate('total laden')} {translate('hull')} {translate('unladen')} {translate('laden')}
{ canThrust ? {int(ship.calcSpeed(4, ship.fuelCapacity, 0, false))}{u['m/s']} : 0 } { canBoost ? {int(ship.calcSpeed(4, ship.fuelCapacity, 0, true))}{u['m/s']} : 0 } {f2(Calc.jumpRange(ship.unladenMass + ship.standard[2].m.getMaxFuelPerJump(), ship.standard[2].m, ship.standard[2].m.getMaxFuelPerJump()))}{u.LY} {f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity))}{u.LY} {f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity))}{u.LY} {f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity))}{u.LY} {f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity))}{u.LY} {int(ship.shield)}{u.MJ} {int(ship.armour)} {f1(ship.totalDps)} {f1(ship.totalEps)} {timeToDrain === Infinity ? '∞' : time(timeToDrain)}{f1(ship.totalHps)}{round(ship.cargoCapacity)}{u.T} {ship.passengerCapacity} {round(ship.fuelCapacity)}{u.T} {ship.hullMass}{u.T} {int(ship.unladenMass)}{u.T} {int(ship.ladenMass)}{u.T} {int(ship.hardness)} {ship.crew} {ship.masslock}
{translate('shield')} {translate('explres')} {translate('kinres')} {translate('thermres')} {`${translate('absolute')} ${translate('HP')}`} {`${translate('explosive')} ${translate('HP')}`} {`${translate('kinetic')} ${translate('HP')}`} {`${translate('thermal')} ${translate('HP')}`} {translate('recovery')} {translate('recharge')}
{translate(shieldGenerator && shieldGenerator.m.grp || 'No Shield')} {int(ship.shieldExplRes * 100) + '%'} {int(ship.shieldKinRes * 100) + '%'} {int(ship.shieldThermRes * 100) + '%'} {int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.absolute.total : 0)} {int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.explosive.total : 0)} {int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.kinetic.total : 0 )} {int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.thermal.total : 0 )} {sgMetrics && sgMetrics.recover ? formats.time(sgMetrics.recover) : 0} {sgMetrics && sgMetrics.recharge ? formats.time(sgMetrics.recharge) : 0}
{translate('armour')} {translate('explres')} {translate('kinres')} {translate('thermres')} {`${translate('absolute')} ${translate('HP')}`} {`${translate('explosive')} ${translate('HP')}`} {`${translate('kinetic')} ${translate('HP')}`} {`${translate('thermal')} ${translate('HP')}`} {translate('raw module armour')} {translate('internal protection')}
{translate(ship && ship.bulkheads && ship.bulkheads.m && ship.bulkheads.m.name || 'No Armour')} {int(ship.hullExplRes * 100) + '%'} {int(ship.hullKinRes * 100) + '%'} {int(ship.hullThermRes * 100) + '%'} {int(armourMetrics.total / armourMetrics.absolute.total)} {int(armourMetrics.total / armourMetrics.explosive.total)} {int(armourMetrics.total / armourMetrics.kinetic.total)} {int(armourMetrics.total / armourMetrics.thermal.total)} {int(armourMetrics.modulearmour)} {int(armourMetrics.moduleprotection * 100) + '%'}
; } }