cgresultstuff
unknown
javascript
4 years ago
2.7 kB
6
Indexable
var results = [
`
1. allanloss88 18818 [5]
2. donsim62 12048 [5]
3. Sverre 9883 [5]
4. ilnaz12122112 9713 [5]
5. tuxoo_ 9191 [5]
6. mgln_ 8792 [5]
7. potf 8274 [5]
8. requiem569 8033 [5]
9. strontjog 7892 [5]
10. justwiiki 7665 [5]
11. fu_ls 7256 [5]
12. spiralvgc 6938 [5]
13. super_33 6716 [5]
14. quarksauce 6517 [5]
15. IH653ttv 6298 [5]
16. havrd 5972 [5]
17. meseriireparator 5544 [5]
18. bluetrec2 5355 [2]
19. a_diverse_world 5000 [1]
20. oneionn 4200 [5]
21. AxelBaxel 3388 [5]
22. lennli_ 2722 [4]
23. wilsonia85 2472 [1]
24. geek298319824 2457 [1]
`,
`
1. spiralvgc 16546 [5]
2. ilnaz12122112 10861 [5]
3. havrd 10536 [5]
4. tuxoo_ 10286 [5]
5. donsim62 9884 [5]
6. fu_ls 9497 [5]
7. Sverre 9299 [5]
8. AxelBaxel 9239 [5]
9. potf 9047 [5]
10. IH653ttv 8975 [5]
11. strontjog 8654 [5]
12. geek298319824 8386 [5]
13. allanloss88 7944 [5]
14. quarksauce 7115 [5]
15. a_diverse_world 6712 [2]
16. super_33 6348 [5]
17. justwiiki 6334 [5]
18. oneionn 6151 [5]
19. mgln_ 5880 [5]
20. johannmit 4736 [1]
21. requiem569 506 [2]
22. meseriireparator 401 [2]
23. S1S2S1S2 64 [1]
`,
`
1. geek298319824 16709 [5]
2. donsim62 16096 [5]
3. fu_ls 14625 [5]
4. super_33 13419 [5]
5. ilnaz12122112 12221 [5]
6. Sverre 11870 [5]
7. AxelBaxel 11082 [5]
8. mgln_ 10851 [5]
9. IH653ttv 10532 [5]
10. quarksauce 10456 [5]
11. scryperoo 9817 [3]
12. potf 9744 [5]
13. oneionn 8683 [5]
14. havrd 8502 [5]
15. tuxoo_ 8429 [5]
16. strontjog 8129 [5]
17. spiralvgc 8128 [5]
18. aksel_csgo 3792 [3]
19. justwiiki 2470 [1]
20. Patrickbart12 1345 [2]
21. allanloss88 147 [2]
22. siyahfuskatr 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}`;
var counter = 1;
for (var game of results) {
console.log(`GAME ${counter++}`);
console.log(resultsForGame(game).map(playerAsString).join('\n'));
}
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...