Adding internal fuel tanks, jump range tweaks

This commit is contained in:
Colin McLeod
2015-06-05 21:14:29 -07:00
parent a5015b243b
commit 827fb3c97a
6 changed files with 113 additions and 33 deletions

View File

@@ -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();
};

View File

@@ -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");

View File

@@ -67,7 +67,7 @@ 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
@@ -75,19 +75,36 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
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.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.capacity;
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;

View File

@@ -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'

View File

@@ -24,24 +24,25 @@
<thead>
<tr class="main">
<th rowspan="2">Size</th>
<th colspan="3">Maneouverability</th>
<th rowspan="2">Agility</th>
<th rowspan="2">Speed</th>
<th rowspan="2">Boost</th>
<th rowspan="2">Armour</th>
<th rowspan="2">Shields</th>
<th colspan="2">Mass</th>
<th rowspan="2">Cargo</th>
<th rowspan="2">Fuel</th>
<th rowspan="2">Armour</th>
<th rowspan="2">Shields</th>
<th colspan="2">Power</th>
<th colspan="2">Jump Range</th>
<th colspan="3">Jump Range</th>
<th colspan="3">Total Range</th>
</tr>
<tr>
<th>Agility</th>
<th>Speed</th>
<th>Boost</th>
<th class="lft">Unladen</th>
<th>Laden</th>
<th class="lft">Retracted</th>
<th>Deployed</th>
<th class="lft">Unladen</th>
<th class="lft">Max</th>
<th>Full Tank</th>
<th>Laden</th>
<th class="lft">Jumps</th>
<th>Unladen</th>
<th>Laden</th>
</tr>
</thead>
@@ -51,22 +52,24 @@
<td>{{ship.agility}}/10</td>
<td>{{fRound(ship.speed)}} <u>m/s</u></td>
<td>{{fRound(ship.boost)}} <u>m/s</u></td>
<td>{{ship.armourTotal}} <span ng-if="ship.armourAdded">({{ship.armour}} + {{ship.armourAdded}})</span></td>
<td>{{fRound(ship.shieldStrength)}} <u>Mj</u> <span ng-if="ship.shieldMultiplier > 1">({{fRPct(ship.shieldMultiplier)}})</span></td>
<td>{{fRound(ship.unladenMass)}} <u>T</u></td>
<td>{{fRound(ship.ladenMass)}} <u>T</u></td>
<td>{{fRound(ship.cargoCapacity)}} <u>T</u></td>
<td>{{fRound(ship.fuelCapacity)}} <u>T</u></td>
<td>{{ship.armourTotal}} <span ng-if="ship.armourAdded">({{ship.armour}} + {{ship.armourAdded}})</span></td>
<td>{{fRound(ship.shieldStrength)}} <u>Mj</u> <span ng-if="ship.shieldMultiplier > 1">({{fRPct(ship.shieldMultiplier)}})</span></td>
<td>{{fPwr(ship.powerRetracted)}} <u>MW ({{fPct(ship.powerRetracted/ship.powerAvailable)}})</u></td>
<td>{{fPwr(ship.powerDeployed)}} <u>MW ({{fPct(ship.powerDeployed/ship.powerAvailable)}})</u></td>
<td>{{fRound(ship.unladenJumpRange)}} <u>LY</u></td>
<td>{{fRound(ship.ladenJumpRange)}} <u>LY</u></td>
<td>{{fRound(ship.unladenRange)}} <u>LY</u></td>
<td>{{fRound(ship.fullTankRange)}} <u>LY</u></td>
<td>{{fRound(ship.ladenRange)}} <u>LY</u></td>
<td>{{fRound(ship.maxJumpCount)}}</td>
<td>{{fRound(ship.unladenTotalRange)}} <u>LY</u></td>
<td>{{fRound(ship.ladenTotalRange)}} <u>LY</u></td>
</tr>
</tbody>
</table>
</div>
<div id="standard" class="slot-group l">
<div id="standard" class="slot-group">
<h1>Standard</h1>
<div class="slot" ng-click="selectSlot($event, ship.bulkheads)" ng-class="{selected: selectedSlot==ship.bulkheads}">
<div class="details">
@@ -160,7 +163,7 @@
</div>
</div>
<div id="hardpoints" class="slot-group l">
<div id="hardpoints" class="slot-group">
<h1>HardPoints</h1>
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '!0'}" ng-click="selectSlot($event, h)" ng-class="{selected: selectedSlot==h}">
<div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="hgMap[h.c.grp]"></div>
@@ -170,7 +173,7 @@
</div>
</div>
<div id="utility" class="slot-group l">
<div id="utility" class="slot-group">
<h1>Utility Mounts</h1>
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '0'}" ng-click="selectSlot($event, h)" ng-class="{selected: selectedSlot==h}">
<div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="hgMap[h.c.grp]"></div>
@@ -180,7 +183,7 @@
</div>
</div>
<div id="internal" class="slot-group l">
<div id="internal" class="slot-group">
<h1>Internal Compartments</h1>
<div class="slot" ng-repeat="i in ship.internal" ng-click="selectSlot($event, i)" ng-class="{selected: selectedSlot==i}">
<div slot-internal class="details" slot="i" lbl="igMap[i.c.grp]" ft="ft"></div>

View File

@@ -0,0 +1,52 @@
{
"Fuel Tank": [
{
"id": "F1",
"grp": "ft",
"class": 1,
"rating": "C",
"cost": 1000,
"capacity": 2
},
{
"id": "F2",
"grp": "ft",
"class": 2,
"rating": "C",
"cost": 3750,
"capacity": 4
},
{
"id": "F3",
"grp": "ft",
"class": 3,
"rating": "C",
"cost": 7063,
"capacity": 8
},
{
"id": "F4",
"grp": "ft",
"class": 4,
"rating": "C",
"cost": 24734,
"capacity": 16
},
{
"id": "F5",
"grp": "ft",
"class": 5,
"rating": "C",
"cost": 97754,
"capacity": 32
},
{
"id": "F6",
"grp": "ft",
"class": 6,
"rating": "C",
"cost": 341577,
"capacity": 64
}
]
}