Merge pull request #107 from sf302/master

Reload costs refinements
This commit is contained in:
Colin McLeod
2015-10-14 00:15:43 -07:00
6 changed files with 49 additions and 17 deletions

View File

@@ -40,8 +40,8 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
$scope.retroPredicate = 'netCost'; $scope.retroPredicate = 'netCost';
$scope.costDesc = true; $scope.costDesc = true;
$scope.costPredicate = 'c.cost'; $scope.costPredicate = 'c.cost';
$scope.ammoDesc = false; $scope.ammoDesc = true;
$scope.ammoPredicate = 'ammoName'; $scope.ammoPredicate = 'ammoUnitCost';
$scope.costTab = Persist.getCostTab() || 'costs'; $scope.costTab = Persist.getCostTab() || 'costs';
if ($scope.savedCode) { if ($scope.savedCode) {
@@ -461,6 +461,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
$scope.fuelChange = function(fuel) { $scope.fuelChange = function(fuel) {
$scope.fuel = fuel; $scope.fuel = fuel;
updateAmmoCosts();
win.triggerHandler('render'); win.triggerHandler('render');
}; };
@@ -555,29 +556,32 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
function updateAmmoCosts() { function updateAmmoCosts() {
var costs = $scope.ammoList = []; var costs = $scope.ammoList = [];
var total = 0, i, l, item; var total = 0, i, l, item, q, limpets = 0, scoop = false;
for (var g in { common: 1, internal: 1, hardpoints: 1 }) { for (var g in { common: 1, internal: 1, hardpoints: 1 }) {
var slotGroup = ship[g]; var slotGroup = ship[g];
for (i = 0, l = slotGroup.length; i < l; i++) { for (i = 0, l = slotGroup.length; i < l; i++) {
var q = 0;
if (slotGroup[i].id) { if (slotGroup[i].id) {
//special cases needed for fuel, SCB and AFMU since they don't use standard ammo/clip //special cases needed for SCB, AFMU, and limpet controllers since they don't use standard ammo/clip
if (slotGroup[i].c.grp == 'ft') { q = 0;
q = slotGroup[i].c.capacity; switch (slotGroup[i].c.grp) {
slotGroup[i].c.ammocost = 50; case 'fs': //skip fuel calculation if scoop present
} scoop = true;
if (slotGroup[i].c.grp == 'scb') { break;
q = slotGroup[i].c.cells; case 'scb':
} q = slotGroup[i].c.cells;
if (slotGroup[i].c.grp == 'am') { break;
q = slotGroup[i].c.ammo; case 'am':
q = slotGroup[i].c.ammo;
break;
case 'fx': case 'hb': case 'cc': case 'pc':
limpets = ship.cargoCapacity;
break;
default:
q = slotGroup[i].c.clip + slotGroup[i].c.ammo;
} }
//calculate ammo costs only if a cost is specified //calculate ammo costs only if a cost is specified
if (slotGroup[i].c.ammocost > 0) { if (slotGroup[i].c.ammocost > 0) {
if (q == 0) {
q = slotGroup[i].c.clip + slotGroup[i].c.ammo;
}
item = { item = {
ammoClassRating: slotGroup[i].c.class + slotGroup[i].c.rating, ammoClassRating: slotGroup[i].c.class + slotGroup[i].c.rating,
ammoName: slotGroup[i].c.name || slotGroup[i].c.grp, ammoName: slotGroup[i].c.name || slotGroup[i].c.grp,
@@ -591,6 +595,29 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
} }
} }
} }
//limpets if controllers exist and cargo space available
if (limpets > 0) {
item = {
ammoName: 'limpets',
ammoMax: ship.cargoCapacity,
ammoUnitCost: 101,
ammoTotalCost: ship.cargoCapacity * 101
};
costs.push(item);
total += item.ammoTotalCost;
}
//calculate refuel costs if no scoop present
if (!scoop) {
item = {
ammoName: 'fuel',
ammoMax: $scope.fuel,
ammoUnitCost: 50,
ammoTotalCost: $scope.fuel * 50
};
costs.push(item);
total += item.ammoTotalCost;
}
$scope.ammoTotal = total; $scope.ammoTotal = total;
} }

View File

@@ -115,6 +115,7 @@ angular.module('app').config(['$translateProvider', 'localeFormatProvider', func
laden: 'Beladen', laden: 'Beladen',
language: 'Sprache', language: 'Sprache',
large: 'Groß', large: 'Groß',
limpets: 'Krallen',
ls: 'Lebenserhaltung', ls: 'Lebenserhaltung',
'Lightweight Alloy': 'Leichte Legierung', 'Lightweight Alloy': 'Leichte Legierung',
'lock factor': 'Massensperrefaktor', 'lock factor': 'Massensperrefaktor',

View File

@@ -105,6 +105,7 @@ angular.module('app').config(['$translateProvider', function($translateProvider)
laden: 'laden', laden: 'laden',
language: 'language', language: 'language',
large: 'large', large: 'large',
'limpets': 'Limpets',
ls: 'life support', ls: 'life support',
'Lightweight Alloy': 'Lightweight Alloy', 'Lightweight Alloy': 'Lightweight Alloy',
'lock factor': 'lock factor', 'lock factor': 'lock factor',

View File

@@ -115,6 +115,7 @@ angular.module('app').config(['$translateProvider', 'localeFormatProvider', func
'large': 'Grande', 'large': 'Grande',
'ls': 'Soporte vital', 'ls': 'Soporte vital',
'Lightweight Alloy': 'Aleaci\u00f3n ligera', 'Lightweight Alloy': 'Aleaci\u00f3n ligera',
'limpets': 'Drones',
'lock factor': 'factor de bloqueo', 'lock factor': 'factor de bloqueo',
'mass': 'Masa', 'mass': 'Masa',
'max': 'm\u00e1x', 'max': 'm\u00e1x',

View File

@@ -106,6 +106,7 @@ angular.module('app').config(['$translateProvider', 'localeFormatProvider', func
large: 'large', large: 'large',
ls: 'Systèmes de survie', ls: 'Systèmes de survie',
'Lightweight Alloy': 'alliage léger', 'Lightweight Alloy': 'alliage léger',
'limpets': 'Patelles',
'lock factor': 'facteur inhibition de masse', 'lock factor': 'facteur inhibition de masse',
LS: 'SL', LS: 'SL',
LY: 'AL', LY: 'AL',

View File

@@ -124,6 +124,7 @@ angular.module('app').config(['$translateProvider', 'localeFormatProvider', func
large: 'большой', large: 'большой',
ls: 'Система жизнеобеспечения', ls: 'Система жизнеобеспечения',
'Lightweight Alloy': 'Легкий сплав', 'Lightweight Alloy': 'Легкий сплав',
'limpets': 'Дроны',
'lock factor': 'Масс. блок', 'lock factor': 'Масс. блок',
LS: 'Св.сек', LS: 'Св.сек',
LY: 'Св.лет', LY: 'Св.лет',