@massif/lancer-data 3.1.7 → 4.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,134 +1,134 @@
1
- const fs = require('fs');
2
-
3
- const weapons = require('../lib/weapons.json');
4
- const systems = require('../lib/systems.json');
5
- const mods = require('../lib/mods.json');
6
- const frames = require('../lib/frames.json');
7
-
8
- // const items = [weapons, systems, mods, frames]
9
- const items = [weapons];
10
-
11
- function row(x) {
12
- if (x.data_type === 'weapon') return weaponRow(x);
13
- return `${x.source},${x.name},0,0,0,0,0,0\n`;
14
- // return `${x.data_type},${x.id},${x.source},${x.name},0,0,0,0,0,0\n`
15
- }
16
-
17
- function weaponRow(x) {
18
- // return `${x.data_type},${x.id},${x.source},${x.name},0,${rangedAp(x)},0,0,0,0\n`
19
- return `${x.source},${x.name},${closeAp(x)},${rangedAp(x)},0,0,0,0\n`;
20
- }
21
-
22
- function getDamage(d, tags) {
23
- let dscore = 0;
24
- let guaranteed = 0;
25
- let possible = 0;
26
- if (typeof d.val === 'string') {
27
- const dmgArr = d.val.split(/d|\+/g);
28
- if (dmgArr.length === 1) guaranteed = parseInt(dmgArr[0]); // straight value, no dice
29
- else {
30
- if (dmgArr.length === 3) guaranteed = parseInt(dmgArr[2]); // bonus val
31
- // handle dice
32
- guaranteed += parseInt(dmgArr[0]); // min number we can get on the dice
33
- possible = parseInt(dmgArr[0]) * parseInt(dmgArr[1]) - parseInt(dmgArr[0]);
34
- }
35
- // guaranteed = 1pt, possible = 0.5
36
- dscore += guaranteed * (possible / 2);
37
- } else {
38
- guaranteed = d.val;
39
- }
40
-
41
- if (tags.find((x) => x.id === 'tg_accurate')) dscore += possible * 0.25;
42
- if (tags.find((x) => x.id === 'tg_inaccurate')) dscore -= possible * 0.25;
43
- if (tags.find((x) => x.id === 'tg_reliable'))
44
- dscore += tags.find((x) => x.id === 'tg_reliable').val * 3;
45
-
46
- return dscore;
47
- }
48
-
49
- function closeAp(x) {
50
- let score = 0;
51
- const tags = x.tags || [];
52
- if (x.type.toLowerCase() !== 'melee' || !x.damage || !x.damage.length) return score.toString();
53
-
54
- x.damage.forEach((d) => {
55
- score += getDamage(d, tags);
56
- });
57
-
58
- const threat = x.range.find((y) => y.type.toLowerCase() === 'threat');
59
- // console.log(threat)
60
- if (threat) score *= (threat.val + 1) / 2;
61
-
62
- if (tags.find((x) => x.id === 'tg_ap')) score = score * 1.35;
63
- if (tags.find((x) => x.id === 'tg_arcing')) score = score * 1.15;
64
- if (tags.find((x) => x.id === 'tg_smart')) score = score * 1.15;
65
- if (tags.find((x) => x.id === 'tg_overkill')) score = score * 1.15;
66
- if (tags.find((x) => x.id === 'tg_loading')) score = score * 0.85;
67
-
68
- return Math.ceil(score).toString();
69
- }
70
-
71
- function rangedAp(x) {
72
- let score = 0;
73
- const tags = x.tags || [];
74
- if (
75
- x.type.toLowerCase() === 'melee' ||
76
- !x.range ||
77
- !x.range.length ||
78
- !x.damage ||
79
- !x.damage.length
80
- )
81
- return score.toString();
82
- x.damage.forEach((d) => {
83
- score += getDamage(d, tags);
84
- });
85
- //collect range pts
86
- x.range.forEach((r) => {
87
- let rscore = 0;
88
- if (typeof r.val === 'string') return 'XXXX';
89
- if (r.type.toLowerCase() === 'range') {
90
- if (r.val <= 10) score += r.val / 2;
91
- else {
92
- rscore += 5 + (r.val - 10);
93
- }
94
- }
95
- if (r.type.toLowerCase() === 'blast') {
96
- rscore += Math.pow(r.val * 3, 2) / 2;
97
- }
98
- if (r.type.toLowerCase() === 'burst') {
99
- rscore += Math.pow(r.val * 3, 2) / 3;
100
- }
101
- if (r.type.toLowerCase() === 'cone') {
102
- rscore += Math.pow(r.val, 2) / 2;
103
- }
104
- if (r.type.toLowerCase() === 'line') {
105
- rscore += r.val * 2;
106
- }
107
- if (r.type.toLowerCase() === 'thrown') {
108
- rscore = score / 3;
109
- }
110
- score += rscore;
111
- });
112
-
113
- if (tags.find((x) => x.id === 'tg_ap')) score = score * 1.35;
114
- if (tags.find((x) => x.id === 'tg_arcing')) score = score * 1.15;
115
- if (tags.find((x) => x.id === 'tg_smart')) score = score * 1.15;
116
- if (tags.find((x) => x.id === 'tg_overkill')) score = score * 1.15;
117
- if (tags.find((x) => x.id === 'tg_loading')) score = score * 0.85;
118
-
119
- return Math.ceil(score).toString();
120
- }
121
-
122
- // let output = 'TYPE,ID,SOURCE,NAME,CQB,RANGED,SURVIVABILITY,MANEUVERABILITY,SUPPORT,CONTROL\n'
123
- let output = 'SOURCE,NAME,MELEE,RANGED,SURVIVABILITY,MANEUVERABILITY,SUPPORT,CONTROL\n';
124
-
125
- items.forEach((e) => {
126
- e.forEach((x) => {
127
- output += row(x);
128
- });
129
- });
130
-
131
- fs.writeFile('./util/output/equipment.csv', output, function (err) {
132
- if (err) return console.log(err);
133
- console.log('Export Complete');
134
- });
1
+ const fs = require('fs');
2
+
3
+ const weapons = require('../lib/weapons.json');
4
+ const systems = require('../lib/systems.json');
5
+ const mods = require('../lib/mods.json');
6
+ const frames = require('../lib/frames.json');
7
+
8
+ // const items = [weapons, systems, mods, frames]
9
+ const items = [weapons];
10
+
11
+ function row(x) {
12
+ if (x.data_type === 'weapon') return weaponRow(x);
13
+ return `${x.source},${x.name},0,0,0,0,0,0\n`;
14
+ // return `${x.data_type},${x.id},${x.source},${x.name},0,0,0,0,0,0\n`
15
+ }
16
+
17
+ function weaponRow(x) {
18
+ // return `${x.data_type},${x.id},${x.source},${x.name},0,${rangedAp(x)},0,0,0,0\n`
19
+ return `${x.source},${x.name},${closeAp(x)},${rangedAp(x)},0,0,0,0\n`;
20
+ }
21
+
22
+ function getDamage(d, tags) {
23
+ let dscore = 0;
24
+ let guaranteed = 0;
25
+ let possible = 0;
26
+ if (typeof d.val === 'string') {
27
+ const dmgArr = d.val.split(/d|\+/g);
28
+ if (dmgArr.length === 1) guaranteed = parseInt(dmgArr[0]); // straight value, no dice
29
+ else {
30
+ if (dmgArr.length === 3) guaranteed = parseInt(dmgArr[2]); // bonus val
31
+ // handle dice
32
+ guaranteed += parseInt(dmgArr[0]); // min number we can get on the dice
33
+ possible = parseInt(dmgArr[0]) * parseInt(dmgArr[1]) - parseInt(dmgArr[0]);
34
+ }
35
+ // guaranteed = 1pt, possible = 0.5
36
+ dscore += guaranteed * (possible / 2);
37
+ } else {
38
+ guaranteed = d.val;
39
+ }
40
+
41
+ if (tags.find((x) => x.id === 'tg_accurate')) dscore += possible * 0.25;
42
+ if (tags.find((x) => x.id === 'tg_inaccurate')) dscore -= possible * 0.25;
43
+ if (tags.find((x) => x.id === 'tg_reliable'))
44
+ dscore += tags.find((x) => x.id === 'tg_reliable').val * 3;
45
+
46
+ return dscore;
47
+ }
48
+
49
+ function closeAp(x) {
50
+ let score = 0;
51
+ const tags = x.tags || [];
52
+ if (x.type.toLowerCase() !== 'melee' || !x.damage || !x.damage.length) return score.toString();
53
+
54
+ x.damage.forEach((d) => {
55
+ score += getDamage(d, tags);
56
+ });
57
+
58
+ const threat = x.range.find((y) => y.type.toLowerCase() === 'threat');
59
+ // console.log(threat)
60
+ if (threat) score *= (threat.val + 1) / 2;
61
+
62
+ if (tags.find((x) => x.id === 'tg_ap')) score = score * 1.35;
63
+ if (tags.find((x) => x.id === 'tg_arcing')) score = score * 1.15;
64
+ if (tags.find((x) => x.id === 'tg_smart')) score = score * 1.15;
65
+ if (tags.find((x) => x.id === 'tg_overkill')) score = score * 1.15;
66
+ if (tags.find((x) => x.id === 'tg_loading')) score = score * 0.85;
67
+
68
+ return Math.ceil(score).toString();
69
+ }
70
+
71
+ function rangedAp(x) {
72
+ let score = 0;
73
+ const tags = x.tags || [];
74
+ if (
75
+ x.type.toLowerCase() === 'melee' ||
76
+ !x.range ||
77
+ !x.range.length ||
78
+ !x.damage ||
79
+ !x.damage.length
80
+ )
81
+ return score.toString();
82
+ x.damage.forEach((d) => {
83
+ score += getDamage(d, tags);
84
+ });
85
+ //collect range pts
86
+ x.range.forEach((r) => {
87
+ let rscore = 0;
88
+ if (typeof r.val === 'string') return 'XXXX';
89
+ if (r.type.toLowerCase() === 'range') {
90
+ if (r.val <= 10) score += r.val / 2;
91
+ else {
92
+ rscore += 5 + (r.val - 10);
93
+ }
94
+ }
95
+ if (r.type.toLowerCase() === 'blast') {
96
+ rscore += Math.pow(r.val * 3, 2) / 2;
97
+ }
98
+ if (r.type.toLowerCase() === 'burst') {
99
+ rscore += Math.pow(r.val * 3, 2) / 3;
100
+ }
101
+ if (r.type.toLowerCase() === 'cone') {
102
+ rscore += Math.pow(r.val, 2) / 2;
103
+ }
104
+ if (r.type.toLowerCase() === 'line') {
105
+ rscore += r.val * 2;
106
+ }
107
+ if (r.type.toLowerCase() === 'thrown') {
108
+ rscore = score / 3;
109
+ }
110
+ score += rscore;
111
+ });
112
+
113
+ if (tags.find((x) => x.id === 'tg_ap')) score = score * 1.35;
114
+ if (tags.find((x) => x.id === 'tg_arcing')) score = score * 1.15;
115
+ if (tags.find((x) => x.id === 'tg_smart')) score = score * 1.15;
116
+ if (tags.find((x) => x.id === 'tg_overkill')) score = score * 1.15;
117
+ if (tags.find((x) => x.id === 'tg_loading')) score = score * 0.85;
118
+
119
+ return Math.ceil(score).toString();
120
+ }
121
+
122
+ // let output = 'TYPE,ID,SOURCE,NAME,CQB,RANGED,SURVIVABILITY,MANEUVERABILITY,SUPPORT,CONTROL\n'
123
+ let output = 'SOURCE,NAME,MELEE,RANGED,SURVIVABILITY,MANEUVERABILITY,SUPPORT,CONTROL\n';
124
+
125
+ items.forEach((e) => {
126
+ e.forEach((x) => {
127
+ output += row(x);
128
+ });
129
+ });
130
+
131
+ fs.writeFile('./util/output/equipment.csv', output, function (err) {
132
+ if (err) return console.log(err);
133
+ console.log('Export Complete');
134
+ });
package/scripts/build.js CHANGED
@@ -1,14 +1,14 @@
1
- const zl = require('zip-lib');
2
-
3
- const info = require('../package.json');
4
-
5
- const filepath = './' + info.name + '-' + info.version + '.lcp';
6
-
7
- zl.archiveFolder('./lib', filepath).then(
8
- function () {
9
- console.log('done');
10
- },
11
- function (err) {
12
- console.log(err);
13
- }
14
- );
1
+ const zl = require('zip-lib');
2
+
3
+ const info = require('../package.json');
4
+
5
+ const filepath = './' + info.name + '-' + info.version + '.lcp';
6
+
7
+ zl.archiveFolder('./lib', filepath).then(
8
+ function () {
9
+ console.log('done');
10
+ },
11
+ function (err) {
12
+ console.log(err);
13
+ }
14
+ );