More logical limpet ammo display, fuel tied to slider

This commit is contained in:
Kevin Chang
2015-10-12 20:54:47 -07:00
parent d286dda07f
commit 20cce4dcda
6 changed files with 36 additions and 25 deletions

View File

@@ -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,20 +556,17 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
function updateAmmoCosts() { function updateAmmoCosts() {
var costs = $scope.ammoList = []; var costs = $scope.ammoList = [];
var controllers = []; var total = 0, i, l, item, q, limpets = 0, scoop = false;
var total = 0, i, l, item, q;
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++) {
if (slotGroup[i].id) { if (slotGroup[i].id) {
//special cases needed for fuel, SCB, AFMU, and limpet controllers 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
var isLimpet = false;
q = 0; q = 0;
switch (slotGroup[i].c.grp) { switch (slotGroup[i].c.grp) {
case 'ft': case 'fs': //skip fuel calculation if scoop present
q = slotGroup[i].c.capacity; scoop = true;
slotGroup[i].c.ammocost = 50;
break; break;
case 'scb': case 'scb':
q = slotGroup[i].c.cells; q = slotGroup[i].c.cells;
@@ -577,12 +575,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
q = slotGroup[i].c.ammo; q = slotGroup[i].c.ammo;
break; break;
case 'fx': case 'hb': case 'cc': case 'pc': case 'fx': case 'hb': case 'cc': case 'pc':
isLimpet = true; limpets = ship.cargoCapacity;
if (!ship.cargoCapacity) { //skip ammo costs if no cargo space for limpets
continue;
}
q = ship.cargoCapacity;
slotGroup[i].c.ammocost = 101;
break; break;
default: default:
q = slotGroup[i].c.clip + slotGroup[i].c.ammo; q = slotGroup[i].c.clip + slotGroup[i].c.ammo;
@@ -596,22 +589,35 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
ammoUnitCost: slotGroup[i].c.ammocost, ammoUnitCost: slotGroup[i].c.ammocost,
ammoTotalCost: q * slotGroup[i].c.ammocost ammoTotalCost: q * slotGroup[i].c.ammocost
}; };
if (isLimpet) { //add total limpet cost once and finalize costs entry later
controllers.push(item);
total += controllers.length == 1 ? item.ammoTotalCost : 0;
} else {
costs.push(item); costs.push(item);
total += item.ammoTotalCost; total += item.ammoTotalCost;
} }
} }
} }
} }
//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;
} }
q = Math.ceil(ship.cargoCapacity / controllers.length); //total fuel, or if slider isn't at max, use that value and only if scoop not present
for (i = 0; i < controllers.length; i++) { if (!scoop) {
controllers[i].ammoTotalCost = q * 101; q = $scope.fuel != ship.fuelCapacity ? $scope.fuel : ship.fuelCapacity;
controllers[i].ammoMax = (i == 0) && (q != ship.cargoCapacity / controllers.length) ? q-- : q; // handle rounding error with first controller item = {
costs.push(controllers[i]); ammoName: 'fuel',
ammoMax: q,
ammoUnitCost: 50,
ammoTotalCost: q * 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: 'Св.лет',