Alter way that X axis for profile charts is calculated

This commit is contained in:
Cmdr McDonald
2017-02-27 09:24:32 +00:00
parent 5a351d4c0d
commit cdc5c29458
4 changed files with 30 additions and 23 deletions

View File

@@ -86,19 +86,13 @@ export default class EngineProfile extends TranslatedComponent {
// Calculate bounds for our line chart // Calculate bounds for our line chart
const thrusters = ship.standard[1].m; const thrusters = ship.standard[1].m;
const minMass = thrusters.getMinMass(); const minMass = ship.calcLowestPossibleMass({th: thrusters});
const maxMass = thrusters.getMaxMass(); const maxMass = thrusters.getMaxMass();
let mass = ship.unladenMass + ship.fuelCapacity + cargo;
const minSpeed = Calc.speed(maxMass, ship.speed, thrusters, ship.engpip)[4]; const minSpeed = Calc.speed(maxMass, ship.speed, thrusters, ship.engpip)[4];
const maxSpeed = Calc.speed(minMass, ship.speed, thrusters, ship.engpip)[4]; const maxSpeed = Calc.speed(minMass, ship.speed, thrusters, ship.engpip)[4];
let mass = ship.unladenMass + ship.fuelCapacity + cargo; // Add a mark at our current mass
let mark; const mark = Math.min(mass, maxMass);
if (mass < minMass) {
mark = minMass;
} else if (mass > maxMass) {
mark = maxMass;
} else {
mark = mass;
}
const cargoPercent = cargo / ship.cargoCapacity; const cargoPercent = cargo / ship.cargoCapacity;

View File

@@ -88,19 +88,13 @@ export default class FSDProfile extends TranslatedComponent {
// Calculate bounds for our line chart - use thruster info for X // Calculate bounds for our line chart - use thruster info for X
const thrusters = ship.standard[1].m; const thrusters = ship.standard[1].m;
const fsd = ship.standard[2].m; const fsd = ship.standard[2].m;
const minMass = thrusters.getMinMass(); const minMass = ship.calcLowestPossibleMass({th: thrusters});
const maxMass = thrusters.getMaxMass(); const maxMass = thrusters.getMaxMass();
const minRange = 0; let mass = ship.unladenMass + ship.fuelCapacity + cargo;
const minRange = Calc.jumpRange(maxMass, fsd, ship.fuelCapacity);
const maxRange = Calc.jumpRange(minMass + fsd.getMaxFuelPerJump(), fsd, fsd.getMaxFuelPerJump()); const maxRange = Calc.jumpRange(minMass + fsd.getMaxFuelPerJump(), fsd, fsd.getMaxFuelPerJump());
let mass = ship.unladenMass + fsd.getMaxFuelPerJump() + cargo; // Add a mark at our current mass
let mark; const mark = Math.min(mass, maxMass);
if (mass < minMass) {
mark = minMass;
} else if (mass > maxMass) {
mark = maxMass;
} else {
mark = mass;
}
const cargoPercent = cargo / ship.cargoCapacity; const cargoPercent = cargo / ship.cargoCapacity;

View File

@@ -282,10 +282,10 @@ The retrofit costs provides information about the costs of changing the base bui
The reload costs provides information about the costs of reloading your current build.</p> The reload costs provides information about the costs of reloading your current build.</p>
<h2>Engine Profile</h2> <h2>Engine Profile</h2>
The engine profile panel provides information about the capabilities of your current thrusters. The graph shows you how the maximum speed (with 4 pips to engines) alters with the overall mass of your build. The slider can be altered to change the amount of cargo you have on-board. Your engine profile can be altered by obtaining different thrusters or engineering your existing thrusters.</p> The engine profile panel provides information about the capabilities of your current thrusters. The graph shows you how the maximum speed (with a full fuel tank and 4 pips to engines) alters with the overall mass of your build. The slider can be altered to change the amount of cargo you have on-board. Your engine profile can be altered by obtaining different thrusters or engineering your existing thrusters.</p>
<h2>FSD Profile</h2> <h2>FSD Profile</h2>
The FSD profile panel provides information about the capabilities of your current frame shift drive. The graph shows you how the maximum jump range alters with the overall mass of your build. The slider can be altered to change the amount of cargo you have on-board. Your FSD profile can be altered by obtaining a different FSD or engineering your existing FSD.</p> The FSD profile panel provides information about the capabilities of your current frame shift drive. The graph shows you how the maximum jump range (with a full fuel tank) alters with the overall mass of your build. The slider can be altered to change the amount of cargo you have on-board. Your FSD profile can be altered by obtaining a different FSD or engineering your existing FSD.</p>
<h2>Jump Range</h2> <h2>Jump Range</h2>
The jump range panel provides information about the build&apos; jump range. The graph shows how the build&apos;s jump range changes with the amount of cargo on-board. The slider can be altered to change the amount of fuel you have on-board.</p> The jump range panel provides information about the build&apos; jump range. The graph shows how the build&apos;s jump range changes with the amount of cargo on-board. The slider can be altered to change the amount of fuel you have on-board.</p>

View File

@@ -1682,6 +1682,25 @@ export default class Ship {
return this; return this;
} }
/**
* Calculate the lowest possible mass for this ship.
* @param {Object} m Module override set (standard type => Module)
* @return {number} The lowest possible mass for this ship
*/
calcLowestPossibleMass(m) {
m = m || {};
let mass = this.hullMass;
mass += m.pp ? m.pp.getMass() : ModuleUtils.standard(0, '2D').getMass();
mass += m.th ? m.th.getMass() : ModuleUtils.standard(1, '2D').getMass();
mass += m.fsd ? m.fsd.getMass() : ModuleUtils.standard(2, this.standard[2].maxClass + 'D').getMass();
mass += m.ls ? m.ls.getMass() : ModuleUtils.standard(3, this.standard[3].maxClass + 'D').getMass() * 0.3; // Lightweight grade 4 mod reduces mass by up to 70%
mass += m.pd ? m.pd.getMass() : ModuleUtils.standard(4, '2D').getMass();
mass += m.s ? m.s.getMass() : ModuleUtils.standard(5, this.standard[5].maxClass + 'D').getMass();
mass += m.ft ? m.ft.getMass() : ModuleUtils.standard(6, '1C').getMass();
return mass;
}
/** /**
* Use the lightest standard ModuleUtils unless otherwise specified * Use the lightest standard ModuleUtils unless otherwise specified
* @param {Object} m Module override set (standard type => module ID) * @param {Object} m Module override set (standard type => module ID)