mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
Add SCO Module Check (#748)
* Add SCO Module Check Goes hand-in-hand with https://github.com/EDCD/coriolis-data/pull/98 * [748] Updated Filter Function This time, readable!
This commit is contained in:
@@ -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));
|
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
|
* 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[0] = filter(stnd.pp, maxStandardArr[0], 0, mass); // Power Plant
|
||||||
this.standard[2] = filter(stnd.fsd, maxStandardArr[2], 0, mass); // FSD
|
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[4] = filter(stnd.pd, maxStandardArr[4], 0, mass); // Power Distributor
|
||||||
this.standard[6] = filter(stnd.ft, maxStandardArr[6], 0, mass); // Fuel Tank
|
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)
|
// Thrusters, filter modules by class only (to show full list of ratings for that class)
|
||||||
|
|||||||
Reference in New Issue
Block a user