Skip to content

Commit

Permalink
Add SCO Module Check (#748)
Browse files Browse the repository at this point in the history
* Add SCO Module Check

Goes hand-in-hand with EDCD/coriolis-data#98

* [748] Updated Filter Function

This time, readable!
  • Loading branch information
Rixxan authored May 12, 2024
1 parent 5d54eb8 commit c3cb2cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/app/shipyard/ModuleSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c3cb2cf

Please sign in to comment.