build_scripts/generate_unlocks.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 25
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
wmc 1
c 1
b 0
f 0
nc 2
mnd 1
bc 1
fnc 0
dl 0
loc 25
rs 10
bpm 0
cpm 0
noi 0
1
/* eslint-env node */
2
/*jslint node: true */
3
'use strict';
4
5
const jsonfile = require('jsonfile');
6
7
let unlocks = jsonfile.readFileSync('build/data/unlocks.json');
8
let elements = jsonfile.readFileSync('build/data/elements.json');
9
10
for(let element in elements){
11
  // Generate element unlocks
12
  unlocks[element] = {
13
    'condition': ['(() => {',
14
      'for(let resource of data.elements.'+element+'.includes){',
15
      '  if(player.resources[resource] !== null){',
16
      '    return true;',
17
      '  }',
18
      '}',
19
      'return false;',
20
      '})()'
21
    ]
22
  };
23
}
24
25
jsonfile.writeFileSync('build/data/unlocks.json', unlocks, {
26
  spaces: 2
27
});
28