games: add: goal table

This commit is contained in:
2024-02-20 16:54:14 +01:00
parent 4d2d4dfb98
commit 4c3116c51f
7 changed files with 58 additions and 27 deletions

View File

@ -14,7 +14,7 @@ class MyPlayer extends Player
*/
constructor(client, game, rail, nb_goal, position)
{
super(game, client.me.id, rail, nb_goal, position, true);
super(game, client.me.id, client.me.username, rail, nb_goal, position, true);
/**
* @type {Client}
*/

View File

@ -7,12 +7,13 @@ class Player
/**
* @param {Number} id
* @param {Game} game
* @param {Segment} rail
* @param {Segment} rail
* @param {Number} nb_goal
* @param {Number} position
* @param {Boolean} is_connected
* @param {String} username
*/
constructor(game, id, rail, nb_goal, position, is_connected)
constructor(game, id, username, rail, nb_goal, position, is_connected)
{
/**
* @type {Game}
@ -43,6 +44,11 @@ class Player
* @type {Segment}
*/
this.rail = rail === undefined ? new Segment() : rail;
/**
* @type {String}
*/
this.username = username;
}
/**
@ -90,30 +96,12 @@ class Player
from_json(data)
{
/**
* @type {Boolean}
*/
this.is_connected = data.is_connected;
/**
* @type {Number}
*/
this.id = data.user_id;
/**
* @type {Number}
*/
this.position = data.position.position ;
/**
* @type {Number}
*/
this.nb_goal = data.nb_goal;
/**
* @type {Segment}
*/
this.rail = this.rail.from_json(data.rail);
this.username = data.username;
return this;
}