game: add: max score win

This commit is contained in:
2024-02-27 17:05:30 +01:00
committed by AdrienLSH
parent d5ab413806
commit 6edca15931
5 changed files with 47 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;