Adding more outiftting sub section menu options

This commit is contained in:
Colin McLeod
2015-10-07 02:14:45 -07:00
parent f42dc481df
commit df7ef0fbdb
4 changed files with 67 additions and 10 deletions

View File

@@ -230,11 +230,19 @@ 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.useUtility = function(group, rating) {
updateState(Serializer.fromShip(ship.useUtility(group, rating)));
};
$scope.emptyInternal = function() {
updateState(Serializer.fromShip(ship.emptyInternal()));
};
$scope.emptyWeapons = function() {
$scope.emptyHardpoints = function() {
updateState(Serializer.fromShip(ship.emptyWeapons()));
};

View File

@@ -547,6 +547,29 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
return this;
};
Ship.prototype.useUtility = function(group, rating) {
var component = Components.findHardpoint(group, 0, rating);
for (var i = this.hardpoints.length; i--; ) {
if (!this.hardpoints[i].maxClass) {
this.use(this.hardpoints[i], component.id, component);
}
}
return this;
};
Ship.prototype.useWeapon = function(group, mount) {
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);
}
}
}
return this;
};
/**
* Will change the priority of the specified slot if the new priority is valid
* @param {object} slot The slot to be updated

View File

@@ -97,7 +97,7 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
*
* @param {string} groupName [Optional] Full name or abbreviated name for component group
* @param {integer} clss Component Class
* @param {string} rating Component Rating
* @param {string} rating [Optional] Component Rating
* @param {string} name [Optional] Long/unique name for component -e.g. 'Heat Sink Launcher'
* @param {string} mode Mount mode/type - [F]ixed, [G]imballed, [T]urret
* @param {string} missile [Optional] Missile type - [D]umbfire, [S]eeker
@@ -122,7 +122,7 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
for (var g in groups) {
var group = groups[g];
for (var i = 0, l = group.length; i < l; i++) {
if (group[i].class == clss && group[i].rating == rating && group[i].mode == mode
if (group[i].class == clss && (!rating || group[i].rating == rating) && group[i].mode == mode
&& ((!name && !group[i].name) || group[i].name == name)
&& ((!missile && !group[i].missile) || group[i].missile == missile)
) {