You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
889 B

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() {
return [
{i: 9, j: 9, color: '#E00000' },
{i: 18, j: 9, color: '#00C000' },
{i: 1, j: 9, color: '#0000FF' },
{i: 9, j: 18, color: '#00C0C0' },
{i: 9, j: 1, color: '#F000F0' },
];
}
Game.prototype.getWalls = function() {
// Edge IDs are of the form [i1-j1-i2-j2]. Top left is 0, 0.
return [
"1-9-1-10",
"9-1-10-1",
"9-19-10-19",
"19-9-19-10"
];
};
module.exports = Game;