build_scripts/generate_antimatter.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 0

Size

Lines of Code 32
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
wmc 3
nc 4
mnd 3
bc 3
fnc 0
dl 0
loc 32
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
/* eslint-env node */
2
/*jslint node: true */
3
'use strict';
4
5
let jsonfile = require('jsonfile');
6
7
let resources = jsonfile.readFileSync('build/data/resources.json');
8
let reactions = jsonfile.readFileSync('build/data/reactions.json');
9
10
for (let i in resources) {
11
  let resource = resources[i];
12
  if (resource.anti_particle) {
13
    let anti = resource.anti_particle;
14
    if(typeof reactions[anti+'-eV'] === 'undefined'){
15
      let key = i + '-eV';
16
      let reaction = {
17
        'reactant': {},
18
        'product': {},
19
        'elements': []
20
      };
21
      reaction.reactant[i] = 1;
22
      reaction.reactant[anti] = 1;
23
      reaction.product.eV = resource.energy * 2;
24
      reactions[key] = reaction;
25
    }
26
  }
27
}
28
29
jsonfile.writeFileSync('build/data/resources.json', resources, {
30
  spaces: 2
31
});
32
jsonfile.writeFileSync('build/data/reactions.json', reactions, {
33
  spaces: 2
34
});
35