Last active
May 21, 2016 01:49
-
-
Save Jtmaca9/4e9e32f20e15d946f7d37461aa8a8297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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