Chart performance tweaks, UI tweaks

This commit is contained in:
Colin McLeod
2015-06-15 21:46:55 -07:00
parent bee4f7e6bc
commit b94e6126cd
4 changed files with 47 additions and 82 deletions

View File

@@ -176,15 +176,15 @@ angular.module('shipyard', ['ngLodash'])
.value('calcJumpRange', function(mass, fsd, fuel) {
return Math.pow(Math.min(fuel === undefined ? fsd.maxfuel : fuel, fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
})
/**
* Calculate the maximum single jump range based on mass and a specific FSD
/**
* Calculate the total 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 Optional - The fuel consumed during the jump (must be less than the drives max fuel per jump)
* @param {number} fuel The total fuel available
* @return {number} Distance in Light Years
*/
.value('calcTotalRangev1', function(mass, fsd, fuel) {
.value('calcTotalRange', function(mass, fsd, fuel) {
var fuelRemaining = fuel % fsd.maxfuel; // Fuel left after making N max jumps
var jumps = fuel / fsd.maxfuel;
mass += fuelRemaining;
@@ -196,29 +196,6 @@ angular.module('shipyard', ['ngLodash'])
totalRange += Math.pow(fsd.maxfuel / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
}
return totalRange;
})
/**
* Calculate the maximum single jump range based on mass and a specific FSD
*
* @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 Optional - The fuel consumed during the jump (must be less than the drives max fuel per jump)
* @return {number} Distance in Light Years
*/
.value('calcTotalRange', function(mass, fsd, fuel) {
var maxfuel = fsd.maxfuel;
var maxJumpCount = Math.floor(fuel / maxfuel);
var fuelRemaining = fuel % maxfuel;
var jumpCoefficient = Math.pow(fsd.maxfuel / fsd.fuelmul, 1 / fsd.fuelpower);
mass += fuelRemaining;
var massCoefficient = (fsd.optmass / maxfuel) * (Math.log(mass + (maxJumpCount * maxfuel)) - Math.log(mass));
var totalDistance = (jumpCoefficient * massCoefficient);
if (fuelRemaining > 0) {
totalDistance += Math.pow(fuelRemaining / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
}
return totalDistance;
})
/**
* Calculate the a ships shield strength based on mass, shield generator and shield boosters used.