diff --git a/app/js/controllers/controller-outfit.js b/app/js/controllers/controller-outfit.js
index f64c54fa..1d9e5ee8 100755
--- a/app/js/controllers/controller-outfit.js
+++ b/app/js/controllers/controller-outfit.js
@@ -158,6 +158,8 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
* @param {object} item The component being toggled
*/
$scope.togglePwr = function(item) {
+ // Update serialize code
+ // updateState();
item.enabled = !item.enabled;
ship.updateTotals();
};
diff --git a/app/js/directives/directive-slider.js b/app/js/directives/directive-slider.js
index 7d9289e9..2a5e72b6 100644
--- a/app/js/directives/directive-slider.js
+++ b/app/js/directives/directive-slider.js
@@ -53,7 +53,7 @@ angular.module('app').directive('slider', ['$window', function ($window) {
.tickSize(0)
.tickPadding(12))
.select(".domain");
- lbl.attr('x', w + 20).text(fmt(val) + ' ' + unit + ' (' + pct(val / scope.max) + ')');
+ lbl.attr('x', w + 20);
slider.call(brush.extent([val, val])).call(brush.event);
slider.selectAll(".extent,.resize").remove();
}
@@ -64,7 +64,7 @@ angular.module('app').directive('slider', ['$window', function ($window) {
val = x.invert(d3.mouse(this)[0]);
brush.extent([val, val]);
}
- lbl.text(fmt(val) + ' ' + unit + ' (' + pct(val / scope.max) + ')');
+ lbl.text(fmt(val) + ' ' + unit + ' ' + pct(val / scope.max));
scope.change({val: val});
handle.attr("cx", x(val));
filled.attr("d", "M0,0V0H" + x(val) + "V0");
diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js
index eb6319bf..e5a653e3 100755
--- a/app/js/shipyard/factory-ship.js
+++ b/app/js/shipyard/factory-ship.js
@@ -67,27 +67,44 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
*/
Ship.prototype.updateTotals = function() {
var c = _.reduce(this.common, optsSum, {cost: 0, power: 0, mass: 0});
- var i = _.reduce(this.internal, optsSum, {cost: 0, power: 0, mass: 0, capacity: 0, armouradd: 0});
+ var i = _.reduce(this.internal, optsSum, {cost: 0, power: 0, mass: 0, fuel: 0, cargo: 0, armouradd: 0});
var h = _.reduce(this.hardpoints, hpSum, {cost: 0, active: 0, passive: 0, mass: 0, shieldmul: 1});
var fsd = this.common[2].c; // Frame Shift Drive;
var sgSI = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any
this.totalCost = c.cost + i.cost + h.cost + (this.incCost? this.cost : 0) + (this.bulkheads.incCost? this.bulkheads.c.cost : 0);
this.unladenMass = c.mass + i.mass + h.mass + this.mass + this.bulkheads.c.mass;
- this.powerAvailable = this.common[0].c.pGen; // Power Plant
- this.fuelCapacity = this.common[6].c.capacity;
- this.maxMass = this.common[1].c.maxmass; // Thrusters Max Mass
- this.cargoCapacity = i.capacity;
+ this.powerAvailable = this.common[0].c.pGen; // Power Plant
+ this.fuelCapacity = this.common[6].c.capacity + i.fuel; // Fuel Tank + Internal Fuel Tanks
+ this.maxMass = this.common[1].c.maxmass; // Thrusters Max Mass
+ this.cargoCapacity = i.cargo;
this.ladenMass = this.unladenMass + this.cargoCapacity + this.fuelCapacity;
this.powerRetracted = c.power + i.power + h.passive + (this.cargoScoop.enabled? this.cargoScoop.c.power : 0);
this.powerDeployed = this.powerRetracted + h.active;
this.armourAdded = i.armouradd;
this.shieldMultiplier = h.shieldmul;
- this.unladenJumpRange = calcJumpRange(this.unladenMass + fsd.maxfuel, fsd); // Include fuel weight for jump
- this.ladenJumpRange = calcJumpRange(this.ladenMass, fsd);
this.shieldStrength = sgSI != -1? calcShieldStrength(this.mass, this.shields, this.internal[sgSI].c, this.shieldMultiplier) : 0;
this.armourTotal = this.armourAdded + this.armour;
- // TODO: shield recharge rate based pips, shield generator, power distributor
+
+ // Jump Range and total range calculations
+ var fuelRemaining = this.fuelCapacity % fsd.maxfuel; // Fuel left after making N max jumps
+ var jumps = this.fuelCapacity / fsd.maxfuel;
+ this.unladenRange = calcJumpRange(this.unladenMass + fsd.maxfuel, fsd, this.fuelCapacity); // Include fuel weight for jump
+ this.fullTankRange = calcJumpRange(this.unladenMass + this.fuelCapacity, fsd, this.fuelCapacity); // Full Tanke
+ this.ladenRange = calcJumpRange(this.ladenMass, fsd, this.fuelCapacity);
+ this.maxJumpCount = Math.ceil(jumps); // Number of full fuel jumps + final jump to empty tank
+
+ // Going backwards, start with the last jump using the remaining fuel
+ this.unladenTotalRange = fuelRemaining > 0? calcJumpRange(this.unladenMass + fuelRemaining, fsd, fuelRemaining): 0;
+ this.ladenTotalRange = fuelRemaining > 0? calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd, fuelRemaining): 0;
+
+ // For each max fuel jump, calculate the max jump range based on fuel left in the tank
+ for (var j = 0, jumps = Math.floor(jumps); j < jumps; j++) {
+ fuelRemaining += fsd.maxfuel;
+ this.unladenTotalRange += calcJumpRange(this.unladenMass + fuelRemaining, fsd);
+ this.ladenTotalRange += calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd);
+ }
+
// TODO: armor bonus / damage reduction for bulkheads
// TODO: Damage / DPS total (for all weapons)
};
@@ -106,7 +123,12 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
sum.cost += (slot.incCost && c.cost)? c.cost : 0;
sum.power += (slot.enabled && c.power)? c.power : 0;
sum.mass += c.mass || 0;
- sum.capacity += c.capacity || 0;
+ if (c.grp == 'ft') { // Internal Fuel Tank
+ sum.fuel += c.capacity;
+ }
+ else if (c.grp == 'cr') { // Internal Cargo Rack
+ sum.cargo += c.capacity;
+ }
sum.armouradd += c.armouradd || 0;
}
return sum;
diff --git a/app/js/shipyard/module-shipyard.js b/app/js/shipyard/module-shipyard.js
index a1826e7a..c79956c8 100755
--- a/app/js/shipyard/module-shipyard.js
+++ b/app/js/shipyard/module-shipyard.js
@@ -21,6 +21,7 @@ angular.module('shipyard', ['ngLodash'])
])
.value('internalGroupMap', {
fs:'Fuel Scoop',
+ ft:'Fuel Tank',
sc:'Scanners',
am:'Auto Field-Maintenance Unit',
cr:'Cargo Racks',
@@ -106,7 +107,7 @@ angular.module('shipyard', ['ngLodash'])
},
{ // 4
title: 'Jump Range',
- props: ['unladenJumpRange', 'ladenJumpRange'],
+ props: ['unladenRange', 'ladenRange'],
lbls: ['Unladen', 'Laden'],
unit: 'LY',
fmt: 'fRound'
diff --git a/app/views/page-outfit.html b/app/views/page-outfit.html
index c9a6964f..1804a085 100755
--- a/app/views/page-outfit.html
+++ b/app/views/page-outfit.html
@@ -24,24 +24,25 @@
Size
- Maneouverability
+ Agility
+ Speed
+ Boost
+ Armour
+ Shields
Mass
Cargo
Fuel
- Armour
- Shields
- Power
- Jump Range
+ Jump Range
+ Total Range
-
@@ -51,22 +52,24 @@
Agility
- Speed
- Boost
Unladen
Laden
- Retracted
- Deployed
- Unladen
+ Max
+ Full Tank
+ Laden
+ Jumps
+ Unladen
Laden