-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
2,272 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
dist/ | ||
testing/ | ||
testing.js | ||
docs/ | ||
assets/ | ||
examples/ | ||
images/ | ||
.github/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
env: { | ||
es2021: true, | ||
node: true, | ||
}, | ||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: "module", | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
rules: { | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"no-constant-condition": "off", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,72 @@ | ||
// This script will save a TETR.IO Solo leaderboard to "leaderboard.json" | ||
// Credit to Turbo-baguette | ||
|
||
const { TetraChannel } = require('../dist/index') | ||
const fs = require('fs') | ||
const { TetraChannel } = require("../dist/index"); | ||
const fs = require("fs"); | ||
|
||
async function getLeaderBoard(country) { | ||
const res = await TetraChannel.leaderboards.tetra_league_full(country); | ||
return res.data.users; | ||
} | ||
|
||
async function getUserRecords(userId) { | ||
|
||
let sprintTime = null; | ||
let blitzScore = null; | ||
|
||
const res = await TetraChannel.users.records(userId); | ||
sprintTime = res.data.records["40l"].record.endcontext.finalTime | ||
blitzScore = res.data.records.blitz.record.endcontext.score | ||
|
||
sprintTime = res.data.records["40l"].record.endcontext.finalTime; | ||
blitzScore = res.data.records.blitz.record.endcontext.score; | ||
|
||
return { | ||
sprint: sprintTime, | ||
blitz: blitzScore | ||
sprint: sprintTime, | ||
blitz: blitzScore, | ||
}; | ||
} | ||
|
||
async function createSoloLeadderBoard() { | ||
var country = "" // Write the country code here | ||
const country = ""; // Write the country code here | ||
|
||
let sprintLeaderboard = []; | ||
let blitzLeaderboard = []; | ||
const sprintLeaderboard = []; | ||
const blitzLeaderboard = []; | ||
|
||
const Players = (await getLeaderBoard(country)); | ||
const Players = await getLeaderBoard(country); | ||
|
||
for (const player of Players) { | ||
const playerRecords = await getUserRecords(player["_id"]); | ||
console.log(`fetched records for player ${player.username}`); | ||
|
||
if (playerRecords.sprint) { | ||
sprintLeaderboard.push({ | ||
player: player.username, | ||
time: playerRecords.sprint | ||
}); | ||
} | ||
|
||
if (playerRecords.blitz) { | ||
blitzLeaderboard.push({ | ||
player: player.username, | ||
score: playerRecords.blitz | ||
}) | ||
} | ||
|
||
const playerRecords = await getUserRecords(player["_id"]); | ||
console.log(`fetched records for player ${player.username}`); | ||
|
||
if (playerRecords.sprint) { | ||
sprintLeaderboard.push({ | ||
player: player.username, | ||
time: playerRecords.sprint, | ||
}); | ||
} | ||
|
||
if (playerRecords.blitz) { | ||
blitzLeaderboard.push({ | ||
player: player.username, | ||
score: playerRecords.blitz, | ||
}); | ||
} | ||
} | ||
|
||
sprintLeaderboard.sort((a, b) => a.time - b.time); | ||
blitzLeaderboard.sort((a, b) => b.score - a.score); | ||
|
||
return { | ||
sprintLeaderboard, | ||
blitzLeaderboard | ||
} | ||
|
||
sprintLeaderboard, | ||
blitzLeaderboard, | ||
}; | ||
} | ||
|
||
createSoloLeadderBoard().then(res => { | ||
fs.writeFile("leaderboard.json", JSON.stringify(res), err => { | ||
createSoloLeadderBoard() | ||
.then((res) => { | ||
fs.writeFile("leaderboard.json", JSON.stringify(res), (err) => { | ||
if (err) { | ||
console.log(err) | ||
console.log(err); | ||
} | ||
}); | ||
console.log('all done :)'); | ||
}).catch(console.error); | ||
}); | ||
console.log("all done :)"); | ||
}) | ||
.catch(console.error); |
Oops, something went wrong.