init: tournament

This commit is contained in:
2023-12-20 19:15:47 +01:00
parent 8ed9deab2d
commit bfcfabb35a
12 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import { Client } from "./client.js";
class Tourmanent
{
/**
* @param {Client} client
*/
constructor(client)
{
/**
* @type {Client}
*/
this.client = client
}
}
export { Tourmanent }

View File

@ -0,0 +1,33 @@
import { Client } from "./client.js";
class Tourmanents
{
/**
* @param {Client} client
*/
constructor(client)
{
/**
* @type {Client}
*/
this.client = client
}
async createTournament(nb_players, online)
{
if (online)
return "offline";
let response = await this.client._post("/api/tournaments/", {numbers_of_players: nb_players});
let response_data = await response.json();
if (JSON.stringify(response_data) === JSON.stringify({'detail': 'Authentication credentials were not provided.'}))
{
this.client._update_logged(false);
return null;
}
return response_data.tournament_id;
}
}
export { Tourmanents }