cgtotalresults
unknown
javascript
4 years ago
2.4 kB
8
Indexable
var results = [
`
1. Geostique 21384 [5]
2. kurt_ynwaliv 20655 [5]
3. simon45_45 20526 [5]
4. pisanico 20281 [5]
5. spiralvgc 18844 [5]
6. JigenYT 18752 [5]
7. Brad_Hamilton 18564 [5]
8. manuelsonh 17965 [5]
9. jiiibeee 17296 [5]
10. slashpeek 14475 [5]
11. Lurioll 14039 [4]
12. Consus 13916 [5]
13. el_Vell 13787 [5]
14. xannyboy420 13778 [5]
15. toro3317 13707 [5]
16. kidconifer 13343 [5]
17. SpringyRubber 11666 [5]
18. kollariss46 10597 [5]
19. velvet_ow 10427 [5]
20. ChicagoGeographer 10166 [5]
21. nmh___ 9709 [4]
22. xxmichelle14xx 9661 [5]
23. j0xu_ 8017 [5]
24. MACONEX 7097 [5]
25. fl0p3s 7027 [4]
26. ImxCarterr 4269 [3]
27. snowf_Iake 181 [1]
28. UltraTech66 13 [1]
29. morqka1913 0 [1]
30. vakon3 0 [1]
1. fl0p3s 20115 [5]
2. Geostique 19345 [5]
3. kurt_ynwaliv 18787 [5]
4. manuelsonh 17098 [5]
5. JigenYT 17091 [5]
6. Consus 16428 [5]
7. jiiibeee 15902 [5]
8. nmh___ 15851 [5]
9. pisanico 15494 [5]
10. simon45_45 15379 [5]
11. morqka1913 15003 [5]
12. SpringyRubber 14947 [5]
13. Lurioll 14437 [4]
14. slashpeek 14348 [5]
15. toro3317 14145 [5]
16. UltraTech66 13150 [5]
17. ChicagoGeographer 13025 [5]
18. jackomac101 13006 [5]
19. Brad_Hamilton 12844 [5]
20. kidconifer 12539 [5]
21. kollariss46 12387 [5]
22. el_Vell 12176 [5]
23. xxmichelle14xx 11913 [5]
24. spiralvgc 10570 [5]
25. GeoGamr 10069 [5]
26. xannyboy420 8091 [5]
27. CryptoJesse 6648 [2]
28. MACONEX 5233 [5]
29. periott 3589 [1]
30. Conquistadorito 7 [2]
31. trikalaboa 0 [1]
`
];
var groupBy = (input, key) => { return input.reduce((acc, currentValue) => { let groupKey = currentValue[key]; if (!acc[groupKey]) { acc[groupKey] = []; } acc[groupKey].push(currentValue); return acc; }, []); };
var resultsForGame = game => game.split('\n').map(x => ({user: x.split('\t')[2], points: parseInt(x.split('\t')[3])})).filter(x => x.user);
var playerAsString = player => `${player.user}\t${player.points}`;
console.log("TOTAL")
var groupedResults = groupBy(results.map(resultsForGame).flatMap(x => x), "user");
var totalResults = Object.keys(groupedResults).map(key => ({points: groupedResults[key].map(x => x.points).reduce((a, b) => a + b), user: key }))
totalResults.sort((a, b) => b.points - a.points);
console.log(totalResults.map(playerAsString).join('\n'));Editor is loading...