mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
Merge pull request #104 from sf302/master
Hull reinforcement auto-fill, hardpoint clobber behavior tweak
This commit is contained in:
@@ -232,12 +232,12 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
||||
updateState(Serializer.fromShip(ship.useCommon(rating)));
|
||||
};
|
||||
|
||||
$scope.useHardpoint = function(group, mount, missile) {
|
||||
updateState(Serializer.fromShip(ship.useWeapon(group, mount, missile)));
|
||||
$scope.useHardpoint = function(group, mount, clobber, missile) {
|
||||
updateState(Serializer.fromShip(ship.useWeapon(group, mount, clobber, missile)));
|
||||
};
|
||||
|
||||
$scope.useUtility = function(group, rating) {
|
||||
updateState(Serializer.fromShip(ship.useUtility(group, rating)));
|
||||
$scope.useUtility = function(group, rating, clobber) {
|
||||
updateState(Serializer.fromShip(ship.useUtility(group, rating, clobber)));
|
||||
};
|
||||
|
||||
$scope.emptyInternal = function() {
|
||||
@@ -255,7 +255,9 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
||||
$scope.fillWithCargo = function() {
|
||||
ship.internal.forEach(function(slot) {
|
||||
var id = Components.findInternalId('cr', slot.maxClass, 'E');
|
||||
ship.use(slot, id, Components.internal(id));
|
||||
if (!slot.c) {
|
||||
ship.use(slot, id, Components.internal(id));
|
||||
}
|
||||
});
|
||||
updateState(Serializer.fromShip(ship));
|
||||
};
|
||||
@@ -264,7 +266,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
||||
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
|
||||
if (!slot.c && (!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
|
||||
@@ -273,6 +275,16 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
||||
updateState(Serializer.fromShip(ship));
|
||||
};
|
||||
|
||||
$scope.fillWithArmor = function() {
|
||||
ship.internal.forEach(function(slot) {
|
||||
var id = Components.findInternalId('hr', Math.min(slot.maxClass, 5), 'D'); // Hull reinforcements top out at 5D
|
||||
if (!slot.c) {
|
||||
ship.use(slot, id, Components.internal(id));
|
||||
}
|
||||
});
|
||||
updateState(Serializer.fromShip(ship));
|
||||
};
|
||||
|
||||
/**
|
||||
* Fill all internal slots with Cargo Racks, and optmize internal components.
|
||||
* Hardpoints are not altered.
|
||||
|
||||
@@ -547,24 +547,24 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
||||
return this;
|
||||
};
|
||||
|
||||
Ship.prototype.useUtility = function(group, rating) {
|
||||
Ship.prototype.useUtility = function(group, rating, clobber) {
|
||||
var component = Components.findHardpoint(group, 0, rating);
|
||||
for (var i = this.hardpoints.length; i--; ) {
|
||||
if (!this.hardpoints[i].maxClass) {
|
||||
if ((clobber || !this.hardpoints[i].c) && !this.hardpoints[i].maxClass) {
|
||||
this.use(this.hardpoints[i], component.id, component);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Ship.prototype.useWeapon = function(group, mount, missile) {
|
||||
Ship.prototype.useWeapon = function(group, mount, clobber, missile) {
|
||||
var hps = this.hardpoints;
|
||||
for (var i = hps.length; i--; ) {
|
||||
if (hps[i].maxClass) {
|
||||
var size = hps[i].maxClass, component;
|
||||
do {
|
||||
component = Components.findHardpoint(group, size, null, null, mount, missile);
|
||||
if (component) {
|
||||
if ((clobber || !hps[i].c) && component) {
|
||||
this.use(hps[i], component.id, component);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user