From df7ef0fbdb286110d2699ca65c4bf4f4da53b5bb Mon Sep 17 00:00:00 2001 From: Colin McLeod Date: Wed, 7 Oct 2015 02:14:45 -0700 Subject: [PATCH] Adding more outiftting sub section menu options --- app/js/controllers/controller-outfit.js | 10 ++++++- app/js/shipyard/factory-ship.js | 23 ++++++++++++++ app/js/shipyard/service-components.js | 4 +-- app/views/page-outfit.html | 40 ++++++++++++++++++++----- 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/app/js/controllers/controller-outfit.js b/app/js/controllers/controller-outfit.js index da470450..749b08d7 100755 --- a/app/js/controllers/controller-outfit.js +++ b/app/js/controllers/controller-outfit.js @@ -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())); }; diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js index 40d040ca..a93662a5 100755 --- a/app/js/shipyard/factory-ship.js +++ b/app/js/shipyard/factory-ship.js @@ -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 diff --git a/app/js/shipyard/service-components.js b/app/js/shipyard/service-components.js index e6828353..b5d902b8 100755 --- a/app/js/shipyard/service-components.js +++ b/app/js/shipyard/service-components.js @@ -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) ) { diff --git a/app/views/page-outfit.html b/app/views/page-outfit.html index 34436e59..8f95ae20 100644 --- a/app/views/page-outfit.html +++ b/app/views/page-outfit.html @@ -99,12 +99,12 @@
@@ -228,14 +228,32 @@
-
+

{{'hardpoints' | translate}}

-
+
    -
  • +
  • +
+
+
    +
  • +
  • +
  • +
+
+
    +
  • +
  • +
  • +
+
+
    +
  • +
  • +
@@ -255,7 +273,15 @@
    -
  • +
  • +
+
+
    +
  • E
  • +
  • D
  • +
  • C
  • +
  • B
  • +
  • A