Skip to content

Instantly share code, notes, and snippets.

@Jtmaca9
Last active May 21, 2016 01:49
Show Gist options
  • Save Jtmaca9/4e9e32f20e15d946f7d37461aa8a8297 to your computer and use it in GitHub Desktop.
Save Jtmaca9/4e9e32f20e15d946f7d37461aa8a8297 to your computer and use it in GitHub Desktop.
var Set = require("collections/set");
var gameList = {};
function gameTiwas() {
this.time = 0;
};
function gameRp() {
this.time = 0;
};
const gameService = {
create(_, data, gameType) {
var id;
//Random id generater, still needs to be adjusted
if(data == ""){
id = Math.floor((Math.random() * 1000) + 1);
}else{
id = data;
}
if(gameType == "tiwas"){
gameList[id] = (new gameTiwas());
}else if(gameType == "rp"){
gameList[id] = (new gameRp());
}
},
get(id) {
if(id == ""){
return gameList;
}
return gameList[id];
},
patch(id, data, __, cb) {
Object.assign(gameList[id], data);
return gameList[id];
},
remove(id) {
delete gameList[id];
}
};
module.exports = function() { this.use('/game', gameService) };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment