diff --git a/src/app/components/Movement.jsx b/src/app/components/Movement.jsx index 6f84a052..df993c65 100644 --- a/src/app/components/Movement.jsx +++ b/src/app/components/Movement.jsx @@ -58,13 +58,13 @@ export default class Movement extends TranslatedComponent { // Speed - {formats.int(ship.calcSpeed(eng, fuel, cargo, boost))}m/s + {formats.int(ship.calcSpeed(eng, fuel, cargo, boost))}m/s // Pitch - {formats.int(ship.calcPitch(eng, fuel, cargo, boost))}°/s + {formats.int(ship.calcPitch(eng, fuel, cargo, boost))}°/s // Roll - {formats.int(ship.calcRoll(eng, fuel, cargo, boost))}°/s + {formats.int(ship.calcRoll(eng, fuel, cargo, boost))}°/s // Yaw - {formats.int(ship.calcYaw(eng, fuel, cargo, boost))}°/s + {formats.int(ship.calcYaw(eng, fuel, cargo, boost))}°/s ); } diff --git a/src/app/components/OutfittingSubpages.jsx b/src/app/components/OutfittingSubpages.jsx index 807bf4f7..e8b33620 100644 --- a/src/app/components/OutfittingSubpages.jsx +++ b/src/app/components/OutfittingSubpages.jsx @@ -138,7 +138,7 @@ export default class OutfittingSubpages extends TranslatedComponent { } return ( -
+
diff --git a/src/app/components/ShipSummaryTable.jsx b/src/app/components/ShipSummaryTable.jsx index 651f9a9f..a982b1df 100644 --- a/src/app/components/ShipSummaryTable.jsx +++ b/src/app/components/ShipSummaryTable.jsx @@ -2,6 +2,7 @@ import React from 'react'; import TranslatedComponent from './TranslatedComponent'; import cn from 'classnames'; import { Warning } from './SvgIcons'; +import * as Calc from '../shipyard/Calculations'; /** * Ship Summary Table / Stats @@ -9,7 +10,13 @@ import { Warning } from './SvgIcons'; export default class ShipSummaryTable extends TranslatedComponent { static propTypes = { - ship: React.PropTypes.object.isRequired + ship: React.PropTypes.object.isRequired, + sys: React.PropTypes.number.isRequired, + eng: React.PropTypes.number.isRequired, + wep: React.PropTypes.number.isRequired, + cargo: React.PropTypes.number.isRequired, + fuel: React.PropTypes.number.isRequired, + marker: React.PropTypes.string.isRequired, }; /** @@ -17,7 +24,7 @@ export default class ShipSummaryTable extends TranslatedComponent { * @return {React.Component} Summary table */ render() { - let ship = this.props.ship; + const { ship, fuel, eng, cargo, boost } = this.props; let { language, tooltip, termtip } = this.context; let translate = language.translate; let u = language.units; @@ -49,8 +56,7 @@ export default class ShipSummaryTable extends TranslatedComponent { - - + @@ -58,36 +64,28 @@ export default class ShipSummaryTable extends TranslatedComponent { - - - - - - + + - - + + - - - - - - - - - - - - + + + + + + + + diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx index 7ad4b5d4..eb501fb1 100644 --- a/src/app/pages/OutfittingPage.jsx +++ b/src/app/pages/OutfittingPage.jsx @@ -375,6 +375,7 @@ export default class OutfittingPage extends Page { // Markers are used to propagate state changes without requiring a deep comparison of the ship, as that takes a long time const boostMarker = `${ship.canBoost()}`; + const shipSummaryMarker = `${ship.toString()}:${eng}:${fuel}:${cargo}`; return (
@@ -410,7 +411,7 @@ export default class OutfittingPage extends Page {
{/* Main tables */} - + diff --git a/src/app/shipyard/Calculations.js b/src/app/shipyard/Calculations.js index 7e74913b..732328cc 100644 --- a/src/app/shipyard/Calculations.js +++ b/src/app/shipyard/Calculations.js @@ -9,33 +9,33 @@ import Module from './Module'; * @return {number} Distance in Light Years */ export function jumpRange(mass, fsd, fuel) { - let fsdMaxFuelPerJump = fsd instanceof Module ? fsd.getMaxFuelPerJump() : fsd.maxfuel; - let fsdOptimalMass = fsd instanceof Module ? fsd.getOptMass() : fsd.optmass; + const fsdMaxFuelPerJump = fsd instanceof Module ? fsd.getMaxFuelPerJump() : fsd.maxfuel; + const fsdOptimalMass = fsd instanceof Module ? fsd.getOptMass() : fsd.optmass; return Math.pow(Math.min(fuel === undefined ? fsdMaxFuelPerJump : fuel, fsdMaxFuelPerJump) / fsd.fuelmul, 1 / fsd.fuelpower) * fsdOptimalMass / mass; } /** - * Calculate the fastest (total) range based on mass and a specific FSD, and all fuel available + * Calculate the total jump range based on mass and a specific FSD, and all fuel available * * @param {number} mass Mass of a ship: laden, unlanden, partially laden, etc * @param {object} fsd The FDS object/component with maxfuel, fuelmul, fuelpower, optmass * @param {number} fuel The total fuel available * @return {number} Distance in Light Years */ -export function fastestRange(mass, fsd, fuel) { - let fsdMaxFuelPerJump = fsd instanceof Module ? fsd.getMaxFuelPerJump() : fsd.maxfuel; - let fsdOptimalMass = fsd instanceof Module ? fsd.getOptMass() : fsd.optmass; - let fuelRemaining = fuel % fsdMaxFuelPerJump; // Fuel left after making N max jumps - let jumps = Math.floor(fuel / fsdMaxFuelPerJump); - mass += fuelRemaining; - // Going backwards, start with the last jump using the remaining fuel - let fastestRange = fuelRemaining > 0 ? Math.pow(fuelRemaining / fsd.fuelmul, 1 / fsd.fuelpower) * fsdOptimalMass / mass : 0; - // For each max fuel jump, calculate the max jump range based on fuel mass left in the tank - for (let j = 0; j < jumps; j++) { - mass += fsd.maxfuel; - fastestRange += Math.pow(fsdMaxFuelPerJump / fsd.fuelmul, 1 / fsd.fuelpower) * fsdOptimalMass / mass; +export function totalJumpRange(mass, fsd, fuel) { + const fsdMaxFuelPerJump = fsd instanceof Module ? fsd.getMaxFuelPerJump() : fsd.maxfuel; + const fsdOptimalMass = fsd instanceof Module ? fsd.getOptMass() : fsd.optmass; + + let fuelRemaining = fuel; + let totalRange = 0; + while (fuelRemaining > 0) { + const fuelForThisJump = Math.min(fuelRemaining, fsdMaxFuelPerJump); + totalRange += this.jumpRange(mass, fsd, fuelForThisJump); + // Mass is reduced + mass -= fuelForThisJump; + fuelRemaining -= fuelForThisJump; } - return fastestRange; + return totalRange; }; /** diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 9a591fdc..e36cba54 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -138,17 +138,6 @@ export default class Ship { this.standard[4].m.getEnginesCapacity() > this.boostEnergy; // PD capacitor is sufficient for boost } - /** - * Calculate hypothetical jump range using the installed FSD and the - * specified mass which can be more or less than ships actual mass - * @param {Number} fuel Fuel available in tons - * @param {Number} cargo Cargo in tons - * @return {Number} Jump range in Light Years - */ - calcJumpRangeWith(fuel, cargo) { - return Calc.jumpRange(this.unladenMass + fuel + cargo, this.standard[2].m, fuel); - } - /** * Calculate the hypothetical laden jump range based on a potential change in mass, fuel, or FSD * @param {Number} massDelta Optional - Change in laden mass (mass + cargo + fuel) @@ -173,17 +162,6 @@ export default class Ship { return Calc.jumpRange(this.unladenMass + (massDelta || 0) + Math.min(fsdMaxFuelPerJump, fuel || this.fuelCapacity), fsd || this.standard[2].m, fuel); } - /** - * Calculate cumulative (total) jump range when making longest jumps using the installed FSD and the - * specified mass which can be more or less than ships actual mass - * @param {Number} fuel Fuel available in tons - * @param {Number} cargo Cargo in tons - * @return {Number} Total/Cumulative Jump range in Light Years - */ - calcFastestRangeWith(fuel, cargo) { - return Calc.fastestRange(this.unladenMass + fuel + cargo, this.standard[2].m, fuel); - } - /** * Calculate the hypothetical top speeds at cargo and fuel tonnage * @param {Number} fuel Fuel available in tons @@ -1398,9 +1376,9 @@ export default class Ship { this.unladenRange = this.calcUnladenRange(); // Includes fuel weight for jump this.fullTankRange = Calc.jumpRange(unladenMass + fuelCapacity, fsd); // Full Tank this.ladenRange = this.calcLadenRange(); // Includes full tank and caro - this.unladenFastestRange = Calc.fastestRange(unladenMass, fsd, fuelCapacity); - this.ladenFastestRange = Calc.fastestRange(unladenMass + this.cargoCapacity, fsd, fuelCapacity); - this.maxJumpCount = Math.ceil(fuelCapacity / fsd.maxfuel); + this.unladenFastestRange = Calc.totalJumpRange(unladenMass + this.fuelCapacity, fsd, fuelCapacity); + this.ladenFastestRange = Calc.totalJumpRange(unladenMass + this.fuelCapacity + this.cargoCapacity, fsd, fuelCapacity); + this.maxJumpCount = Math.ceil(fuelCapacity / fsd.getMaxFuelPerJump()); return this; } diff --git a/src/less/shippicker.less b/src/less/shippicker.less index 8c7658c1..982bf5ad 100755 --- a/src/less/shippicker.less +++ b/src/less/shippicker.less @@ -11,7 +11,6 @@ .menu { position: relative; - z-index: 1; cursor: default; &.r {
{translate('mass')} {translate('cargo')} {translate('fuel')}{translate('jump range')}{translate('fastest range')}{translate('jump range')} {translate('crew')} {translate('MLF')}
{translate('hull')} {translate('unladen')} {translate('laden')}{translate('max')}{translate('full tank')}{translate('laden')}{translate('jumps')}{translate('unladen')}{translate('laden')}{translate('single')}{translate('total')}
{ ship.canThrust() ? {int(ship.topSpeed)} {u['m/s']} : 0 }{ ship.canBoost() ? {int(ship.topBoost)} {u['m/s']} : 0 }{ ship.canThrust() ? {int(ship.calcSpeed(eng, fuel, cargo, false))}{u['m/s']} : 0 }{ ship.canBoost() ? {int(ship.calcSpeed(eng, fuel, cargo, true))}{u['m/s']} : 0 } {f1(ship.totalDps)} {f1(ship.totalEps)} {ship.timeToDrain === Infinity ? '∞' : time(ship.timeToDrain)} {f1(ship.totalHps)} {int(ship.hardness)} {int(ship.armour)}{int(ship.shield)} {u.MJ}{ship.hullMass} {u.T}{int(ship.unladenMass)} {u.T}{int(ship.ladenMass)} {u.T}{round(ship.cargoCapacity)} {u.T}{round(ship.fuelCapacity)} {u.T}{f2(ship.unladenRange)} {u.LY}{f2(ship.fullTankRange)} {u.LY}{f2(ship.ladenRange)} {u.LY}{int(ship.maxJumpCount)}{f2(ship.unladenFastestRange)} {u.LY}{f2(ship.ladenFastestRange)} {u.LY}{int(ship.shield)}{u.MJ}{ship.hullMass}{u.T}{int(ship.unladenMass)}{u.T}{int(ship.ladenMass)}{u.T}{round(ship.cargoCapacity)}{u.T}{round(ship.fuelCapacity)}{u.T}{f2(Calc.jumpRange(ship.unladenMass + fuel + cargo, ship.standard[2].m, fuel))}{u.LY}{f2(Calc.totalJumpRange(ship.unladenMass + fuel + cargo, ship.standard[2].m, fuel))}{u.LY} {ship.crew} {ship.masslock}