import React from 'react'; import cn from 'classnames'; import Slot from './Slot'; import Persist from '../stores/Persist'; import { DamageAbsolute, DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, ListModifications, Modified } from './SvgIcons'; import { Modifications } from 'coriolis-data/dist'; import { stopCtxPropagation } from '../utils/UtilityFunctions'; import { blueprintTooltip } from '../utils/BlueprintFunctions'; /** * 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 {Boolean} enabled Slot enabled * @param {Function} translate Translate function * @param {Object} formats Localized Formats map * @param {Object} u Localized Units Map * @return {React.Component} Slot contents */ _getSlotDetails(m, enabled, 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 >= 0) { modTT += ', ' + translate(m.blueprint.special.name); } modTT = (
{modTT}
{blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], null, m.grp, m)}
); } const className = cn('details', enabled ? '' : 'disabled'); 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 ? : ''} {m.getDamageDist() && m.getDamageDist().A ? : ''} {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.getSDps())}) : null}
: null} {m.getDamage() ?
{translate('shotdmg')}: {formats.round1(m.getDamage())}
: null} {m.getEps() ?
{translate('EPS')}: {formats.round1(m.getEps())}{u.MW} {m.getClip() ? ({formats.round1(m.getEps() * m.getSustainedFactor())}{u.MW}) : null}
: null} {m.getHps() ?
{translate('HPS')}: {formats.round1(m.getHps())} {m.getClip() ? ({formats.round1(m.getHps() * m.getSustainedFactor())}) : 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', m.grp)} {formats.f1(m.getRange() / 1000)}{u.km}
: null} {m.getScanTime() ?
{translate('scantime')} {formats.f1(m.getScanTime())}{u.s}
: null} {m.getFalloff() ?
{translate('falloff')} {formats.round(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.getReload() ?
{translate('wep_reload')}: {formats.round(m.getReload())}{u.s}
: 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} {m.getScanAngle() ?
{translate('scan angle')}: {formats.f2(m.getScanAngle())}°
: null} {m.getScanRange() ?
{translate('scan range')}: {formats.int(m.getScanRange())}{u.m}
: null} {m.getMaxAngle() ?
{translate('max angle')}: {formats.f2(m.getMaxAngle())}°
: 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.getIntegrity() ?
{translate('integrity')}: {formats.int(m.getIntegrity())}
: null} {m && validMods.length > 0 ?
this.modButton = modButton}>
: null}
; } else { return
{translate('empty')}
; } } }