Less hacks to get the same thing done

This commit is contained in:
Kevin Chang
2015-10-07 20:06:04 -07:00
parent 1d4b046723
commit f807f4222f
3 changed files with 6 additions and 10 deletions

View File

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

View File

@@ -557,17 +557,13 @@ 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 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);
}
component = Components.findHardpoint(group, size, null, null, mount, missile);
if (component) {
this.use(hps[i], component.id, component);
break;