add: game history
This commit is contained in:
@ -13,8 +13,16 @@ class Game
|
||||
* @param {CallableFunction} goal_handler
|
||||
* @param {CallableFunction} finish_handler
|
||||
* @param {CallableFunction} disconnect_handler
|
||||
* @param {Boolean} finished
|
||||
* @param {Number} id
|
||||
* @param {[Object]} players_data
|
||||
* @param {Number} start_timestamp
|
||||
* @param {Number} stop_timestamp
|
||||
* @param {Boolean} started
|
||||
* @param {Number} winner_id
|
||||
* @param {String} state
|
||||
*/
|
||||
constructor(client, id, disconnect_handler, goal_handler, finish_handler)
|
||||
constructor(client, id, disconnect_handler, goal_handler, finish_handler, winner_id, state, started, finished, players_data, start_timestamp, stop_timestamp)
|
||||
{
|
||||
/**
|
||||
* @type {Client}
|
||||
@ -40,6 +48,50 @@ class Game
|
||||
* @type {CallableFunction}
|
||||
*/
|
||||
this.disconnect_handler = disconnect_handler;
|
||||
|
||||
/**
|
||||
* @type {String}
|
||||
*/
|
||||
this.state = state;
|
||||
|
||||
/**
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.started = started;
|
||||
|
||||
/**
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.finished = finished;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.winner_id = this.finished ? winner_id : undefined;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.start_timestamp = start_timestamp;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.stop_timestamp = stop_timestamp;
|
||||
|
||||
/**
|
||||
* @type {[Player]}
|
||||
*/
|
||||
this.players = [];
|
||||
|
||||
players_data.forEach(player_data => {
|
||||
this.players.push(new Player(this,
|
||||
player_data.player_id,
|
||||
player_data.username,
|
||||
player_data.score
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,9 +107,6 @@ class Game
|
||||
|
||||
let response_data = await response.json();
|
||||
|
||||
/**
|
||||
* @type {[Player]}
|
||||
*/
|
||||
this.players = [];
|
||||
|
||||
response_data.players.forEach(player_data => {
|
||||
@ -69,34 +118,14 @@ class Game
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {String}
|
||||
*/
|
||||
this.state = response_data.state;
|
||||
|
||||
/**
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.started = response_data.started;
|
||||
|
||||
/**
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.finished = response_data.finished;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.winner_id = this.finished ? response_data.winner_id : undefined;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.start_timestamp = response_data.start_timestamp;
|
||||
|
||||
/**
|
||||
* @type {Number}
|
||||
*/
|
||||
this.stop_timestamp = response_data.stop_timestamp;
|
||||
|
||||
if (this.finished === true)
|
||||
|
Reference in New Issue
Block a user