From bed81d26b2d6bdf3aced41dcc924931a2fd9d8b3 Mon Sep 17 00:00:00 2001 From: Kevin Chang Date: Thu, 8 Oct 2015 19:20:17 -0700 Subject: [PATCH] Alter auto-fill clobbering behavior for hardpoints --- app/js/controllers/controller-outfit.js | 8 ++++---- app/js/shipyard/factory-ship.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/js/controllers/controller-outfit.js b/app/js/controllers/controller-outfit.js index 9501d566..a7fdb062 100755 --- a/app/js/controllers/controller-outfit.js +++ b/app/js/controllers/controller-outfit.js @@ -232,12 +232,12 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', ' updateState(Serializer.fromShip(ship.useCommon(rating))); }; - $scope.useHardpoint = function(group, mount, missile) { - updateState(Serializer.fromShip(ship.useWeapon(group, mount, missile))); + $scope.useHardpoint = function(group, mount, clobber, missile) { + updateState(Serializer.fromShip(ship.useWeapon(group, mount, clobber, missile))); }; - $scope.useUtility = function(group, rating) { - updateState(Serializer.fromShip(ship.useUtility(group, rating))); + $scope.useUtility = function(group, rating, clobber) { + updateState(Serializer.fromShip(ship.useUtility(group, rating, clobber))); }; $scope.emptyInternal = function() { diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js index faaf8f9f..32f081c6 100755 --- a/app/js/shipyard/factory-ship.js +++ b/app/js/shipyard/factory-ship.js @@ -547,24 +547,24 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', return this; }; - Ship.prototype.useUtility = function(group, rating) { + Ship.prototype.useUtility = function(group, rating, clobber) { var component = Components.findHardpoint(group, 0, rating); for (var i = this.hardpoints.length; i--; ) { - if (!this.hardpoints[i].maxClass) { + if ((clobber || !this.hardpoints[i].c) && !this.hardpoints[i].maxClass) { this.use(this.hardpoints[i], component.id, component); } } return this; }; - Ship.prototype.useWeapon = function(group, mount, missile) { + Ship.prototype.useWeapon = function(group, mount, clobber, missile) { var hps = this.hardpoints; for (var i = hps.length; i--; ) { if (hps[i].maxClass) { var size = hps[i].maxClass, component; do { component = Components.findHardpoint(group, size, null, null, mount, missile); - if (component) { + if ((clobber || !hps[i].c) && component) { this.use(hps[i], component.id, component); break; }