33 lines
991 B
JavaScript
33 lines
991 B
JavaScript
import request from 'request';
|
|
import * as playerAnswers from './playerAnswers.json';
|
|
import { HEADERS, SERVER_URL } from './config';
|
|
|
|
export default class TopPlayers {
|
|
constructor() {
|
|
this.logger = null;
|
|
}
|
|
|
|
async run() {
|
|
const players = playerAnswers.default;
|
|
console.log(`There have been ${players.length} players recorded!\n`);
|
|
players.sort((a, b) => b.score - a.score);
|
|
|
|
const playersToShow = Math.min(10, players.length);
|
|
console.log(`Showing results for top ${playersToShow} players:`);
|
|
|
|
for (let i = 0; i < playersToShow; i++) {
|
|
const { username, score } = players[i];
|
|
console.log(`${i + 1}) ${username} with a score of ${score}.`);
|
|
}
|
|
|
|
players.sort((a, b) => a.score - b.score);
|
|
|
|
console.log(`\nShowing results for worst ${playersToShow} players:`);
|
|
|
|
for (let i = 0; i < playersToShow; i++) {
|
|
const { username, score } = players[i];
|
|
console.log(`${i + 1}) ${username} with a score of ${score}.`);
|
|
}
|
|
}
|
|
}
|