mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
Massive refactor for 3rd party import
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user