diff --git a/src/app/components/Defence.jsx b/src/app/components/Defence.jsx index 03c3a3be..7c9c0dfe 100644 --- a/src/app/components/Defence.jsx +++ b/src/app/components/Defence.jsx @@ -29,8 +29,8 @@ export default class Defence extends TranslatedComponent { constructor(props) { super(props); - const { shield, armour, damagetaken } = this._calcMetrics(props.ship, props.opponent, props.sys); - this.state = { shield, armour, damagetaken }; + const { shield, armour, shielddamage } = this._calcMetrics(props.ship, props.opponent, props.sys); + this.state = { shield, armour, shielddamage }; } /** @@ -40,8 +40,8 @@ export default class Defence extends TranslatedComponent { */ componentWillReceiveProps(nextProps) { if (this.props.marker != nextProps.marker || this.props.sys != nextProps.sys) { - const { shield, armour, damagetaken } = this._calcMetrics(nextProps.ship, nextProps.opponent, nextProps.sys); - this.setState({ shield, armour, damagetaken }); + const { shield, armour, shielddamage } = this._calcMetrics(nextProps.ship, nextProps.opponent, nextProps.sys); + this.setState({ shield, armour, shielddamage }); return true; } } @@ -56,6 +56,16 @@ export default class Defence extends TranslatedComponent { _calcMetrics(ship, opponent, sys) { const sysResistance = this._calcSysResistance(sys); + // Obtain the opponent's sustained DPS for later damage calculations + // const opponentSDps = Calc.sustainedDps(opponent, range); + const opponentSDps = { + absolute: 62.1, + explosive: 0, + kinetic: 7.4, + thermal: 7.4 + }; + + let shielddamage = {}; let shield = {}; const shieldGeneratorSlot = ship.findInternalByGroup('sg'); if (shieldGeneratorSlot && shieldGeneratorSlot.enabled && shieldGeneratorSlot.m) { @@ -122,11 +132,17 @@ export default class Defence extends TranslatedComponent { sys: (1 - sysResistance), total: (1 - shieldGenerator.getThermalResistance()) * boosterThermDmg * (1 - sysResistance) }; + + shielddamage.absolutesdps = opponentSDps.absolute *= shield.absolute.total; + shielddamage.explosivesdps = opponentSDps.explosive *= shield.explosive.total; + shielddamage.kineticsdps = opponentSDps.kinetic *= shield.kinetic.total; + shielddamage.thermalsdps = opponentSDps.thermal *= shield.thermal.total; + shielddamage.totalsdps = shielddamage.absolutesdps + shielddamage.explosivesdps + shielddamage.kineticsdps + shielddamage.thermalsdps; } // Armour from bulkheads const armourBulkheads = ship.baseArmour + (ship.baseArmour * ship.bulkheads.m.getHullBoost()); - let armourReinforcement = 0 + let armourReinforcement = 0; let modulearmour = 0; let moduleprotection = 1; @@ -193,31 +209,7 @@ export default class Defence extends TranslatedComponent { total: (1 - ship.bulkheads.m.getThermalResistance()) * hullThermDmg }; - // Use the SDPS for each weapon type of the opponent to work out how long the shields and armour will last - // const opponentSDps = Calc.sustainedDps(opponent, range); - const opponentSDps = { - absolute: 62.1, - explosive: 0, - kinetic: 7.4, - thermal: 7.4 - }; - - // Modify according to resistances to see how much damage we actually take - //opponentSDps.absolute *= shield.absolute.total; - //opponentSDps.explosive *= shield.explosive.total; - //opponentSDps.kinetic *= shield.kinetic.total; - //opponentSDps.thermal *= shield.thermal.total; - opponentSDps.total = opponentSDps.absolute + opponentSDps.explosive + opponentSDps.kinetic + opponentSDps.thermal; - - const damagetaken = { - absolutesdps: opponentSDps.absolute, - explosivesdps: opponentSDps.explosive, - kineticsdps: opponentSDps.kinetic, - thermalsdps: opponentSDps.thermal, - tts: (shield.total + ship.shieldCells) / opponentSDps.total, - }; - - return { shield, armour, damagetaken }; + return { shield, armour, shielddamage }; } /** @@ -237,7 +229,7 @@ export default class Defence extends TranslatedComponent { const { ship, sys } = this.props; const { language, tooltip, termtip } = this.context; const { formats, translate, units } = language; - const { shield, armour, damagetaken } = this.state; + const { shield, armour, shielddamage } = this.state; const shieldSourcesData = []; const effectiveShieldData = []; @@ -321,58 +313,7 @@ export default class Defence extends TranslatedComponent {

{shieldTooltipDetails}

)} onMouseOut={tooltip.bind(null, null)} className='summary'>{translate('shields')}: {formats.int(shield.total)}{units.MJ} - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{translate('damage type')} -   - -   - -   - -   -
{translate('damage taken')} - {shieldAbsoluteTooltipDetails})} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.absolute.total)} - - {shieldExplosiveTooltipDetails})} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.explosive.total)} - - {shieldKineticTooltipDetails})} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.kinetic.total)} - - {shieldThermalTooltipDetails})} onMouseOut={tooltip.bind(null, null)}>{formats.pct1(shield.thermal.total)} -
{translate('effective shield')} - {formats.int(effectiveAbsoluteShield)}{units.MJ} - - {formats.int(effectiveExplosiveShield)}{units.MJ} - - {formats.int(effectiveKineticShield)}{units.MJ} - - {formats.int(effectiveThermalShield)}{units.MJ} -
{translate('shields will hold against opponent for')} {formats.time(damagetaken.tts)}
+

{translate('PHRASE_TIME_TO_LOSE_SHIELDS')} {formats.time(shield.total / shielddamage.totalsdps)}

{translate('shield sources')}

diff --git a/src/app/components/PieChart.jsx b/src/app/components/PieChart.jsx index c9199641..0af72456 100644 --- a/src/app/components/PieChart.jsx +++ b/src/app/components/PieChart.jsx @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import Measure from 'react-measure'; import * as d3 from 'd3'; -const CORIOLIS_COLOURS = [ '#FF8C0D', '#1FB0FF', '#519032', '#D5420D' ]; +const CORIOLIS_COLOURS = ['#FF8C0D', '#1FB0FF', '#519032', '#D5420D']; const LABEL_COLOUR = '#FFFFFF'; /** @@ -28,12 +28,15 @@ export default class PieChart extends Component { width: 100, height: 100 } - } + }; } /** * Generate a slice of the pie chart + * @param {Object} d the data for this slice + * @param {number} i the index of this slice + * @returns {Object} the SVG for the slice */ sliceGenerator(d, i) { const { width, height } = this.state.dimensions; @@ -49,24 +52,28 @@ export default class PieChart extends Component { return ( - + {d.value} - {d.data.label} + {d.data.label} ); } + /** + * Render the component + * @returns {object} Markup + */ render() { const { width, height } = this.state.dimensions; const pie = this.pie(this.props.data), - translate = `translate(${width / 2}, ${width * 0.4})`; + translate = `translate(${width / 2}, ${width * 0.4})`; this.arc.outerRadius(width * 0.4); return ( - { this.setState({dimensions}) }}> + { this.setState({ dimensions }); }}>
- + {pie.map((d, i) => this.sliceGenerator(d, i))} diff --git a/src/app/components/Pips.jsx b/src/app/components/Pips.jsx index d5446594..2bec028e 100644 --- a/src/app/components/Pips.jsx +++ b/src/app/components/Pips.jsx @@ -111,7 +111,7 @@ export default class Pips extends TranslatedComponent { if (this.props.ship.canBoost()) { e.preventDefault(); this._toggleBoost(); - } + } break; case 37: // Left arrow == increase SYS e.preventDefault(); @@ -345,7 +345,7 @@ export default class Pips extends TranslatedComponent {
- { ship.canBoost() ? + { ship.canBoost() ? diff --git a/src/app/components/VerticalBarChart.jsx b/src/app/components/VerticalBarChart.jsx index 45183cf5..9bbab161 100644 --- a/src/app/components/VerticalBarChart.jsx +++ b/src/app/components/VerticalBarChart.jsx @@ -2,10 +2,10 @@ import React, { Component } from 'react'; import Measure from 'react-measure'; import * as d3 from 'd3'; -const CORIOLIS_COLOURS = [ '#FF8C0D', '#1FB0FF', '#519032', '#D5420D' ]; +const CORIOLIS_COLOURS = ['#FF8C0D', '#1FB0FF', '#519032', '#D5420D']; const LABEL_COLOUR = '#FFFFFF'; -var margin = {top: 10, right: 0, bottom: 0, left: 55}; +const margin = { top: 10, right: 0, bottom: 0, left: 55 }; const ASPECT = 1; @@ -36,10 +36,14 @@ export default class VerticalBarChart extends Component { width: 300, height: 300 } - } + }; } - _renderGraph(props){ + /** + * Render the graph + * @param {Object} props React Component properties + */ + _renderGraph(props) { let { width, height } = this.state.dimensions; width = width - margin.left - margin.right, @@ -73,7 +77,7 @@ export default class VerticalBarChart extends Component { svg.append('g') .attr('class', 'y axis') .call(this.yAxis) - .attr('fill', CORIOLIS_COLOURS[0]) + .attr('fill', CORIOLIS_COLOURS[0]); svg.selectAll('rect.bar') .data(props.data) @@ -99,8 +103,10 @@ export default class VerticalBarChart extends Component { .text(d => d.value); } - - + /** + * Render the component + * @returns {object} Markup + */ render() { const { width } = this.state.dimensions; @@ -109,7 +115,7 @@ export default class VerticalBarChart extends Component { this._renderGraph(this.props); return ( - { this.setState({dimensions}) }}> + { this.setState({ dimensions }); }}>
{ this.x ? this.svg = ref} width={width} height={width * ASPECT} transform={translate}> diff --git a/src/app/i18n/en.js b/src/app/i18n/en.js index 4b338ae4..7cce1ea2 100644 --- a/src/app/i18n/en.js +++ b/src/app/i18n/en.js @@ -39,6 +39,7 @@ export const terms = { PHRASE_NO_SPECIAL: 'No experimental effect', PHRASE_SHOPPING_LIST: 'Stations that sell this build', PHRASE_TOTAL_EFFECTIVE_SHIELD: 'Total amount of damage that can be taken from each damage type, if using all shield cells', + PHRASE_TIME_TO_LOSE_SHIELDS: 'Shields will hold for', HELP_MODIFICATIONS_MENU: 'Click on a number to enter a new value, or drag along the bar for small changes', @@ -204,6 +205,21 @@ export const terms = { optmul_sg: 'Optimal strength', maxmul_sg: 'Minimum strength', + // Damage types + absolute: 'Absolute', + explosive: 'Explosive', + kinetic: 'Kinetia', + thermal: 'Thermal', + + // Shield sources + generator: 'Generator', + boosters: 'Boosters', + cells: 'Cells', + + // Armour sources + bulkheads: 'Bulkheads', + reinforcement: 'Reinforcement', + // Help text HELP_TEXT: `

Introduction

diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 8bb0b84b..9a591fdc 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -1251,7 +1251,6 @@ export default class Ship { * @return {this} The ship instance (for chaining operations) */ updateMovement() { -console.log('updateMovement()'); this.speeds = Calc.speed(this.unladenMass + this.fuelCapacity, this.speed, this.standard[1].m, this.pipSpeed); this.topSpeed = this.speeds[4]; this.topBoost = this.canBoost() ? this.speeds[4] * this.boost / this.speed : 0;