game: add: docstring
This commit is contained in:
@ -3,7 +3,17 @@ import { Client } from "../client.js";
|
||||
class Tourmanent
|
||||
{
|
||||
/**
|
||||
* @param {Client} client
|
||||
*
|
||||
* @param {Client} client
|
||||
* @param {Number} id the id of the tournament
|
||||
* @param {Number} name
|
||||
* @param {Number} nb_players
|
||||
* @param {Number} nb_players_by_game
|
||||
* @param {Number} level
|
||||
* @param {Boolean} started
|
||||
* @param {Boolean} finished
|
||||
* @param {[]} levels
|
||||
* @param {String} state
|
||||
*/
|
||||
constructor(client, id, name = undefined, nb_players = undefined, nb_players_by_game = undefined, level = undefined, started = undefined, finished = undefined, levels = undefined, state = undefined)
|
||||
{
|
||||
@ -11,16 +21,55 @@ class Tourmanent
|
||||
* @type {Client}
|
||||
*/
|
||||
this.client = client;
|
||||
|
||||
/**
|
||||
* @type {String} the name of the tournament
|
||||
*/
|
||||
this.name = name || `${nb_players_by_game}x1, ${nb_players} players`;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.nb_players = nb_players;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.nb_players_by_game = nb_players_by_game;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.level = level;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.started = started;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.finished = finished;
|
||||
|
||||
/**
|
||||
* @type {[]}
|
||||
*/
|
||||
this.levels = levels;
|
||||
|
||||
/**
|
||||
* @type {String} must be "finished", or "started", or "waiting". Any other return all elements
|
||||
*/
|
||||
this.state = state;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.id = id
|
||||
|
||||
/**
|
||||
* @type {Boolean} if a websocket connection is enabled
|
||||
*/
|
||||
this.connected = false;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,11 @@ class Tourmanents
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Number} id
|
||||
* @returns
|
||||
*/
|
||||
async getTournament(id)
|
||||
{
|
||||
let tournament = new Tourmanent(this.client);
|
||||
@ -22,6 +27,13 @@ class Tourmanents
|
||||
return tournament;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Number} nb_players
|
||||
* @param {Number} nb_players_by_game
|
||||
* @param {String} name
|
||||
* @returns
|
||||
*/
|
||||
async createTournament(nb_players, nb_players_by_game, name = "")
|
||||
{
|
||||
let response = await this.client._post("/api/tournaments/", {nb_players: nb_players, nb_players_by_game: nb_players_by_game, name: name});
|
||||
@ -34,15 +46,14 @@ class Tourmanents
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} state must be "finished", or "started", or "waiting". Any other return all elements
|
||||
* @param {String} state must be "finished", or "started", or "waiting". Any other return all elements
|
||||
*/
|
||||
|
||||
async search(state)
|
||||
{
|
||||
let response = await this.client._get(`/api/tournaments/search/${state}`);
|
||||
let response_data = await response.json()
|
||||
|
||||
if (response.status === 404)
|
||||
if (response.status === 403)
|
||||
{
|
||||
this.client._update_logged(false);
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user