diff --git a/src/app/shipyard/ModuleSet.js b/src/app/shipyard/ModuleSet.js index 129ee019..69b93418 100755 --- a/src/app/shipyard/ModuleSet.js +++ b/src/app/shipyard/ModuleSet.js @@ -13,6 +13,19 @@ function filter(arr, maxClass, minClass, mass) { return arr.filter(m => m.class <= maxClass && m.class >= minClass && (m.maxmass === undefined || mass <= m.maxmass)); } +/** + * Filter SCO Modules to only return legal size. + * @param {Array} arr Array of available FSD modules. + * @param {number} maxSize Maximum allowable size for SCO modules. + * @return {Array} Subset of modules filtered based on legal size amd type. + */ +function sco_filter(arr, maxSize) { + return arr.filter(module => { + return !(module.hasOwnProperty('name') && module['name'] === "Frame Shift Drive (SCO)" && module['class'] < maxSize); + }); +} + + /** * The available module set for a specific ship */ @@ -41,6 +54,7 @@ export default class ModuleSet { this.standard[0] = filter(stnd.pp, maxStandardArr[0], 0, mass); // Power Plant this.standard[2] = filter(stnd.fsd, maxStandardArr[2], 0, mass); // FSD + this.standard[2] = sco_filter(this.standard[2], maxStandardArr[2]) // FSD - Filter SCO Modules this.standard[4] = filter(stnd.pd, maxStandardArr[4], 0, mass); // Power Distributor this.standard[6] = filter(stnd.ft, maxStandardArr[6], 0, mass); // Fuel Tank // Thrusters, filter modules by class only (to show full list of ratings for that class)