Additional auto-fill for SCB and other weapons

This commit is contained in:
Kevin Chang
2015-10-07 19:43:39 -07:00
parent 610ded2f83
commit b9fc114e02
3 changed files with 71 additions and 4 deletions

View File

@@ -260,6 +260,21 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
updateState(Serializer.fromShip(ship));
};
$scope.fillWithCells = function() {
var chargeCap = 0; // Capacity of single activation
ship.internal.forEach(function(slot) {
var id = Components.findInternalId('scb', slot.maxClass, 'A');
if ((!slot.c || (slot.c.grp != 'sg' && slot.c.grp != 'psg')) && (!slot.eligible || slot.eligible.scb)) { // Check eligibility because of Orca, don't overwrite generator
ship.use(slot, id, Components.internal(id));
chargeCap += Components.internal(id).recharge;
if (chargeCap >= ship.shieldStrength) {
ship.setSlotEnabled(slot, false); // Don't waste cell capacity on overcharge
}
}
});
updateState(Serializer.fromShip(ship));
};
/**
* Fill all internal slots with Cargo Racks, and optmize internal components.
* Hardpoints are not altered.

View File

@@ -561,10 +561,18 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
var hps = this.hardpoints;
for (var i = hps.length; i--; ) {
if (hps[i].maxClass) {
var component = Components.findHardpoint(group, hps[i].maxClass, null, null, mount);
if (component) {
this.use(hps[i], component.id, component);
}
var size = hps[i].maxClass, component;
do {
if (group == 'mr') {
component = Components.findHardpoint(group, size, null, null, 'F', mount);
} else {
component = Components.findHardpoint(group, size, null, null, mount);
}
if (component) {
this.use(hps[i], component.id, component);
break;
}
} while (!component && (--size > 0));
}
}
return this;