-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci_aggregate_urf.js
64 lines (58 loc) · 1.75 KB
/
ci_aggregate_urf.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var fs = require('fs');
var championitems = JSON.parse(fs.readFileSync('champion_items_urf.json'));
var items = JSON.parse(fs.readFileSync('items_adjusted.json'));
var championdata = JSON.parse(fs.readFileSync('champions.json')).data;
var sum = 0;
for (var ci in championitems) {
sum += championitems[ci].totalgold;
}
console.log(sum);
console.log(sum / championitems.length);
//var avg = sum / championitems.length;
var avg = 15000;
var champions = {};
for (var c in championdata) {
var t = {};
t.count = 0;
t.name = c;
t.itemcounts = {};
t.totalgold = 0;
for (var i in items) {
if (items[i].mapto) continue;
t.itemcounts[i] = 0;
}
champions[championdata[c].id] = t;
}
for (var ci in championitems) {
var scale = avg / championitems[ci].totalgold;
var c = championitems[ci].champion;
//console.log(champions[c]);
champions[c].count++;
champions[c].totalgold += championitems[ci].totalgold;
for (var i in championitems[ci].items) {
var it = championitems[ci].items[i];
champions[c].itemcounts[it] += scale;
if (it >= 3707 && it <= 3726) {
champions[c].itemcounts[1039] += scale;
}
}
}
fs.writeFileSync('champions_aggregated_urf.json', JSON.stringify(champions));
var s = 'Champion,Count,AvgGold';
var itemnames = '';
for (var i in items) {
if (items[i].mapto) continue;
s += ',' + i;
itemnames += items[i].name + '\n';
}
s += '\n';
for (var c in champions) {
s += champions[c].name + ',' + champions[c].count + ',' + champions[c].totalgold / champions[c].count;
for (var i in items) {
if (items[i].mapto) continue;
s += ',' + champions[c].itemcounts[i] / champions[c].count * items[i].gold;
}
s += '\n';
}
fs.writeFileSync('champions_aggregated_urf.csv', s);
fs.writeFileSync('itemnames.txt', itemnames);