diff --git a/app/js/controllers/controller-outfit.js b/app/js/controllers/controller-outfit.js index 3848778a..dff4fed9 100755 --- a/app/js/controllers/controller-outfit.js +++ b/app/js/controllers/controller-outfit.js @@ -232,8 +232,8 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', ' updateState(Serializer.fromShip(ship.useCommon(rating))); }; - $scope.useHardpoint = function(group, mount) { - updateState(Serializer.fromShip(ship.useWeapon(group, mount))); + $scope.useHardpoint = function(group, mount, missile) { + updateState(Serializer.fromShip(ship.useWeapon(group, mount, missile))); }; $scope.useUtility = function(group, rating) { @@ -260,6 +260,19 @@ 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; + ship.setSlotEnabled(slot, chargeCap <= ship.shieldStrength); // 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. diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js index a93662a5..faaf8f9f 100755 --- a/app/js/shipyard/factory-ship.js +++ b/app/js/shipyard/factory-ship.js @@ -557,14 +557,18 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', return this; }; - Ship.prototype.useWeapon = function(group, mount) { + Ship.prototype.useWeapon = function(group, mount, missile) { 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 { + component = Components.findHardpoint(group, size, null, null, mount, missile); + if (component) { + this.use(hps[i], component.id, component); + break; + } + } while (!component && (--size > 0)); } } return this; diff --git a/app/views/page-outfit.html b/app/views/page-outfit.html index 95d1b10c..1ccee8f4 100644 --- a/app/views/page-outfit.html +++ b/app/views/page-outfit.html @@ -216,6 +216,7 @@