game: add: max score win
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user