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.
32 lines
941 B
32 lines
941 B
var mongo = require("./mongoHelp.js")
|
|
const uuidv4 = require('uuid/v4');
|
|
|
|
var lobby={
|
|
list: () => {
|
|
mongo.get("embezzle","gamelist",{}).then(result => {
|
|
return (result)
|
|
})
|
|
},
|
|
details: (gameID) => {
|
|
mongo.get("embezzle","gamelist",{"gameID":gameID}).then(result => {
|
|
return (result)
|
|
})
|
|
},
|
|
register: (name) => {
|
|
id=uuidv4()
|
|
console.log({"_id":id,"name":name})
|
|
mongo.put("embezzle","players",{"_id":id,"name":name})
|
|
return(id)
|
|
},
|
|
make: (name,seats,ownerID) => {
|
|
gameID=uuidv4()
|
|
mongo.put("embezzle","gamelist",{"gameID":gameID,"ownerID":ownerID,"name":name,"seats":seats, "status":"lobby"})
|
|
return(gameID)
|
|
},
|
|
start: (ownerID, gameID) => {
|
|
mongo.update("embezzle","gamelist",{"gameID":gameID,"ownerID":ownerID}, {"status":"Playing"})
|
|
return(gameID)
|
|
},
|
|
}
|
|
|
|
module.exports = lobby |