Skip to content

Commit c3cb2cf

Browse files
authored
Add SCO Module Check (#748)
* Add SCO Module Check Goes hand-in-hand with EDCD/coriolis-data#98 * [748] Updated Filter Function This time, readable!
1 parent 5d54eb8 commit c3cb2cf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/app/shipyard/ModuleSet.js

+14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ function filter(arr, maxClass, minClass, mass) {
1313
return arr.filter(m => m.class <= maxClass && m.class >= minClass && (m.maxmass === undefined || mass <= m.maxmass));
1414
}
1515

16+
/**
17+
* Filter SCO Modules to only return legal size.
18+
* @param {Array} arr Array of available FSD modules.
19+
* @param {number} maxSize Maximum allowable size for SCO modules.
20+
* @return {Array} Subset of modules filtered based on legal size amd type.
21+
*/
22+
function sco_filter(arr, maxSize) {
23+
return arr.filter(module => {
24+
return !(module.hasOwnProperty('name') && module['name'] === "Frame Shift Drive (SCO)" && module['class'] < maxSize);
25+
});
26+
}
27+
28+
1629
/**
1730
* The available module set for a specific ship
1831
*/
@@ -41,6 +54,7 @@ export default class ModuleSet {
4154

4255
this.standard[0] = filter(stnd.pp, maxStandardArr[0], 0, mass); // Power Plant
4356
this.standard[2] = filter(stnd.fsd, maxStandardArr[2], 0, mass); // FSD
57+
this.standard[2] = sco_filter(this.standard[2], maxStandardArr[2]) // FSD - Filter SCO Modules
4458
this.standard[4] = filter(stnd.pd, maxStandardArr[4], 0, mass); // Power Distributor
4559
this.standard[6] = filter(stnd.ft, maxStandardArr[6], 0, mass); // Fuel Tank
4660
// Thrusters, filter modules by class only (to show full list of ratings for that class)

0 commit comments

Comments
 (0)