X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=empires.js;fp=empires.js;h=5b9df829e252e9ef42b9ee4d8338007fb1463bc3;hb=4c810ccb16ea6cfcdcb7f507aea2affc2c36f163;hp=744224e6b68f30a7abfe4bed34df96ceda81651f;hpb=ee64666099c0401afdc1e51fe378359f943d3f69;p=empires-server diff --git a/empires.js b/empires.js index 744224e..5b9df82 100644 --- a/empires.js +++ b/empires.js @@ -176,7 +176,14 @@ class Empires extends Game { })); } - get players() { + /* The base class recently acquired Game.players which works like + * Empires.spectators, (and meanwhile the Empires._players + * functionality could perhaps be reworked into + * Game.players[].team). Until we do that rework, lets use + * .registered_players as the getter for the Empires-specific + * ._players property to avoid mixing it up with the distinct + * Game.players property. */ + get registered_players() { return this._players.map(player => ({id: player.id, name: player.name })); } @@ -222,7 +229,7 @@ class Empires extends Game { } if (this._players.length > 0) { - const players_json = JSON.stringify(this.players); + const players_json = JSON.stringify(this.registered_players); const players_data = `event: players\ndata: ${players_json}\n\n`; response.write(players_data); } @@ -334,7 +341,7 @@ router.get('/spectators', (request, response) => { router.get('/players', (request, response) => { const game = request.game; - response.send(game.players); + response.send(game.registered_players); }); Empires.meta = {