import React from 'react'; import Slot from './Slot'; import Persist from '../stores/Persist'; import { DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, ListModifications, Modified } from './SvgIcons'; import { Modifications } from 'coriolis-data/dist'; import { stopCtxPropagation } from '../utils/UtilityFunctions'; /** * Hardpoint / Utility Slot */ export default class HardpointSlot extends Slot { /** * Get the CSS class name for the slot. * @return {string} CSS Class name */ _getClassNames() { return this.props.maxClass > 0 ? 'hardpoint' : null; } /** * Get the label for the slot * @param {Function} translate Translate function * @return {string} Label */ _getMaxClassLabel(translate) { return translate(['U','S','M','L','H'][this.props.maxClass]); } /** * Generate the slot contents * @param {Object} m Mounted Module * @param {Function} translate Translate function * @param {Object} formats Localized Formats map * @param {Object} u Localized Units Map * @return {React.Component} Slot contents */ _getSlotDetails(m, translate, formats, u) { if (m) { let classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`; let { drag, drop } = this.props; let { termtip, tooltip } = this.context; let validMods = Modifications.modules[m.grp].modifications || []; let showModuleResistances = Persist.showModuleResistances(); // Modifications tooltip shows blueprint and grade, if available let modTT = translate('modified'); if (m && m.blueprint && m.blueprint.name) { modTT = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade; if (m.blueprint.special && m.blueprint.special.id) { modTT += ', ' + translate(m.blueprint.special.name); } } return
{m.mount && m.mount == 'F' ? : ''} {m.mount && m.mount == 'G' ? : ''} {m.mount && m.mount == 'T' ? : ''} {m.getDamageDist() && m.getDamageDist().K ? : ''} {m.getDamageDist() && m.getDamageDist().T ? : ''} {m.getDamageDist() && m.getDamageDist().E ? : ''} {classRating} {translate(m.name || m.grp)}{ m.mods && Object.keys(m.mods).length > 0 ? : null }
{formats.round(m.getMass())}{u.T}
{ m.getDps() ?
{translate('DPS')}: {formats.round1(m.getDps())} { m.getClip() ? ({formats.round1((m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload())) }) : null }
: null } { m.getEps() ?
{translate('EPS')}: {formats.round1(m.getEps())}{u.MW} { m.getClip() ? ({formats.round1((m.getClip() * m.getEps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload())) }{u.MW}) : null }
: null } { m.getHps() ?
{translate('HPS')}: {formats.round1(m.getHps())} { m.getClip() ? ({formats.round1((m.getClip() * m.getHps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload())) }) : null }
: null } { m.getDps() && m.getEps() ?
{translate('DPE')}: {formats.f1(m.getDps() / m.getEps())}
: null } { m.getRoF() ?
{translate('ROF')}: {formats.f1(m.getRoF())}{u.ps}
: null } { m.getRange() ?
{translate('range')} {formats.f1(m.getRange() / 1000)}{u.km}
: null } { m.getFalloff() ?
{translate('falloff')} {formats.f1(m.getFalloff() / 1000)}{u.km}
: null } { m.getShieldBoost() ?
+{formats.pct1(m.getShieldBoost())}
: null } { m.getAmmo() ?
{translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}
: null } { m.getShotSpeed() ?
{translate('shotspeed')}: {formats.int(m.getShotSpeed())}{u.mps}
: null } { m.getPiercing() ?
{translate('piercing')}: {formats.int(m.getPiercing())}
: null } { m.getJitter() ?
{translate('jitter')}: {formats.f2(m.getJitter())}°
: null } { showModuleResistances && m.getExplosiveResistance() ?
{translate('explres')}: {formats.pct(m.getExplosiveResistance())}
: null } { showModuleResistances && m.getKineticResistance() ?
{translate('kinres')}: {formats.pct(m.getKineticResistance())}
: null } { showModuleResistances && m.getThermalResistance() ?
{translate('thermres')}: {formats.pct(m.getThermalResistance())}
: null } { m && validMods.length > 0 ?
: null }
; } else { return
{translate('empty')}
; } } }