add: game history

This commit is contained in:
2024-03-05 10:53:32 +01:00
parent 7a034c2b48
commit de146367c3
8 changed files with 201 additions and 24 deletions

View File

@ -1,4 +1,5 @@
import { Client } from "./Client.js";
import { Game } from "./game/Game.js";
class Profile
{
@ -59,6 +60,36 @@ class Profile
}
/**
* @returns {[Game]}
*/
async getGameHistory()
{
let response = await this.client._get(`/api/games/history/${this.id}`);
let response_data = await response.json();
let games = [];
response_data.forEach(game_data => {
games.push(new Game(this.client,
game_data.id,
null,
null,
null,
game_data.winner_id,
game_data.state,
game_data.started,
game_data.finished,
game_data.players,
game_data.start_timestamp,
game_data.stop_timestamp
)
);
});
return games;
}
async getBlock() {
let block_response = await this.client._get("/api/profiles/block");