Merge branch 'main' of codeberg.org:adrien-lsh/ft_transcendence

This commit is contained in:
Namonay
2024-02-27 18:12:07 +01:00
6 changed files with 49 additions and 9 deletions

View File

@ -6,6 +6,7 @@ import { Player } from "../api/game/Player.js";
import { lang } from "../index.js";
import "https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js";
import { get_labels, transformData } from "../utils/graph.js";
import { sleep } from "../utils/sleep.js";
export default class extends AbstractView
{
@ -149,6 +150,11 @@ export default class extends AbstractView
createGraph()
{
let players = this.game.players;
if (players === undefined)
return;
let graph = document.createElement("canvas");
graph.height = 450;
@ -162,7 +168,7 @@ export default class extends AbstractView
let datasets = [];
this.game.players.forEach(player => {
players.forEach(player => {
let data = transformData(player.score);
@ -228,9 +234,15 @@ export default class extends AbstractView
});
}
async on_disconnect()
{
sleep(500);
await reloadView();
}
async postInit()
{
this.game = new Game(client, this.game_id, this.on_goal, this.on_finish);
this.game = new Game(client, this.game_id, this.on_disconnect, this.on_goal, this.on_finish);
this.keys_pressed = [];
this.my_player = undefined;