diff --git a/app/js/controllers/controller-outfit.js b/app/js/controllers/controller-outfit.js index e6da0fa3..5f03080a 100755 --- a/app/js/controllers/controller-outfit.js +++ b/app/js/controllers/controller-outfit.js @@ -100,11 +100,11 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', ' $scope.speedSeries = { xMin: 0, xMax: ship.cargoCapacity, - yMax: 500, + yMax: calcSpeed(ship.unladenMass, ship.speed, $scope.th.c, ship.pipSpeed)['4 Pips'], yMin: 0, - series: ['speed', 'boost'], + series: ['4 Pips', '2 Pips', '0 Pips'], func: function(cargo) { // X Axis is Cargo - return calcSpeed(ship.unladenMass + $scope.fuel + cargo, ship.speed, ship.boost, $scope.th.c); + return calcSpeed(ship.unladenMass + $scope.fuel + cargo, ship.speed, $scope.th.c, ship.pipSpeed); } }; $scope.speedChart = { @@ -360,6 +360,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', ' $scope.speedSeries.xMax = $scope.trSeries.xMax = $scope.jrSeries.xMax = ship.cargoCapacity; $scope.jrSeries.yMax = ship.unladenRange; $scope.trSeries.yMax = ship.unladenTotalRange; + $scope.speedSeries.yMax = calcSpeed(ship.unladenMass, ship.speed, $scope.th.c, ship.pipSpeed)['4 Pips']; updateRetrofitCosts(); win.triggerHandler('pwrchange'); } diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js index 80156f23..e89187a4 100755 --- a/app/js/shipyard/factory-ship.js +++ b/app/js/shipyard/factory-ship.js @@ -1,4 +1,4 @@ -angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'calcTotalRange', 'lodash', 'ArmourMultiplier', function(Components, calcShieldStrength, calcJumpRange, calcTotalRange, _, ArmourMultiplier) { +angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'calcTotalRange', 'calcSpeed', 'lodash', 'ArmourMultiplier', function(Components, calcShieldStrength, calcJumpRange, calcTotalRange, calcSpeed, _, ArmourMultiplier) { /** * Returns the power usage type of a slot and it's particular component @@ -159,6 +159,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', this.updatePower(); this.updateJumpStats(); this.updateShieldStrength(); + this.updateTopSpeed(); } }; @@ -375,6 +376,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', if (powerChange) { this.updatePower(); } + this.updateTopSpeed(); this.updateJumpStats(); this.updateShieldStrength(); } @@ -395,6 +397,10 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', this.powerDeployed = prevDeployed; }; + Ship.prototype.updateTopSpeed = function() { + this.topSpeed = calcSpeed(this.unladenMass + this.fuelCapacity, this.speed, this.common[1].c, this.pipSpeed)['4 Pips']; + }; + Ship.prototype.updateShieldStrength = function() { var sgSlot = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any this.shieldStrength = sgSlot && sgSlot.enabled ? calcShieldStrength(this.hullMass, this.baseShieldStrength, sgSlot.c, this.shieldMultiplier) : 0; diff --git a/app/js/shipyard/module-shipyard.js b/app/js/shipyard/module-shipyard.js index 71c3ddb1..b8763405 100755 --- a/app/js/shipyard/module-shipyard.js +++ b/app/js/shipyard/module-shipyard.js @@ -204,7 +204,6 @@ angular.module('shipyard', ['ngLodash']) /** * Calculate the a ships shield strength based on mass, shield generator and shield boosters used. * - * @private * @param {number} mass Current mass of the ship * @param {number} shields Base Shield strength MJ for ship * @param {object} sg The shield generator used @@ -230,18 +229,20 @@ angular.module('shipyard', ['ngLodash']) } }) /** - * Calculate the a ships speed based on mass, and thrusters. Currently Innacurate / Incomplete :( + * Calculate the a ships speed based on mass, and thrusters. * - * @private * @param {number} mass Current mass of the ship * @param {number} baseSpeed Base speed m/s for ship - * @param {number} baseBoost Base boost m/s for ship - * @param {object} thrusters The shield generator used - * @return {object} Approximate speed and boost speed in m/s + * @param {object} thrusters The Thrusters used + * @param {number} pipSpeed Speed pip multiplier + * @return {object} Approximate speed by pips */ - .value('calcSpeed', function(mass, baseSpeed, baseBoost) { //, thrusters) { - //var speed = baseSpeed * (1 + ((thrusters.optmass / mass) * 0.1 ) ); // TODO: find thruser coefficient(s) - //var boost = baseBoost * (1 + ((thrusters.optmass / mass) * 0.1 ) ); + .value('calcSpeed', function(mass, baseSpeed, thrusters, pipSpeed) { + var speed = baseSpeed * ((1 - thrusters.M) + (thrusters.M * Math.pow(3 - (2 * Math.max(0.5, mass / thrusters.optmass)), thrusters.P))); - return { boost: baseSpeed, speed: baseBoost }; + return { + '0 Pips': speed * (1 - (pipSpeed * 4)), + '2 Pips': speed * (1 - (pipSpeed * 2)), + '4 Pips': speed + }; }); diff --git a/app/views/page-outfit.html b/app/views/page-outfit.html index 68a2fb73..22ae0af7 100644 --- a/app/views/page-outfit.html +++ b/app/views/page-outfit.html @@ -63,7 +63,7 @@