diff --git a/src/app/components/Defence.jsx b/src/app/components/Defence.jsx index d365206c..7d6f5e78 100644 --- a/src/app/components/Defence.jsx +++ b/src/app/components/Defence.jsx @@ -18,7 +18,8 @@ export default class Defence extends TranslatedComponent { ship: React.PropTypes.object.isRequired, opponent: React.PropTypes.object.isRequired, engagementrange: React.PropTypes.number.isRequired, - sys: React.PropTypes.number.isRequired + sys: React.PropTypes.number.isRequired, + opponentWep: React.PropTypes.number.isRequired }; /** @@ -28,7 +29,7 @@ export default class Defence extends TranslatedComponent { constructor(props) { super(props); - const { shield, armour, shielddamage, armourdamage } = Calc.defenceMetrics(props.ship, props.opponent, props.sys, props.engagementrange); + const { shield, armour, shielddamage, armourdamage } = Calc.defenceMetrics(props.ship, props.opponent, props.sys, props.opponentWep, props.engagementrange); this.state = { shield, armour, shielddamage, armourdamage }; } @@ -39,7 +40,7 @@ export default class Defence extends TranslatedComponent { */ componentWillReceiveProps(nextProps) { if (this.props.marker != nextProps.marker || this.props.sys != nextProps.sys) { - const { shield, armour, shielddamage, armourdamage } = Calc.defenceMetrics(nextProps.ship, nextProps.opponent, nextProps.sys, nextProps.engagementrange); + const { shield, armour, shielddamage, armourdamage } = Calc.defenceMetrics(nextProps.ship, nextProps.opponent, nextProps.sys, nextProps.opponentWep, nextProps.engagementrange); this.setState({ shield, armour, shielddamage, armourdamage }); } return true; @@ -50,7 +51,7 @@ export default class Defence extends TranslatedComponent { * @return {React.Component} contents */ render() { - const { ship, sys } = this.props; + const { ship, sys, opponentWep } = this.props; const { language, tooltip, termtip } = this.context; const { formats, translate, units } = language; const { shield, armour, shielddamage, armourdamage } = this.state; @@ -155,7 +156,7 @@ export default class Defence extends TranslatedComponent {

{translate('shield metrics')}


{shieldTooltipDetails})} onMouseOut={tooltip.bind(null, null)} className='summary'>{translate('raw shield strength')}
{formats.int(shield.total)}{units.MJ}

-

{translate('PHRASE_TIME_TO_LOSE_SHIELDS')}
{shielddamage.totalsdps == 0 ? translate('ever') : formats.time(Calc.timeToDeplete(shield.total, shielddamage.totalsdps, shielddamage.totalseps, pd.getWeaponsCapacity(), pd.getWeaponsRechargeRate()))}

+

{translate('PHRASE_TIME_TO_LOSE_SHIELDS')}
{shielddamage.totalsdps == 0 ? translate('ever') : formats.time(Calc.timeToDeplete(shield.total, shielddamage.totalsdps, shielddamage.totalseps, pd.getWeaponsCapacity(), pd.getWeaponsRechargeRate() * opponentWep / 4))}

{translate('PHRASE_TIME_TO_RECOVER_SHIELDS')}
{shield.recover === Math.Inf ? translate('never') : formats.time(shield.recover)}

{translate('PHRASE_TIME_TO_RECHARGE_SHIELDS')}
{shield.recharge === Math.Inf ? translate('never') : formats.time(shield.recharge)}

@@ -176,7 +177,7 @@ export default class Defence extends TranslatedComponent {

{translate('armour metrics')}

{armourTooltipDetails}

)} onMouseOut={tooltip.bind(null, null)} className='summary'>{translate('raw armour strength')}
{formats.int(armour.total)} -

{translate('PHRASE_TIME_TO_LOSE_ARMOUR')}
{armourdamage.totalsdps == 0 ? translate('ever') : formats.time(Calc.timeToDeplete(armour.total, armourdamage.totalsdps, armourdamage.totalseps, pd.getWeaponsCapacity(), pd.getWeaponsRechargeRate()))}

+

{translate('PHRASE_TIME_TO_LOSE_ARMOUR')}
{armourdamage.totalsdps == 0 ? translate('ever') : formats.time(Calc.timeToDeplete(armour.total, armourdamage.totalsdps, armourdamage.totalseps, pd.getWeaponsCapacity(), pd.getWeaponsRechargeRate() * opponentWep / 4))}

{translate('raw module armour')}
{formats.int(armour.modulearmour)}

{translate('PHRASE_MODULE_PROTECTION_EXTERNAL')}
{formats.pct1(armour.moduleprotection / 2)}

{translate('PHRASE_MODULE_PROTECTION_INTERNAL')}
{formats.pct1(armour.moduleprotection)}

diff --git a/src/app/components/Offence.jsx b/src/app/components/Offence.jsx index bb880d4d..0faa5c82 100644 --- a/src/app/components/Offence.jsx +++ b/src/app/components/Offence.jsx @@ -55,7 +55,8 @@ export default class Offence extends TranslatedComponent { ship: React.PropTypes.object.isRequired, opponent: React.PropTypes.object.isRequired, engagementrange: React.PropTypes.number.isRequired, - wep: React.PropTypes.number.isRequired + wep: React.PropTypes.number.isRequired, + opponentSys: React.PropTypes.number.isRequired }; /** @@ -67,7 +68,7 @@ export default class Offence extends TranslatedComponent { this._sort = this._sort.bind(this); - const damage = Calc.offenceMetrics(props.ship, props.opponent, props.eng, props.engagementrange); + const damage = Calc.offenceMetrics(props.ship, props.opponent, props.wep, props.opponentSys, props.engagementrange); this.state = { predicate: 'n', desc: true, @@ -82,7 +83,7 @@ export default class Offence extends TranslatedComponent { */ componentWillReceiveProps(nextProps) { if (this.props.marker != nextProps.marker || this.props.eng != nextProps.eng) { - const damage = Calc.offenceMetrics(nextProps.ship, nextProps.opponent, nextProps.wep, nextProps.engagementrange); + const damage = Calc.offenceMetrics(nextProps.ship, nextProps.opponent, nextProps.wep, nextProps.opponentSys, nextProps.engagementrange); this.setState({ damage }); } return true; diff --git a/src/app/components/OutfittingSubpages.jsx b/src/app/components/OutfittingSubpages.jsx index 6a8bf2bd..5eb2abb1 100644 --- a/src/app/components/OutfittingSubpages.jsx +++ b/src/app/components/OutfittingSubpages.jsx @@ -31,7 +31,10 @@ export default class OutfittingSubpages extends TranslatedComponent { boost: React.PropTypes.bool.isRequired, engagementRange: React.PropTypes.number.isRequired, opponent: React.PropTypes.object.isRequired, - opponentBuild: React.PropTypes.string + opponentBuild: React.PropTypes.string, + opponentSys: React.PropTypes.number.isRequired, + opponentEng: React.PropTypes.number.isRequired, + opponentWep: React.PropTypes.number.isRequired, }; /** @@ -80,7 +83,7 @@ export default class OutfittingSubpages extends TranslatedComponent { * @return {React.Component} Tab contents */ _profilesTab() { - const { ship, opponent, cargo, fuel, eng, boost, engagementRange } = this.props; + const { ship, opponent, cargo, fuel, eng, boost, engagementRange, opponentSys } = this.props; const { translate } = this.context.language; let realBoost = boost && ship.canBoost(); Persist.setOutfittingTab('profiles'); @@ -88,7 +91,7 @@ export default class OutfittingSubpages extends TranslatedComponent { const engineProfileMarker = `${ship.toString()}:${cargo}:${fuel}:${eng}:${realBoost}`; const fsdProfileMarker = `${ship.toString()}:${cargo}:${fuel}`; const movementMarker = `${ship.topSpeed}:${ship.pitch}:${ship.roll}:${ship.yaw}:${ship.canBoost()}`; - const damageMarker = `${ship.toString()}:${opponent.toString()}:${engagementRange}`; + const damageMarker = `${ship.toString()}:${opponent.toString()}:${engagementRange}:${opponentSys}`; return
@@ -123,13 +126,13 @@ export default class OutfittingSubpages extends TranslatedComponent { * @return {React.Component} Tab contents */ _offenceTab() { - const { ship, sys, eng, wep, cargo, fuel, boost, engagementRange, opponent, opponentBuild } = this.props; + const { ship, sys, eng, wep, cargo, fuel, boost, engagementRange, opponent, opponentBuild, opponentSys } = this.props; Persist.setOutfittingTab('offence'); - const marker = `${ship.toString()}:${opponent.toString()}:${opponentBuild}:${engagementRange}`; + const marker = `${ship.toString()}${opponent.toString()}${opponentBuild}${engagementRange}${opponentSys}`; return
- +
; } @@ -138,13 +141,13 @@ export default class OutfittingSubpages extends TranslatedComponent { * @return {React.Component} Tab contents */ _defenceTab() { - const { ship, sys, eng, wep, cargo, fuel, boost, engagementRange, opponent, opponentBuild } = this.props; + const { ship, sys, eng, wep, cargo, fuel, boost, engagementRange, opponent, opponentBuild, opponentWep } = this.props; Persist.setOutfittingTab('defence'); - const marker = `${ship.toString()}:${opponent.toString()}:${opponentBuild}:${engagementRange}`; + const marker = `${ship.toString()}${opponent.toString()}{opponentBuild}${engagementRange}${opponentWep}`; return
- +
; } diff --git a/src/app/components/ShipPicker.jsx b/src/app/components/ShipPicker.jsx index c2bcb9a4..93505b8d 100644 --- a/src/app/components/ShipPicker.jsx +++ b/src/app/components/ShipPicker.jsx @@ -45,7 +45,7 @@ export default class ShipPicker extends TranslatedComponent { this._closeMenu(); // Ensure that the ship has changed - if (ship !== this.props.ship || this.build !== this.props.build) { + if (ship !== this.props.ship || build !== this.props.build) { this.props.onChange(ship, build); } } diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx index 11b4b71a..81372ec8 100644 --- a/src/app/pages/OutfittingPage.jsx +++ b/src/app/pages/OutfittingPage.jsx @@ -299,16 +299,22 @@ export default class OutfittingPage extends Page { Persist.saveBuild(shipId, newBuildName, code); this._updateRoute(shipId, newBuildName, code); - let opponent, opponentBuild; + let opponent, opponentBuild, opponentSys, opponentEng, opponentWep; if (shipId === this.state.opponent.id && buildName === this.state.opponentBuild) { // This is a save of our current opponent build; update it opponentBuild = newBuildName; opponent = new Ship(shipId, Ships[shipId].properties, Ships[shipId].slots).buildFrom(code); + opponentSys = this.state.sys; + opponentEng = this.state.eng; + opponentWep = this.state.wep; } else { opponentBuild = this.state.opponentBuild; opponent = this.state.opponent; + opponentSys = this.state.opponentSys; + opponentEng = this.state.opponentEng; + opponentWep = this.state.opponentWep; } - this.setState({ buildName: newBuildName, code, savedCode: code, opponent, opponentBuild, title: this._getTitle(newBuildName) }); + this.setState({ buildName: newBuildName, code, savedCode: code, opponent, opponentBuild, opponentSys, opponentEng, opponentWep, title: this._getTitle(newBuildName) }); } /** @@ -507,7 +513,7 @@ export default class OutfittingPage extends Page { let state = this.state, { language, termtip, tooltip, sizeRatio, onWindowResize } = this.context, { translate, units, formats } = language, - { ship, code, savedCode, buildName, newBuildName, sys, eng, wep, boost, fuel, cargo, opponent, opponentBuild, engagementRange } = state, + { ship, code, savedCode, buildName, newBuildName, sys, eng, wep, boost, fuel, cargo, opponent, opponentBuild, opponentSys, opponentEng, opponentWep, engagementRange } = state, hide = tooltip.bind(null, null), menu = this.props.currentMenu, shipUpdated = this._shipUpdated, @@ -616,6 +622,9 @@ export default class OutfittingPage extends Page { engagementRange={engagementRange} opponent={opponent} opponentBuild={opponentBuild} + opponentSys={opponentSys} + opponentEng={opponentEng} + opponentWep={opponentWep} />
); diff --git a/src/app/shipyard/Calculations.js b/src/app/shipyard/Calculations.js index 30432949..3b806710 100644 --- a/src/app/shipyard/Calculations.js +++ b/src/app/shipyard/Calculations.js @@ -533,10 +533,11 @@ export function armourMetrics(ship) { * @param {Object} ship The ship * @param {Object} opponent The opponent ship * @param {int} sys The pips to SYS + * @param {int} opponentWep The pips to pponent's WEP * @param {int} engagementrange The range between the ship and opponent * @returns {Object} Defence metrics */ -export function defenceMetrics(ship, opponent, sys, engagementrange) { +export function defenceMetrics(ship, opponent, sys, opponentWep, engagementrange) { // Obtain the shield metrics const shield = this.shieldMetrics(ship, sys); @@ -572,15 +573,16 @@ export function defenceMetrics(ship, opponent, sys, engagementrange) { * @param {Object} ship The ship * @param {Object} opponent The opponent ship * @param {int} wep The pips to WEP + * @param {int} opponentSys The pips to opponent's SYS * @param {int} engagementrange The range between the ship and opponent * @returns {array} Offence metrics */ -export function offenceMetrics(ship, opponent, wep, engagementrange) { +export function offenceMetrics(ship, opponent, wep, opponentSys, engagementrange) { // Per-weapon and total damage const damage = []; // Obtain the opponent's shield and armour metrics - const opponentShields = this.shieldMetrics(opponent, 4); + const opponentShields = this.shieldMetrics(opponent, opponentSys); const opponentArmour = this.armourMetrics(opponent); // Per-weapon and total damage to shields @@ -612,18 +614,6 @@ export function offenceMetrics(ship, opponent, wep, engagementrange) { } return damage; - - const shielddamage = opponentShields.generator ? { - absolute: { - weapon1: 10, - weapon2: 10, - weapon3: 10, - weapon4: 10, - total: 40 - } - } : {}; - - return damage; } /** @@ -632,7 +622,7 @@ export function offenceMetrics(ship, opponent, wep, engagementrange) { * @returns {integer} the resistance for the given pips */ export function sysResistance(sys) { - return Math.pow(sys,0.85) * 0.6 / Math.pow(4,0.85); + return Math.pow(sys, 0.85) * 0.6 / Math.pow(4, 0.85); } /**