Since, whenever anyone has a reference to a game, it can be handy to
be able to query its ID value.
}
class Empires extends Game {
- constructor() {
- super();
+ constructor(id) {
+ super(id);
this._spectators = [];
this.next_spectator_id = 1;
this._players = [];
/* Base class providing common code for game engine implementations. */
class Game {
- constructor() {
+ constructor(id) {
+ this.id = id;
this.clients = [];
this.next_client_id = 1;
}
const engine = engines[engine_name];
- const game = new engine.Game();
+ const game = new engine.Game(id);
this.games[id] = {
id: id,
const router = express.Router();
class TicTacToe extends Game {
- constructor() {
- super();
+ constructor(id) {
+ super(id);
this.moves = [];
this.board = Array(9).fill(null);
}