mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 14:33:22 +00:00
Merge pull request #102 from sf302/master
Additional auto-fill for SCB and other weapons
This commit is contained in:
@@ -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) {
|
||||
@@ -260,6 +260,19 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
||||
updateState(Serializer.fromShip(ship));
|
||||
};
|
||||
|
||||
$scope.fillWithCells = function() {
|
||||
var chargeCap = 0; // Capacity of single activation
|
||||
ship.internal.forEach(function(slot) {
|
||||
var id = Components.findInternalId('scb', slot.maxClass, 'A');
|
||||
if ((!slot.c || (slot.c.grp != 'sg' && slot.c.grp != 'psg')) && (!slot.eligible || slot.eligible.scb)) { // Check eligibility because of Orca, don't overwrite generator
|
||||
ship.use(slot, id, Components.internal(id));
|
||||
chargeCap += Components.internal(id).recharge;
|
||||
ship.setSlotEnabled(slot, chargeCap <= ship.shieldStrength); // Don't waste cell capacity on overcharge
|
||||
}
|
||||
});
|
||||
updateState(Serializer.fromShip(ship));
|
||||
};
|
||||
|
||||
/**
|
||||
* Fill all internal slots with Cargo Racks, and optmize internal components.
|
||||
* Hardpoints are not altered.
|
||||
|
||||
@@ -557,14 +557,18 @@ 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 component = Components.findHardpoint(group, hps[i].maxClass, null, null, mount);
|
||||
if (component) {
|
||||
this.use(hps[i], component.id, component);
|
||||
}
|
||||
var size = hps[i].maxClass, component;
|
||||
do {
|
||||
component = Components.findHardpoint(group, size, null, null, mount, missile);
|
||||
if (component) {
|
||||
this.use(hps[i], component.id, component);
|
||||
break;
|
||||
}
|
||||
} while (!component && (--size > 0));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -216,6 +216,7 @@
|
||||
<ul>
|
||||
<li class="lc" ng-click="emptyInternal()" translate="empty all"></li>
|
||||
<li class="lc" ng-click="fillWithCargo()" translate="cargo"></li>
|
||||
<li class="lc" ng-click="fillWithCells()" translate="scb"></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -255,6 +256,18 @@
|
||||
<li class="c" ng-click="useHardpoint('bl','G')"><svg class="icon lg"><use xlink:href="#mount-G"></use></svg></li>
|
||||
<li class="c" ng-click="useHardpoint('bl','T')"><svg class="icon lg"><use xlink:href="#mount-T"></use></svg></li>
|
||||
</ul>
|
||||
<div class="select-group cap" translate="mc"></div>
|
||||
<ul>
|
||||
<li class="c" ng-click="useHardpoint('mc','F')"><svg class="icon lg"><use xlink:href="#mount-F"></use></svg></li>
|
||||
<li class="c" ng-click="useHardpoint('mc','G')"><svg class="icon lg"><use xlink:href="#mount-G"></use></svg></li>
|
||||
<li class="c" ng-click="useHardpoint('mc','T')"><svg class="icon lg"><use xlink:href="#mount-T"></use></svg></li>
|
||||
</ul>
|
||||
<div class="select-group cap" translate="c"></div>
|
||||
<ul>
|
||||
<li class="c" ng-click="useHardpoint('c','F')"><svg class="icon lg"><use xlink:href="#mount-F"></use></svg></li>
|
||||
<li class="c" ng-click="useHardpoint('c','G')"><svg class="icon lg"><use xlink:href="#mount-G"></use></svg></li>
|
||||
<li class="c" ng-click="useHardpoint('c','T')"><svg class="icon lg"><use xlink:href="#mount-T"></use></svg></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '!0'}" ng-click="selectSlot($event, h)" context-menu="select('h', h, $event, 'empty')" ng-class="{selected: selectedSlot==h}">
|
||||
|
||||
Reference in New Issue
Block a user