A-rated uses largest eligible shield slot; dirty hacks rewritten

This commit is contained in:
Kevin Chang
2015-07-30 19:50:08 -07:00
parent 15616d112f
commit 69de209aba

View File

@@ -175,28 +175,23 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
};
/**
* Strip ship to A-class and A-class shield generator.
* Strip ship to A-class and biggest A-class shield generator with military bulkheads
*/
$scope.aRatedBuild = function() {
ship.buildWith(data.defaults); // Reset build to default -- lazy hack to find shield slot
var sgSlot = 0;
var sgId = 0;
ship.internal.forEach(function(slot) {
// TODO: equip biggest A-rated shield in highest slot instead
if (slot.c && (slot.c.grp == 'sg')) {
sgSlot = ship.internal.indexOf(slot);
// Dirty hack using char decrement to get to A rated shield from default E
sgId = slot.c.id.charAt(0) + String.fromCharCode(slot.c.id.charCodeAt(1) - 4);
}
});
for (var i = 0, l = ship.common.length - 1; i < l; i++) { // All except Fuel Tank
var id = ship.common[i].maxClass + 'A';
ship.use(ship.common[i], id, Components.common(i, id));
}
ship.hardpoints.forEach(function(slot) { ship.use(slot, null, null); });
ship.internal.forEach(function(slot) { ship.use(slot, null, null); });
ship.use(ship.internal[sgSlot], sgId, Components.internal(sgId));
ship.useBulkhead(0);
ship.internal.some(function(slot) {
if ('undefined' == typeof slot.eligible) { // Assuming largest slot can hold an eligible shield
var id = Components.findInternalId('Shield Generator', slot.maxClass, 'A');
ship.use(slot, id, Components.internal(id));
return true;
}
});
ship.useBulkhead(2);
updateState(Serializer.fromShip(ship));
};