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 }; /** * The ShipSummaryTable constructor * @param {Object} props The props */ 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 canJump = ship.getSlotStatus(ship.standard[2]) == 3; const sgMetrics = Calc.shieldMetrics(ship, pips.sys); const shipBoost = canBoost ? Calc.calcBoost(ship) : 'No Boost'; const restingHeat = Math.sqrt(((ship.standard[0].m.pgen * ship.standard[0].m.eff) / ship.heatCapacity) / 0.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('boost interval')} {translate('resting heat (Beta)')}
{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 } { canJump ? { f2(Calc.jumpRange(ship.unladenMass + ship.standard[2].m.getMaxFuelPerJump(), ship.standard[2].m, ship.standard[2].m.getMaxFuelPerJump(), ship))}{u.LY} : 0 } { canJump ? {f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY} : 0 } { canJump ? {f2(Calc.jumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY} : 0 } { canJump ? {f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY} : 0 } { canJump ? {f2(Calc.totalJumpRange(ship.unladenMass + ship.fuelCapacity + ship.cargoCapacity, ship.standard[2].m, ship.fuelCapacity, ship))}{u.LY} : 0 } {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} {shipBoost !== 'No Boost' ? formats.time(shipBoost) : 'No Boost'} {formats.pct(restingHeat)}
{translate('shield')} {translate('resistance')} {`${translate('HP')}`} {translate('recovery')} {translate('recharge')}
{`${translate('explosive')}`} {`${translate('kinetic')}`} {`${translate('thermal')}`} {`${translate('absolute')}`} {`${translate('explosive')}`} {`${translate('kinetic')}`} {`${translate('thermal')}`}
{translate(shieldGenerator && shieldGenerator.m.grp || 'No Shield')} {formats.pct1(ship.shieldExplRes)} {formats.pct1(ship.shieldKinRes)} {formats.pct1(ship.shieldThermRes)} {int(ship && sgMetrics.summary > 0 ? sgMetrics.summary : 0)}{u.MJ} {int(ship && sgMetrics.summary > 0 ? sgMetrics.summary / sgMetrics.explosive.base : 0)}{u.MJ} {int(ship && sgMetrics.summary ? sgMetrics.summary / sgMetrics.kinetic.base : 0)}{u.MJ} {int(ship && sgMetrics.summary ? sgMetrics.summary / sgMetrics.thermal.base : 0)}{u.MJ} {sgMetrics && sgMetrics.recover === Math.Inf ? translate('Never') : formats.time(sgMetrics.recover)} {sgMetrics && sgMetrics.recharge === Math.Inf ? translate('Never') : formats.time(sgMetrics.recharge)}
{translate('armour')} {translate('resistance')} {`${translate('HP')}`} {translate('raw module armour')} {translate('internal protection')}
{`${translate('explosive')}`} {`${translate('kinetic')}`} {`${translate('thermal')}`} {`${translate('caustic')}`} {`${translate('absolute')}`} {`${translate('explosive')}`} {`${translate('kinetic')}`} {`${translate('thermal')}`} {`${translate('caustic')}`}
{translate(ship && ship.bulkheads && ship.bulkheads.m && ship.bulkheads.m.name || 'No Armour')} {formats.pct1(ship.hullExplRes)} {formats.pct1(ship.hullKinRes)} {formats.pct1(ship.hullThermRes)} {formats.pct1(ship.hullCausRes)} {int(armourMetrics.total)} {int(armourMetrics.total / armourMetrics.explosive.total)} {int(armourMetrics.total/ armourMetrics.kinetic.total)} {int(armourMetrics.total / armourMetrics.thermal.total)} {int(armourMetrics.total/ armourMetrics.caustic.total)} {int(armourMetrics.modulearmour)} {int(armourMetrics.moduleprotection * 100) + '%'}
; } }