Shortcut to A-rated common components and shield generator

This commit is contained in:
kchang
2015-07-28 23:21:46 -07:00
parent b850695715
commit 82c5460936
2 changed files with 29 additions and 0 deletions

View File

@@ -174,6 +174,32 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
}
};
/**
* Strip ship to A-class and A-class shield generator.
*/
$scope.aRatedBuild = function() {
ship.buildWith(data.defaults); // Reset build to default -- lazy hack to find shield slot
var sgSlot = 0;
var sgId = 0;
ship.internal.forEach(function(slot) {
// TODO: equip biggest A-rated shield in highest slot instead
if (slot.c && (slot.c.grp == 'sg')) {
sgSlot = ship.internal.indexOf(slot);
// Dirty hack using char decrement to get to A rated shield from default E
sgId = slot.c.id.charAt(0) + String.fromCharCode(slot.c.id.charCodeAt(1) - 4);
}
});
for (var i = 0, l = ship.common.length - 1; i < l; i++) { // All except Fuel Tank
var id = ship.common[i].maxClass + 'A';
ship.use(ship.common[i], id, Components.common(i, id));
}
ship.hardpoints.forEach(function(slot) { ship.use(slot, null, null); });
ship.internal.forEach(function(slot) { ship.use(slot, null, null); });
ship.use(ship.internal[sgSlot], sgId, Components.internal(sgId));
ship.useBulkhead(0);
updateState(Serializer.fromShip(ship));
};
/**
* Strip ship to D-class and no other components.
*/

View File

@@ -16,6 +16,9 @@
<button ui-sref="outfit({shipId: ship.id,code:null, bn: buildName})" ng-disabled="!code">
<svg class="icon lg"><use xlink:href="#switch"></use></svg><span class="button-lbl">Reset</span>
</button>
<button ng-click="aRatedBuild()">
<svg class="icon lg"><use xlink:href="#cogs"></use></svg><span class="button-lbl">A-Rated</span>
</button>
<button ng-click="stripBuild()">
<svg class="icon lg"><use xlink:href="#feather"></use></svg><span class="button-lbl">Low-Weight</span>
</button>