-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplasmaFLowPerInjectorCalculator.js
46 lines (38 loc) · 1.64 KB
/
plasmaFLowPerInjectorCalculator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const velocityCalculator = require('./velocityCalculator');
const injectorsWithDamageCounter = require('./functions/injectorsWithDamageCounter');
const functionalInjectorsCounter = require('./functions/functionalInjectorsCounter');
const extraPlasmaCalculator = require('./functions/extraPlasmaCalculator');
const distributeExtraPlasma = require('./functions/distributeExtraPlasma');
const maximumPlasmaCapacityCalculator = require('./functions/maximumPlasmaCapacityCalculator');
module.exports = (injectorStatus) => {
const {injectorA, injectorB, injectorC, velocityPercent} = injectorStatus;
var injectorsDamage = [100 - injectorA, 100 - injectorB, 100 - injectorC];
var plasmaFlow = velocityCalculator(velocityPercent);
var injectorsWithDamage = injectorsWithDamageCounter(injectorsDamage);
var functionalInjector = functionalInjectorsCounter(injectorsDamage);
var extraPlasma = extraPlasmaCalculator(velocityPercent, injectorsDamage)
var injectorsWithExtraPlasma = distributeExtraPlasma(extraPlasma, injectorsDamage);
var upperCapacityInjectors = maximumPlasmaCapacityCalculator(injectorStatus, injectorsWithExtraPlasma);
const injectorsResults = [];
if(injectorsWithDamage > 0){
for(var i = 0; i < injectorsDamage.length; i++){
injectorsResults.push({
id : i,
value : injectorsWithExtraPlasma[i],
});
}
} else {
for(var i = 0; i < injectorsDamage.length; i++){
injectorsResults.push({
id : i,
value : plasmaFlow / functionalInjector,
});
}
}
if(upperCapacityInjectors > 0){
return 'Unable to comply'
}
else {
return injectorsResults;
}
}