Skip to content

Commit

Permalink
Merge branch 'nightly' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup3rFire committed Aug 4, 2021
2 parents 90d22f0 + d0fe6f5 commit e54aff8
Show file tree
Hide file tree
Showing 29 changed files with 2,272 additions and 294 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist/
testing/
testing.js
docs/
assets/
examples/
images/
.github/
19 changes: 19 additions & 0 deletions .eslintrc.js
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",
},
};
15 changes: 15 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ on:
branches: "*"

jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint
quality:
runs-on: ${{ matrix.os }}

Expand Down
8 changes: 8 additions & 0 deletions .prettierrc
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
}
2 changes: 1 addition & 1 deletion examples/AutoHost.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Client } = require("./../dist/index");
const { Client } = require("../dist/index");
const main = new Client();
const START_DELAY = 5000;

Expand Down
2 changes: 1 addition & 1 deletion examples/General.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Client } = require("./../dist/index");
const { Client } = require("../dist/index");
const client = new Client();

client.on("ready", () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/JoinOnInvite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Client } = require("./dist/index");
const { Client } = require("../dist/index");
const client = new Client();

client.on("ready", () => {
Expand Down
77 changes: 38 additions & 39 deletions examples/saveSoloLeaderboard.js
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);
Loading

0 comments on commit e54aff8

Please sign in to comment.