From 87e903e473e9320928e41f91ca6b1250447b8e32 Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Fri, 11 Nov 2016 00:15:49 +0000 Subject: [PATCH] Add 'Offence summary' and 'Defence summary' components --- ChangeLog.md | 2 + src/app/components/DefenceSummary.jsx | 82 ++++++++------------ src/app/components/OffenceSummary.jsx | 106 +++++++++----------------- src/app/i18n/en.js | 7 +- src/app/shipyard/Module.js | 16 ++++ src/app/shipyard/Ship.js | 28 ++++++- src/less/icons.less | 6 ++ 7 files changed, 123 insertions(+), 124 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7848244e..db3c3fef 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -12,3 +12,5 @@ * Ensure that retrofit tab only shows changed modules * Fix import and export of ships with modifications, bump schema version to 4 * Enable boost display even if power distributor is disabled + * Calculate breakdown of ship offensive and defensive stats + * Add 'Offence summary' and 'Defence summary' components diff --git a/src/app/components/DefenceSummary.jsx b/src/app/components/DefenceSummary.jsx index 909ce89f..2c77f947 100644 --- a/src/app/components/DefenceSummary.jsx +++ b/src/app/components/DefenceSummary.jsx @@ -1,6 +1,7 @@ import React from 'react'; import cn from 'classnames'; import TranslatedComponent from './TranslatedComponent'; +import { DamageKinetic, DamageThermal, DamageExplosive } from './SvgIcons'; /** * Defence summary @@ -28,62 +29,41 @@ export default class DefenceSummary extends TranslatedComponent { let { formats, translate, units } = language; let hide = tooltip.bind(null, null); - let sgClassNames = cn({ muted: !ship.findInternalByGroup('sg') }); - return ( -
-

{translate('defence summary')}

-
- - - - - - - - - - - - - - { ship.shield ? - - - - - - : null } - - - - - - - -
{translate('damage to')}{translate('damage from')}
{translate('explosive')}{translate('kinetic')}{translate('thermal')}
{translate('shields')}{ship.shieldExplRes ? formats.pct(ship.shieldExplRes) : '-'}{ship.shieldKinRes ? formats.pct(ship.shieldKinRes) : '-'}{ship.shieldThermRes ? formats.pct(ship.shieldThermRes) : '-'}
{translate('hull')}{formats.pct(ship.hullExplRes)}{formats.pct(ship.hullKinRes)}{formats.pct(ship.hullThermRes)}
-
- { ship.shield ? - - - - - - - - - - - + +

{translate('defence summary')}

+
{translate('shields')}
{translate('strength')}{translate('recovery')}{translate('recovery')}
+ {ship.shield ? - - - + + : null } + {ship.shield ? + + + + + + : null } + + { ship.shield && ship.shieldCells ? + + + : null } + + + + + + + + + + -
{formats.int(ship.shield)} {units.MJ}{ship.shield ? formats.time(ship.calcShieldRecovery()) : '-'}{ship.shield ? formats.time(ship.calcShieldRecharge()) : '-'}

{translate('shields')}: {formats.int(ship.shield)} {units.MJ}

{translate('damage from')} {formats.pct1(ship.shieldExplRes || 1)} {formats.pct1(ship.shieldKinRes || 1)} {formats.pct1(ship.shieldThermRes || 1)}

{translate('shield cells')}: {formats.int(ship.shieldCells)} {units.MJ}

{translate('armour')}: {formats.int(ship.armour)}

{translate('damage from')} {formats.pct1(ship.hullExplRes || 1)} {formats.pct1(ship.hullKinRes || 1)} {formats.pct1(ship.hullThermRes || 1)}
: null } -
+ + ); } } diff --git a/src/app/components/OffenceSummary.jsx b/src/app/components/OffenceSummary.jsx index a32f3ec0..4b4237c0 100644 --- a/src/app/components/OffenceSummary.jsx +++ b/src/app/components/OffenceSummary.jsx @@ -1,6 +1,7 @@ import React from 'react'; import cn from 'classnames'; import TranslatedComponent from './TranslatedComponent'; +import { DamageKinetic, DamageThermal, DamageExplosive } from './SvgIcons'; /** * Offence summary @@ -29,75 +30,42 @@ export default class OffenceSummary extends TranslatedComponent { let hide = tooltip.bind(null, null); return ( -
-

{translate('offence summary')}

-
- - - - - - - - - - - - - - - - - - - - -
{translate('dps')}
{translate('explosive')}{translate('kinetic')}{translate('thermal')}{translate('total')}
{formats.f1(ship.totalExplDps)}{formats.f1(ship.totalKinDps)}{formats.f1(ship.totalThermDps)}{formats.f1(ship.totalDps)}
-
- - - - - - - - - - - - - - - - - - - - -
{translate('sustained dps')}
{translate('explosive')}{translate('kinetic')}{translate('thermal')}{translate('total')}
{formats.f1(ship.totalExplSDps)}{formats.f1(ship.totalKinSDps)}{formats.f1(ship.totalThermSDps)}{formats.f1(ship.totalSDps)}
-
- - - - - - - - - - - - - - - - - - - - -
{translate('dpe')}
{translate('explosive')}{translate('kinetic')}{translate('thermal')}{translate('total')}
{formats.f1(ship.totalExplDpe)}{formats.f1(ship.totalKinDpe)}{formats.f1(ship.totalThermDpe)}{formats.f1(ship.totalDpe)}
-
+ +

{translate('offence summary')}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

{translate('dps')}: {formats.f1(ship.totalDps)}

{translate('damage by')} {formats.f1(ship.totalExplDps)} {formats.f1(ship.totalKinDps)} {formats.f1(ship.totalThermDps)}

{translate('sdps')}: {formats.f1(ship.totalSDps)}

{translate('damage by')} {formats.f1(ship.totalExplSDps)} {formats.f1(ship.totalKinSDps)} {formats.f1(ship.totalThermSDps)}

{translate('dpe')}: {formats.f1(ship.totalDpe)}

{translate('damage by')} {formats.f1(ship.totalExplDpe)} {formats.f1(ship.totalKinDpe)} {formats.f1(ship.totalThermDpe)}
+
); } } diff --git a/src/app/i18n/en.js b/src/app/i18n/en.js index 6276f0d1..cc70e86c 100644 --- a/src/app/i18n/en.js +++ b/src/app/i18n/en.js @@ -92,14 +92,18 @@ export const terms = { // Unit for seconds secs: 's', - // Hardpoint abbreviations + // Weapon, offence and defence dpe: 'Damage per MJ of energy', dps: 'Damage per second', + sdps: 'Sustained damage per second', dpssdps: 'Damage per second (sustained damage per second)', eps: 'Energy per second', epsseps: 'Energy per second (sustained energy per second)', hps: 'Heat per second', hpsshps: 'Heat per second (sustained heat per second)', + 'damage by': 'Damage by', + 'damage from': 'Damage from', + 'shield cells': 'Shield cells', // Modifications ammo: 'Ammunition maximum', @@ -134,6 +138,7 @@ export const terms = { rof: 'Rate of fire', shield: 'Shield', shieldboost: 'Shield boost', + shieldreinforcement: 'Shield reinforcement', spinup: 'Spin up time', syscap: 'Systems capacity', sysrate: 'Systems recharge rate', diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index dbc3488e..cb1a5d25 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -492,4 +492,20 @@ export default class Module { return this._getModifiedValue('hullboost'); } + /** + * Get the shield reinforcement for this module, taking in to account modifications + * @return {Number} the shield reinforcement for this module + */ + getShieldReinforcement() { + return this._getModifiedValue('shieldreinforcement'); + } + + /** + * Get the cells for this module, taking in to account modifications + * @return {Number} the cells for this module + */ + getCells() { + return this._getModifiedValue('cells'); + } + } diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index e71f8ac6..0de12dec 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -236,9 +236,8 @@ export default class Ship { sg = sgSlot.m; } - // TODO obtain shield boost - // return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, this.shieldMultiplier + (multiplierDelta || 0)); - return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, 0 + (multiplierDelta || 0)); + // TODO Not accurate if the ship has modified shield boosters + return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, 1 + (multiplierDelta || 0)); } /** @@ -442,6 +441,9 @@ export default class Ship { } else if (name === 'hullboost' || name === 'hullreinforcement') { m.setModValue(name, value); this.recalculateArmour(); + } else if (name === 'shieldreinforcement') { + m.setModValue(name, value); + this.recalculateShieldCells(); } else if (name === 'burst' || name === 'clip' || name === 'damage' || name === 'distdraw' || name === 'jitter' || name === 'piercing' || name === 'range' || name === 'reload' || name === 'rof' || name === 'thermload') { m.setModValue(name, value); this.recalculateDps(); @@ -479,6 +481,7 @@ export default class Ship { this.ladenMass = 0; this.armour = this.baseArmour; this.shield = this.baseShieldStrength; + this.shieldCells = 0; this.totalCost = this.m.incCost ? this.m.discountedCost : 0; this.unladenMass = this.hullMass; this.totalDpe = 0; @@ -564,6 +567,7 @@ export default class Ship { .updatePowerUsed() .updateJumpStats() .recalculateShield() + .recalculateShieldCells() .recalculateArmour() .recalculateDps() .recalculateEps() @@ -1097,6 +1101,24 @@ export default class Ship { return this; } + /** + * Update shield cells + * @return {this} The ship instance (for chaining operations) + */ + recalculateShieldCells() { + let shieldCells = 0; + + for (let slot of this.internal) { + if (slot.m && slot.m.grp == 'scb') { + shieldCells += slot.m.getShieldReinforcement() * slot.m.getCells(); + } + } + + this.shieldCells = shieldCells; + + return this; + } + /** * Update armour and hull resistances * @return {this} The ship instance (for chaining operations) diff --git a/src/less/icons.less b/src/less/icons.less index 91362fd6..9af0c0e6 100755 --- a/src/less/icons.less +++ b/src/less/icons.less @@ -56,3 +56,9 @@ height: 2em; } } + +.summary { + stroke: @fg; + stroke-width: 10; + fill: @fg; +}