Alter auto-fill clobbering behavior for hardpoints

This commit is contained in:
Kevin Chang
2015-10-08 19:20:17 -07:00
parent 38b13fca27
commit bed81d26b2
2 changed files with 8 additions and 8 deletions

View File

@@ -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() {

View File

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