const uuid = require('node-uuid'); const players = {}; const Game = function() { this.id = uuid.v4(); } Game.prototype.addPlayer = function(id, name) { if (!players[id]) { players[id] = name; } } Game.prototype.removePlayer = function(id) { players[id] = undefined; delete players[id]; } Game.prototype.getPlayers = function() { return players; } Game.prototype.getRobots = function() { const robots = [ {x: 3, y: 1, color: 'red' }, {x: 19, y: 0, color: 'silver' }, {x: 1, y: 19, color: 'green' } ]; return robots.map(r => [r.color, r.x, r.y]); } Game.prototype.getWalls = function() { const walls = [ {x: 8, y: 9, n: 1, e: 0, s: 0, w: 1 }, {x: 18, y: 9, n: 1, e: 0, s: 0, w: 1 }, {x: 4, y: 19, n: 1, e: 0, s: 0, w: 1 } ]; return walls.map(w => [w.x, w.y, w.n, w.s, w.e, w.w]); }; module.exports = Game;