Massive refactor for 3rd party import

This commit is contained in:
Colin McLeod
2015-07-19 21:32:14 -07:00
parent c796adf40d
commit 03986cb88a
50 changed files with 4278 additions and 156 deletions

View File

@@ -32,6 +32,41 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
return null;
};
this.findInternalId = function(groupName, clss, rating, name) {
var group = C.internal[groupName];
if (!group) {
throw 'Invalid internal group: ' + groupName;
}
for (var i = 0, l = group.length; i < l; i++) {
if (group[i].class == clss && group[i].rating == rating && ((!name && !group[i].name) || group[i].name == name)) {
return group[i].id;
}
}
return 0;
};
this.findHardpointId = function(groupName, clss, rating, name, mode, missile) {
var group = C.hardpoints[groupName];
if (!group) {
throw 'Invalid hardpoint group: ' + groupName;
}
for (var i = 0, l = group.length; i < l; i++) {
if (group[i].class == clss && group[i].rating == rating && group[i].mode == mode
&& ((!name && !group[i].name) || group[i].name == name)
&& ((!missile && !group[i].missile) || group[i].missile == missile)
) {
return group[i].id;
}
}
return 0;
};
/**
* Looks up the bulkhead component for a specific ship and bulkhead
* @param {string} shipId Unique ship Id/Key
@@ -42,6 +77,10 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
return C.bulkheads[shipId][bulkheadsId];
};
this.bulkheadIndex = function(bulkheadName) {
return ['Lightweight Alloy', 'Reinforced Alloy', 'Military Grade Composite', 'Mirrored Surface Composite', 'Reactive Surface Composite'].indexOf(bulkheadName);
};
/**
* Creates a new ComponentSet that contains all available components
* that the specified ship is eligible to use.