mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Refactor many variable names, adding detailed json dump and schema
This commit is contained in:
@@ -14,26 +14,27 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function(_) {
|
||||
this.hpClass = {};
|
||||
this.intClass = {};
|
||||
|
||||
for (var i = 0; i < components.common.length; i++) {
|
||||
var max = maxCommonArr[i];
|
||||
switch (i) {
|
||||
// Slots where component class must be equal to slot class
|
||||
case 3: // Life Support
|
||||
case 5: // Sensors
|
||||
this.common[i] = filter(components.common[i], max, max, this.mass);
|
||||
break;
|
||||
// Other slots can have a component of class lower than the slot class
|
||||
default:
|
||||
this.common[i] = filter(components.common[i], max, 0, this.mass);
|
||||
}
|
||||
}
|
||||
this.common[0] = filter(components.common[0], maxCommonArr[0], 0, mass); // Power Plant
|
||||
this.common[2] = filter(components.common[2], maxCommonArr[2], 0, mass); // FSD
|
||||
this.common[4] = filter(components.common[4], maxCommonArr[4], 0, mass); // Power Distributor
|
||||
this.common[6] = filter(components.common[6], maxCommonArr[6], 0, mass); // Fuel Tank
|
||||
|
||||
// Thrusters, filter components by class only (to show full list of ratings for that class)
|
||||
var minThrusterClass = _.reduce(components.common[1], function(minClass, thruster) {
|
||||
return (thruster.maxmass >= mass && thruster.class < minClass) ? thruster.class : minClass;
|
||||
}, maxCommonArr[1]);
|
||||
this.common[1] = filter(components.common[1], maxCommonArr[1], minThrusterClass, 0); // Thrusters
|
||||
|
||||
// Slots where component class must be equal to slot class
|
||||
this.common[3] = filter(components.common[3], maxCommonArr[3], maxCommonArr[3], 0); // Life Supprt
|
||||
this.common[5] = filter(components.common[5], maxCommonArr[5], maxCommonArr[5], mass); // Sensors
|
||||
|
||||
for (var h in components.hardpoints) {
|
||||
this.hardpoints[h] = filter(components.hardpoints[h], maxHardPoint, 0, this.mass);
|
||||
this.hardpoints[h] = filter(components.hardpoints[h], maxHardPoint, 0, mass);
|
||||
}
|
||||
|
||||
for (var g in components.internal) {
|
||||
this.internal[g] = filter(components.internal[g], maxInternal, 0, this.mass);
|
||||
this.internal[g] = filter(components.internal[g], maxInternal, 0, mass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user