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

@ -12,8 +12,9 @@ class Game
* @param {Client} client
* @param {CallableFunction} goal_handler
* @param {CallableFunction} finish_handler
* @param {CallableFunction} disconnect_handler
*/
constructor(client, id, goal_handler, finish_handler)
constructor(client, id, disconnect_handler, goal_handler, finish_handler)
{
/**
* @type {Client}
@ -34,6 +35,11 @@ class Game
* @type {CallableFunction}
*/
this.finish_handler = finish_handler;
/**
* @type {CallableFunction}
*/
this.disconnect_handler = disconnect_handler;
}
/**
@ -274,6 +280,11 @@ class Game
await this._receive(data);
};
this._socket.onclose = async () => {
this._socket = undefined;
await this.disconnect_handler();
};
return this.wait_init();
}